Selenium启动加载用户配置的浏览器(Chrome/Firefox)

加载chrome用户配置

   

 System.setProperty("webdriver.chrome.bin", "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe");
        System.setProperty("webdriver.chrome.driver", "C:/Program Files (x86)/Google/Chrome/Application/chromedriver.exe");  //chromedriver.exe的安装路径
        //设置Webdriver启动chrome为默认用户的配置信息(包括书签、扩展程序等)
        ChromeOptions options = new ChromeOptions();
        options.addArguments("user-data-dir=C:/Users/acer/AppData/Local/Google/Chrome/User Data"); //第一步chrome://version/中的对应信息
        WebDriver driver = new ChromeDriver(options);
        driver.manage().window().maximize();//窗口最大化



加载firefox用户配置

   

 ProfilesIni allProfiles = new ProfilesIni();
    FirefoxProfile profile = allProfiles.getProfile("default"); //default为火狐默认
    WebDriever driver  = new FirefoxDriver(profile);

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值