资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

Se(4)---自定义profile

package test;

创新互联-专业网站定制、快速模板网站建设、高性价比印江网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式印江网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖印江地区。费用合理售后完善,10年实体公司更值得信赖。

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();

}

}


分享名称:Se(4)---自定义profile
文章源于:http://cdkjz.cn/article/jdojpd.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220