package test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
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 profile {
@Test
public void test() throws InterruptedException{
//自定义profile,ie不支持,firefox和chrome支持
//profile模式,包含隐私网站,cookie 插件
/*System.setProperty(“webdriver.firefox.bin”, “D:/Firefox/firefox.exe”);
ProfilesIni allprofiles = new ProfilesIni();
FirefoxProfile pro = allprofiles.getProfile(“default”);
WebDriver dr = new FirefoxDriver(pro);
dr.manage().window().maximize();
dr.get(“http://www.baidu.com”);*/
/*System.setProperty(“webdriver.chrome.driver”, “D:/01 Learn WebDriver/chromedriver.exe”);
WebDriver dr = new ChromeDriver();
dr.manage().window().maximize();
dr.get(“http://www.baidu.com”);*/
//把浏览器关掉,再执行以下脚本
System.setProperty(“webdriver.chrome.driver”, “D:/01 Learn WebDriver/chromedriver.exe”);
ChromeOptions options = new ChromeOptions();
options.addArguments(“user-data-dir=C:/Users/fengchuanyun/AppData/Local/Google/Chrome/User Data”);
WebDriver dr = new ChromeDriver(options);
dr.manage().window().maximize();
dr.get(“http://www.baidu.com”);
Thread.sleep(3000);
dr.quit();
}
}
原创文章,作者:carmelaweatherly,如若转载,请注明出处:https://blog.ytso.com/193302.html