Kor*_*gay 5 java firefox selenium
如何在自定义Firefox配置文件中使用Selenium和Java?
我花了一天时间尝试这样做,并决定在这里分享.网上也有一些信息,但大多数都有点复杂或不是最新的......
Here is my configuration:
Firefox version: 12
Selenium version: 2.25
Language: Java
Computer: Macintosh
Run Code Online (Sandbox Code Playgroud)
FirefoxBinary binary = new FirefoxBinary();
File firefoxProfileFolder = new
File("/Users/xxx/work/xxx/selenium/src/test/resources/firefoxprofile");
FirefoxProfile profile = new FirefoxProfile(firefoxProfileFolder);
profile.setAcceptUntrustedCertificates(true);
webDriver = new FirefoxDriver(binary, profile);
Run Code Online (Sandbox Code Playgroud)
再次根据需要更改绝对路径.添加autoAuth等附加组件,将Firefox中的HTML授权窗口传递给此配置文件.
小智 6
对于Windows,要创建新的Firefox配置文件,请键入:
firefox -profilemanager
Run Code Online (Sandbox Code Playgroud)
在运行中将打开Firefox配置文件管理器.
假设您创建了一个名为的配置文件Selenium,那么您可以使用以下代码:
ProfilesIni listProfiles = new ProfilesIni();
FirefoxProfile profile = listProfiles.getProfile("Selenium");
WebDriver driver = new FirefoxDriver(profile);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13494 次 |
| 最近记录: |