How to open a new tab using Selenium WebDriver?

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

    driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL +"t");
    
    ArrayList tabs = new ArrayList (driver.getWindowHandles());
    
    driver.switchTo().window(tabs.get(0));
    

提交回复
热议问题