How to open a new tab using Selenium WebDriver?

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

    Try this for the FireFox browser.

    /*  Open new tab in browser */
    public void openNewTab()
    {
        driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL +"t");
        ArrayList tabs = new ArrayList (driver.getWindowHandles());
        driver.switchTo().window(tabs.get(0));
    }
    

提交回复
热议问题