如何解决错误“找不到定位符为'name:ide_username'的元素”。使用Selenium和RobotFramework

时间:2019-11-28 05:09:20

标签: selenium selenium-webdriver xpath robotframework webdriverwait

*设置*

Library  SeleniumLibrary

*变量*

${Browser}  Firefox
${URL}  https://allegis.ramcocloud.com/RVW/extui/vwrt/LaunchPanel.htm

*测试用例*

TC1 Browser Start and close
    Open Browser  ${URL}  ${Browser}
    Input Text  name:ide_username  INR004914
    Input Text  xpath://input[@name='ide_password']  tsip890*()

2 个答案:

答案 0 :(得分:0)

我想错误是在第一个“输入文本”上。 尝试按照您在下面的说明复制其xpath

 Input Text  xpath://input[@name='ide_username']  INR004914

答案 1 :(得分:0)

您似乎很近。所需元素是启用了JavaScript的元素,因此您需要引发 wait ,并且可以使用(合并)侍应生中的任一个/两个,并且可以使用以下Locator Strategies

  • 诱导Wait Until Element Is Visible

    TC1 Browser Start and close
        Open Browser  ${URL}  ${Browser}
        Wait Until Element Is Visible    xpath://input[@id='ide_username' and @name='ide_username']    20  seconds
        Input Text  xpath://input[@id='ide_username' and @name='ide_username']  INR004914
        Input Text  xpath://input[@name='ide_password']  tsip890*()
    
  • 诱导Wait Until Element Is Enabled

    TC1 Browser Start and close
        Open Browser  ${URL}  ${Browser}
        Wait Until Element Is Enabled    xpath://input[@id='ide_username' and @name='ide_username']    20  seconds
        Input Text  xpath://input[@id='ide_username' and @name='ide_username']  INR004914
        Input Text  xpath://input[@name='ide_password']  tsip890*()
    
  

您可以在How to click a row that has javascript on click event in RIDE中找到有关Wait Until Element Is VisibleWait Until Element Is Enabled的详细讨论


参考

一些参考文献: