Selenium ChromeDriver switch tabs

前端 未结 5 733
走了就别回头了
走了就别回头了 2021-02-07 11:10

When I click on a link in my test, it opens a new tab. I want ChromeDriver to then focus on that tab. I have tried the following code to get ChromeDriver to change tabas using

5条回答
  •  日久生厌
    2021-02-07 11:36

    On my code I click a button and opens a tab (so it is already on the new tab, I don't need to do something to go to that new tab) and run this so it recognize the new tab and worked:

    driver.SwitchTo().Window(driver.WindowHandles.Last());
    

提交回复
热议问题