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...");
		
	}

}

  

相关文章:

  • 2021-09-28
  • 2021-12-28
  • 2021-07-05
  • 2022-12-23
  • 2022-12-23
  • 2021-05-30
  • 2021-11-25
猜你喜欢
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-06
  • 2021-12-13
相关资源
相似解决方案