【问题标题】:Robotframework: Variable ${CUSTOM_VARIABLE} not foundRobotframework:未找到变量 ${CUSTOM_VARIABLE}
【发布时间】: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


    【解决方案1】:

    这不是我们在机器人框架中使用变量的方式。

    试试这个:

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

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

    【讨论】:

      【解决方案2】:

      考虑这段代码:

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

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

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

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

      【讨论】:

        猜你喜欢
        • 2017-04-07
        • 1970-01-01
        • 1970-01-01
        • 2019-02-16
        • 1970-01-01
        • 2019-09-03
        • 2013-01-11
        • 2020-03-07
        • 2012-03-29
        相关资源
        最近更新 更多