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
添加回答
舉報