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

后端 未结 7 1291
渐次进展
渐次进展 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条回答
  •  梦毁少年i
    2020-12-29 06:48

    hi try this one ..

    Set winSet = driver.getWindowHandles();
            List winList = new ArrayList(winSet);
            String newTab = winList.get(winList.size() - 1);
            System.out.println("winList: "+winList.size());
            //driver.close(); // close the original tab
            driver.switchTo().window(newTab);
    

提交回复
热议问题