如何在机器人框架中存储自动生成的值并在以后使用它?

时间:2018-05-17 12:22:00

标签: robotframework

文本框上有一个自动生成的数字,我想存储它,以便我在第二个测试文件中使用它。 这就是我的代码的样子:

*** Keywords ***

Search for Product Code  #keywords to search for a stored value
    [Arguments]  ${prodCode}  
    Selenium2Library.Input Text xpath=//[@id="abcdefg"]  ${prodCode}  #pointing to the searchbox
    ${storedPCode}=  Selenium2Library.Get Text  xpath=//*[@id="mnopqrst"]  #pointing to the textbox with an autogenerated number
    [return]  ${storedPCode}

执行脚本时出现此错误:

webDriverException: Message: unknown error: Element <input type="submit" value=" refresh" class="btn btn-green"> is not clickable at point (404, 308). Other element would receive the click: <div class="modal"></div>

请帮助,谢谢

1 个答案:

答案 0 :(得分:0)

使用获取值而不是获取文本

${storedPCode}= Selenium2Library.Get Value xpath=//*[@id="mnopqrst"]