下面是我的代码,我可以登录该页面,但登录后无法注销。
最大化浏览器窗口
Input Text //*[@id="userid"] some_user_name
Input Password //*[@id="password"] some_password
Click Button //*[@id="btnSubmit"]
sleep 10s
Select Frame //*[@id="topFrame"]
Page Should Contain Log out
Click Element //*[contains(text(),'Log out')]
日志:
Starting test: WebScraping.NAS web.Welcome 20191009 15:29:40.801 : INFO : Opening browser 'chrome' to base url 'some url'. 20191009 15:29:45.557 : INFO : Typing text '******' into text field '//*[@id="userid"]'. 20191009 15:29:45.658 : INFO : Typing password into text field '//*[@id="password"]'. 20191009 15:29:45.739 : INFO : Clicking button '//*[@id="btnSubmit"]'. 20191009 15:29:55.823 : INFO : Slept 10 seconds 20191009 15:29:55.881 : INFO : Current page contains text 'Log out'. 20191009 15:29:55.881 : INFO : Clicking element '//*[contains(text(),'Log out')]'. 20191009 15:29:56.310 : FAIL : Element with locator '//*[contains(text(),'Log out')]' not found. Ending test: WebScraping.NAS web.Welcome
答案 0 :(得分:0)
我认为问题出在以下几行:
Select Frame //*[@id="topFrame"]
frame标签不包含id属性,而是使用name属性进行标识。 (HTML Tag Documentation)
使用@name代替@id,如下所示
Select Frame //*[@name="topFrame"]
我希望这可以解决您的问题。