Robotframework:变量${CUSTOM_VARIABLE}未找到



我创建了一个robotframework测试用例,如果我直接将xpath硬拷贝到关键字中,它似乎可以工作。

例如:

*** Variables ***
${MAIN_FOLDER}=//span[text()=" AutomationTestFolder "]
*** Keywords ***
Folder tear down
navigate to process designer
wait until element is visible  ${FRAME}  180s
select frame  ${FRAME}
#finds the created folder
wait until element is visible  xpath=//span[text()=" AutomationTestFolder "]
click element  xpath=//span[text()=" AutomationTestFolder "]
#below it is basically the same xpath as the one above. The above one works, the below one does not
open context menu  ${MAIN_FOLDER}
#press on delete
wait until element is visible  xpath=//li[a[contains(@data-selected-option, "DELETE")]]  10s
click element  xpath=//li[a[contains(@data-selected-option, "DELETE")]]
#confirm delete
wait until element is visible  xpath=//button[contains(@class, "btn-modal btn-modal-primary hide-focus")]
click element  xpath=//button[contains(@class, "btn-modal btn-modal-primary hide-focus")]

为什么不使用自定义变量?它实际上是相同的xpath

这不是我们在robotframework中使用变量的方式。

试试这个:

${MAIN_FOLDER} //span[text()=" AutomationTestFolder "]

${MAIN_FOLDER}= Set Variable //span[text()=" AutomationTestFolder "]

考虑以下代码:

*** Variables ***
${MAIN_FOLDER}=//span[text()=" AutomationTestFolder "]

您已经定义了一个名为${MAIN_FOLDER}=//span[text()=" AutomationTestFolder "]的变量,其值为空。

您需要在变量名(和可选的=)后面有两个或多个空格:

${MAIN_FOLDER}=    //span[text()=" AutomationTestFolder "]

最新更新