如何使用Selenium自定义Firefox配置文件? (Java)(并通过HTML授权窗口) [英] How to use custom Firefox Profile with Selenium? (Java) (And pass HTML Authorization Window)
本文介绍了如何使用Selenium自定义Firefox配置文件? (Java)(并通过HTML授权窗口)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
我花了一天的时间尝试做到这一点,并决定在这里分享。在网上也有一些信息,但大多数都有点复杂或不及时... ...
这里是我的配置:
$ p $打开终端
Firefox版本:12
Selenium版本:2.25
语言:Java
计算机:Macintosh
$ b pre>
FirefoxBinary binary = new FirefoxBinary();
文件firefoxProfileFolder = new
文件(/ Users / xxx / work / xxx / selenium / src / test / resources / firefoxprofile);
FirefoxProfile profile = new FirefoxProfile(firefoxProfileFolder);
profile.setAcceptUntrustedCertificates(true);
webDriver =新的FirefoxDriver(binary,profile);
再次按需要更改绝对路径。
添加像autoAuth这样的加载项,将Firefox中的HTML授权窗口传递给此配置文件。
How can I use Selenium with Java with a custom Firefox Profile?
解决方案
I have spent a day trying to do this and decided to share it here. There is some information on the web as well but most of them are a bit complicated or not up to date...
Here is my configuration:
Firefox version: 12
Selenium version: 2.25
Language: Java
Computer: Macintosh
- Open Terminal
- type: /Applications/Firefox.app/Contents/MacOS/firefox-bin -p ( change the path as necessary )
- Create a new profile, save it in a directory as you wish..
- Start firefox with this profile, add any addons, modifications as you wish.
- In Selenium, use:
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);
Again here change the absolute path as required. Add add-ons like autoAuth to pass the HTML Authorization windows in Firefox to this profile..
这篇关于如何使用Selenium自定义Firefox配置文件? (Java)(并通过HTML授权窗口)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文