在启动selenium时,firefox总是弹框,很是烦人,需要手动取消。通过google总算找到了办法。
可参见:
http://toolsqa.com/selenium-webdriver/custom-firefox-profile/
当然,也有中文版,可参见:
https://my.oschina.net/jiangbianwanghai/blog/508736
以及:
http://www.cnblogs.com/uslang/articles/5819116.html
以下是我的具体实践:
1. 处理每次都启动新的firefox方法
2. 找到firefox配置所在文件夹路径
3. 利用profile传递给FirefoxDriver
主要部分
private static String path
= "C:\\Users\\用户名\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\6vo0xq9s.default";
static FirefoxProfile profile = new FirefoxProfile(new File(path));
static WebDriver driver = new FirefoxDriver(profile);
PS:
如果firefox未默认安装,则需要设置firefox启动位置
System.setProperty("webdriver.firefox.bin", "D:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
driver = new FirefoxDriver();
/启动IE/
System.setProperty("webdriver.ie.driver", "D:\\selenium\\IEDriverServer.exe");
driver = new InternetExplorerDriver();
随着工作的需要,慢慢都是需要学习的!学无止境,就是有点慢,无暇顾及,尤其是在工作中没有使用到的东西。。。。再接再厉吧!