How to open a new tab using Selenium WebDriver?

后端 未结 29 2459
野的像风
野的像风 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:39

    *JAVA

    I recommend to using JavascriptExecutor:

    • Open new blank window:
    ((JavascriptExecutor) driver).executeScript("window.open()");
    
    • Open new window with specific url:
    ((JavascriptExecutor) driver).executeScript("window.open('https://google.com')");
    

    Following import:

    import org.openqa.selenium.JavascriptExecutor;
    

提交回复
热议问题