How do I change focus to a new popup tab in Selenium?

后端 未结 7 1319
渐次进展
渐次进展 2020-12-29 06:38

I\'m using Selenium and Firefox.

I have a link on a page (say linkA) that opens a new page in a new tab. The new tab is displayed when linkA is clicked. I then w

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-29 06:41

    Did you try adding a windowFocus between selectWindow and click linkB?

    Edit: selectWindow takes a Javascript windowID. Does your linkA specify a windowID for Selenium to access?

    Here is the full first test page (t1.html), in the window.open call the 2nd parameter is 'WindowTest', this is the javascript windowID that selenium looks for.

    
     test
    
    

    Here is the second test page (t2.html):

    2test2
    

    Running your script ends up with the popup window on t1.html My script

    click              link=test
    pause              5000
    selectWindow       WindowTest
    windowFocus
    click              link=2test2
    

提交回复
热议问题