WebDriver中启动不同的浏览器

import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;


public class FirstExample {

    /**
     * @param args
     * @throws InterruptedException 
     */
    public static void main(String[] args) throws InterruptedException {

        //打开指定地方的firefox
//        System.setProperty("webdriver.firefox.bin","C:\\Users\\test\\AppData\\Local\\Mozilla Firefox\\firefox.exe");
//        FirefoxDriver driver = new FirefoxDriver();
        
        //打开IE8
//        System.setProperty("webdriver.ie.driver","E:\\driver\\IEDriverServer.exe");
//        InternetExplorerDriver driver = new InternetExplorerDriver();
        
        //打开chrome浏览器
        System.setProperty("webdriver.chrome.driver","E:\\driver\\chromedriver.exe");
        ChromeDriver driver = new ChromeDriver();
        
        driver.get("http://localhost:8080/test/login.jsp");
        driver.findElementByName("userName").sendKeys("test");
        driver.findElementById("userPwd").sendKeys("test");
        driver.findElementById("login").click();

        System.out.println(driver.findElementByXPath("//*[@id='modify_psw']/a").getText());
        
        driver.close();
    }

}

 备注:
    1. firefox浏览器

           selenium版本:2.44.0   firefox的版本:33.1

    2. chrome浏览器

           selenium版本:2.44.0   chrome版本: 33.0.1750.154   相应的chromedriver的驱动(驱动与selenium和chrome的版本也是对应的)

   3. IE浏览器

           selenium版本:2.44.0   IE版本: IE8   相应的IE的驱动(驱动与selenium和IE的版本也是对应的)

 

转载于:https://www.cnblogs.com/zhuhaiying/p/4939884.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值