【发布时间】:2021-11-05 09:16:39
【问题描述】:
我创建了一个机器人框架测试用例,如果我将 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
【问题讨论】:
标签: python automated-tests robotframework