FireFox

时间:2016-08-24 15:11:43

标签: java firefox selenium-webdriver

Selenium WebDriver 2.53.1使用FireFox 47.0.1和Java:

无论driver1.getWindowHandles()只返回一个句柄。在Chrome中,下面的代码运行正常并返回正确数量的句柄。

无论如何使用firefox以这种方式返回多个窗口句柄?

    driver1 = new FirefoxDriver();

    // LOOP TO OPEN AS MANY TABS AS YOU WISH
    for(int i = 0; i < TAB_NUMBER; i++) {
       driver1.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL + "t");
       // SLEEP FOR SPLIT SECOND TO ALLOW DRIVER TIME TO OPEN TAB
       Thread.sleep(100);
     }
    // STORE TAB HANDLES IN ARRAY LIST FOR EASY ACCESS
    ArrayList tabs1 = new ArrayList<String> (driver1.getWindowHandles());

    System.out.println(tabs1);

0 个答案:

没有答案