How to open a new tab using Selenium WebDriver?

后端 未结 29 2849
野的像风
野的像风 2020-11-22 04:40

How to open a new tab in the existing Firefox browser using Selenium WebDriver (a.k.a. Selenium 2)?

29条回答
  •  天涯浪人
    2020-11-22 05:37

    Almost all answers here are out of date.

    WebDriver now has support for opening tabs:

    browser = Selenium::WebDriver.for :chrome
    new_tab = browser.manage.new_window
    

    Will open a new tab. Opening a window has actually become the non-standard case:

    browser.manage.new_window(:window)
    

    The tab or window will not automatically be focussed. To switch to it:

    browser.switch_to.window new_tab
    

提交回复
热议问题