1 回答
TA贡献1810条经验 获得超4个赞
此信息日志消息:
INFO: Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
是包含在以下内容中的更改的结果:
硒 v3.0.0-beta4
Added ability to use FirefoxOptions when starting firefox.
硒 v3.5.0
* Start making *Option classes instances of Capabilities. This allows
the user to do:
`WebDriver driver = new RemoteWebDriver(new InternetExplorerOptions());`
如果您的用例是明确提及的绝对位置,FirefoxBinary您可以使用以下解决方案:
使用FirefoxOptions:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
public class A_Firefox_binary
{
public static void main(String[] args)
{
System.setProperty("webdriver.gecko.driver", "C:/Utility/BrowserDrivers/geckodriver.exe");
FirefoxOptions options = new FirefoxOptions();
options.setBinary("C:\\Program Files\\Mozilla Firefox\\firefox.exe");
WebDriver driver = new FirefoxDriver(options);
driver.get("https://stackoverflow.com");
System.out.println("Page Title is : "+driver.getTitle());
driver.quit();
}
}
控制台输出:
Page Title is : Stack Overflow - Where Developers Learn, Share, & Build Careers
添加回答
举报