问题描述
我来自Ruby,我知道如何在Ruby Selenium Binding中进行此操作,但是我不知道如何执行Java Selenium Binding,
I am coming from Ruby background, I know how to do this in Ruby Selenium Binding, but I don't know how to do it Java Selenium Binding,
我有这段代码可以创建Firefox个人资料
I have this code to create Firefox profile
FirefoxProfile firefoxProfile = new FirefoxProfile(pathToProfile);
WebDriver driver=new FirefoxDriver(firefoxProfile);
它可以在硒2.53中使用,但是在最近的硒绑定3.11.0中会引发错误,有人可以告诉我有什么替代方法吗?
It works in selenium 2.53 but it's throws error in very recent selenium binding 3.11.0, Can anyone tell me what's the alternative?
我也想关闭木偶以连接到旧版Firefox驱动程序,我可以使用以下代码完成此操作
And also I wanted to switch off the marionette to connect to Legacy Firefox driver, I can do this with the following code
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", false);
WebDriver driver=new FirefoxDriver(capabilities);
但是,如果我使用上面的行,则表明FirefoxDriver已被弃用.谁能指导我如何创建个人资料以及如何关闭木偶?
But if I use the above line, then it gives the FirefoxDriver is deprecated. Can anyone guide me how to create profile as well as how to switch off the marionette?
推荐答案
是,不赞成使用FirefoxDriver(desiredCapabilities)
.
替代的方法是使用选项:
FirefoxOptions foptions = new FirefoxOptions(capabilities);
WebDriver driver=new FirefoxDriver(foptions);
更新:[顺序]
FirefoxOptions foptions = new FirefoxOptions();
FirefoxProfile firefoxProfile = new FirefoxProfile(pathToProfile);
foptions.setProfile(firefoxProfile);
foptions.setCapability("marionette", false);
foptions.setBinary("C:\\Program Files\\Mozilla Firefox 52\\firefox.exe");
WebDriver driver = new FirefoxDriver(foptions);
这篇关于创建Firefox配置文件并关闭木偶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!