单击“应用”链接后,它将在Robot框架中打开一个新浏览器。如何获取该页面的当前网址?这是代码:
Open Server
Set Browser Implicit Wait 60
Go To ${server}/jobs
Element Should Be Visible xpath=.//*[@id='txtjobsearch']
Input Text xpath=.//*[@id='txtjobsearch'] ${job Title search}
Element Should Contain xpath=(.//*[@class='clearfix tit-job']/div)[1] ${Job title}
Element Should Be Visible xpath=(.//*[@class='btn btn-sm btn-primary btnApply'])[1]
Click Element xpath=(.//*[@class='btn btn-sm btn-primary btnApply'])[1]
在此行之后,它会打开一个新窗口。如何获取新打开的页面的URL并执行输入文本等操作?
Set Browser Implicit Wait 20
Wait Until Page Contains Element xpath=.//*[@class='text-primary']
答案 0 :(得分:1)
您是否尝试过使用“选择窗口”关键字?
http://rtomac.github.io/robotframework-selenium2library/doc/Selenium2Library.html#Select%20Window
Click Link popup_link # opens new window
Select Window popupName
Title Should Be Popup Title
Select Window # Chooses the main window again
您似乎希望验证新窗口的网址,应该可以通过以下方式轻松实现:
Select Window | url=https://google.com
显然,您需要将上述网址替换为您期望的内容。让我们知道你是如何上场的。
答案 1 :(得分:1)
使用Execute Javascript SeleniumLibrary关键字轻松获取当前网址:
${url} = Execute Javascript return window.location.href;
答案 2 :(得分:1)
试试这个:
${url}= Get Location