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

后端 未结 7 1238
渐次进展
渐次进展 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:52

    Here are the steps I took for Selenium IDE:

    1. find the link in question
    2. remove the attribute “target” from the link
    3. copy the href destination in a variable (myUrl)
    4. modify the link href->javascript:window.open(myUrl,’myWindow’)
    5. click on link
    6. select window ‘myWindow’

    getEval | this.page().findElement(‘link=click here’).removeAttribute(‘target’)||

    storeEval | this.page().findElement(‘link=click here’).href | myUrl

    getEval | this.page().findElement(‘link=click here’).href=”javascript:window.open(‘${myUrl}’,'myWindow’)” ||

    click | link=click here ||

    pause | 1000 ||

    selectWindow | name=myWindow ||

提交回复
热议问题