在RobotFramework中单击转到第二个窗口的链接后,有没有办法调整焦点(即前面)第二个窗口?我有一些代码在点击后进行截图,它只显示第一个窗口
Click link xpath=//*[contains(., "Download certificate")]
sleep 20
Select Window Title=Certificate
Page Screenshot Completion-Certificate
我知道弹出窗口的标题是证书,但我收到错误
ValueError: Unable to locate window with title 'Certificate'
答案 0 :(得分:0)
我想,您正在尝试测试点击链接时出现的弹出窗口。您可以使用以下解决方案,
Select Window ${windowId} # Focus popup/required window
答案 1 :(得分:0)
我认为您的案例将遵循以下要求:
Select Window locator=Certificate
答案 2 :(得分:0)
Handle Lookup Window
Select Window NEW #comment: It will automatically move to new window
${tempB}= Get Title
Log To Console New window is : \ ${tempB} # to verify the name in console
Select Frame //*[@title='Search'] # optional sometimes elements are within frames ,so first need to access frame
Input Text id=lksrch hello
Click Element //*[@value=' Go! ']
Unselect Frame # going back to page
Select Frame //*[@title='Results'] #selecting another frame
Click Element id=jobdone
Select Window #once the jobdone button is clicked my pop up browser window is automatically get closed.so going back to parent browser.
注意:以#开头的行是注释,仅供理解 谢谢!
答案 3 :(得分:0)
是的,您可以通过添加以下脚本来实现它-
Switch Window locator=NEW
//This will take you to the latest window launched.
对我有用。
答案 4 :(得分:0)
您可以通过标题,URL或窗口句柄ID切换到多个窗口。为此,请使用Robot Framework中的“选择窗口”关键字。
示例1:
open browser http://qaTechTesting.com Chrome
click element (//img[@alt='Raghwen Linkedin Profile'])[1]
Select Window Raghwendra Sonu
示例2:
open browser http://qaTechTesting.com Chrome
click element (//img[@alt='Raghwen Linkedin Profile'])[1]
@{list1} get window handles
:FOR ${Win} in ${list1}
\ Select Window ${Win}
有关更多详细信息,请阅读:http://robotframework.org/Selenium2Library/Selenium2Library.html#Select%20Window