1.输入cmd后继续输入命令firefox.exe -p -no-remote
package com.gloryroad.Demo;
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.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class PersonTest {
String url="http://www.sogou.com";
public WebDriver driver;
@BeforeMethod
public void setUp(){
}
@AfterMethod
public void tearDown(){
driver.close();
}
@Test
public void PersonTest(){
ProfilesIni pro=new ProfilesIni();
try {
FirefoxProfile fox=pro.getProfile("default");
fox.setPreference("browser.startup.homepage",url);
driver=new FirefoxDriver(fox);
} catch (Exception e) {
// TODO: handle exception
System.out.println("出故障了");
}
}
}