Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Se (4)-Custom profile

Shulou Source: shulou.com Published: 2022-06-03 05:24:26 11月24日 Update

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 {

/ / Custom profile,ie is not supported, firefox and chrome are supported

/ / profile mode, including private websites and cookie plug-ins

/ * 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", "DJV Learn WebDriver/chromedriver.exe 01")

WebDriver dr = new ChromeDriver ()

Dr.manage (). Window (). Maximize ()

Dr.get ("http://www.baidu.com");*/"

/ / close the browser and execute the following script

System.setProperty ("webdriver.chrome.driver", "DJV 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 ()

}

}

Tags: Support plug-ins patterns browsers websites scripts privacy browsing Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Microsoft MySQL Xiaomi Redmi