Selenium如何在浏览器新开一个Tab

时间:2014-05-13 07:50:42   收藏:0   阅读:216

实现如何在浏览器中新开一个tab,并输入url.

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import org.openqa.selenium.Keys;


      WebElement element = null;

      String url="http://www.baidu.com";

        try {
            element = driver.findElement(By.tagName("body"));
            element.sendKeys(Keys.CONTROL + "t");

            driver.get(url);
            
        } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

Selenium如何在浏览器新开一个Tab,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!