无法在FirefoxDriver中加载自定义配置文件:构造函数FirefoxDriver(Firefox配置文件)未定义
我试图在www.naukri.com中处理多个弹出窗口阻止程序;为此,我在firefox中创建了一个名为“AutoProfile”的自定义配置文件。但我在加载这个自定义配置文件在Firefox的驱动程序有问题;无法在FirefoxDriver中加载自定义配置文件:构造函数FirefoxDriver(Firefox配置文件)未定义
System.setProperty("webdriver.gecko.driver", "F:\\abc\\geckodriver-v0.18.0-win64\\geckodriver.exe");
ProfilesIni profile2=new ProfilesIni();
FirefoxProfile profile3=profile2.getProfile("AutoProfile");
profile3.setPreference("browser.popups.showPopupBlocker", false);
driver =new FirefoxDriver(profile3);
driver.get("www.naukri.com");
但我得到一个错误在driver=new FirefoxDriver(profile3);
它说:
The constructor FirefoxDriver(FirefoxProfile) is undefined.
有些时候,我得到一个消息作为构造已被弃用。
这个问题是由于旧的硒版本并存。 mvn clean install解决了这个问题。
更新壁虎驱动器和库
希望您的问题将得到解决
什么是硒Geckodriver的版本,您使用的
?
从https://raw.githubusercontent.com/SeleniumHQ/selenium/master/rb/CHANGES
3.4.1 (2017-06-13)
==================
Firefox:
* Added new Firefox::Options class that should be used to customize browser
behavior (command line arguments, profile, preferences, Firefox binary, etc.).
The instance of options class can be passed to driver initialization using
:options key. Old way of passing these customization directly to driver
initialization is deprecated.
为了设置配置文件,你应该做这样的事情:
System.setProperty("webdriver.gecko.driver", "F:\\abc\\geckodriver-v0.18.0-win64\\geckodriver.exe");
ProfilesIni profile2 = new ProfilesIni();
FirefoxProfile profile3 = profile2.getProfile("AutoProfile");
profile3.setPreference("browser.popups.showPopupBlocker", false);
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setProfile(profile3);
WebDriver driver = new FirefoxDriver(firefoxOptions);
driver.get("www.naukri.com");
谢谢你的回复..它确实解决了我的问题。再次感谢你! –
@JohnDoe乐于帮忙,欢迎来到Stack Overflow。如果此答案或任何其他人解决了您的问题,请将其标记为已接受:stackoverflow.com/help/someone-answers –
感谢您的回复,我没有下载最新的磁带库和驱动器壁虎。但问题仍然存在.. –