启动带有用户配置信息的FireFox浏览器

1)位火狐创建配置文件

      此步骤请参考http://jingyan.baidu.com/article/9f7e7ec079bff46f281554f0.html

2)在启动的浏览器中配置自己需要的配置项,比如加载FireBug之类,配置完成后关闭FireFox浏览器

3)使用Selenium调用配置好的profile文件,其中pi.getProfile("WebDriver")中的WebDriver为创建配置文件名,之后调用起来的firefox是添加了配置项的fireFox 

package com.testng.webdriver;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
import org.testng.annotations.Test;

public class CreateFireProfile {
	WebDriver driver;
	String baseUrl;
	@Test
	public void testFirefoxProfile()
	{
		  
		//String profile_dir="C:\\Users\\Administrator\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\br4sk518.WebDriver";
		System.out.println("start firefox browser...");
		System.setProperty("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
		ProfilesIni pi = new ProfilesIni();
		FirefoxProfile profile = pi.getProfile("WebDriver");
	    WebDriver driver = new FirefoxDriver(profile);
		driver.get("http://localhost:8080/Example1.html");
		System.out.println("start firefox browser succeed...");
		
	}

}

  

转载于:https://www.cnblogs.com/xmmc/p/7586808.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值