FirefoxDriver() 不接受 ProfilesIni 实例作为参数
FirefoxDriver() does not accept ProfilesIni instance as argument
我正在按照此页面上的示例设置要使用的自定义配置文件:
http://toolsqa.com/selenium-webdriver/custom-firefox-profile/
但是在我的代码中出现 "Remove argument to match Firefox driver" 错误:
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("testProfile");
WebDriver driver = new FirefoxDriver(myprofile); // does not like myprofile as an argument here
谢谢
更新
我可以通过稍微修改 try-catch 的解决方案来解决这个问题:
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("testProfile"); //added this
FirefoxOptions options = new FirefoxOptions();
options.setProfile(myprofile);
根据 FirefoxDriver
的 API 文档,没有 FirefoxDriver(ProfilesIni)
签名并且 ProfilesIni
没有基础 class 也没有实现可用的接口FirefoxDriver
.
的构造函数签名
通过 FirefoxDriver(FirefoxOptions)
签名。 FirefoxDriver
有一个 setProfile(FirefoxProfile profile)
方法。
这应该有效:
ProfilesIni profile = new ProfilesIni();
FirefoxOptions options = new FirefoxOptions();
options.setProfile(profile.getProfile("testProfile"));
WebDriver driver = new FirefoxDriver(options);
我正在按照此页面上的示例设置要使用的自定义配置文件:
http://toolsqa.com/selenium-webdriver/custom-firefox-profile/
但是在我的代码中出现 "Remove argument to match Firefox driver" 错误:
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("testProfile");
WebDriver driver = new FirefoxDriver(myprofile); // does not like myprofile as an argument here
谢谢
更新
我可以通过稍微修改 try-catch 的解决方案来解决这个问题:
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("testProfile"); //added this
FirefoxOptions options = new FirefoxOptions();
options.setProfile(myprofile);
根据 FirefoxDriver
的 API 文档,没有 FirefoxDriver(ProfilesIni)
签名并且 ProfilesIni
没有基础 class 也没有实现可用的接口FirefoxDriver
.
通过 FirefoxDriver(FirefoxOptions)
签名。 FirefoxDriver
有一个 setProfile(FirefoxProfile profile)
方法。
这应该有效:
ProfilesIni profile = new ProfilesIni();
FirefoxOptions options = new FirefoxOptions();
options.setProfile(profile.getProfile("testProfile"));
WebDriver driver = new FirefoxDriver(options);