我想使用eclipse运行Selenium网络驱动程序自动化但无法打开浏览器窗口。调试日志显示,没有任何错误,我能够成功地检索该网页的标题如下图所示:无法启动任何浏览器使用硒webdriver
try {
System.setProperty("webdriver.gecko.driver","/Users/shankar.sharma/Downloads/chrome-driver/geckodriver");
DesiredCapabilities cap = DesiredCapabilities.firefox();
cap.setCapability("marionette", true);
FirefoxOptions options = new FirefoxOptions();
options.addPreference("log", "{level: error}");
WebDriver driver = new FirefoxDriver();
driver.navigate().to("http://www.seleniumhq.org/download/");
String appTitle = driver.getTitle();
System.out.println("Application title is :: "+appTitle);
driver.quit();
} catch (Exception e) {
System.out.println("Exception:"+e.getMessage());
}
调试日志: 1496221115902 geckodriver信息上127.0.0.1:39119听力 1496221116097 geckodriver ::木偶INFO启动浏览器/Applications/Firefox.app/Contents/MacOS/firefox-bin与ARGS [ “-marionette”] 1496221117678木偶信息侦听端口 2017年5月31日下午2时28分38秒org.openqa.selenium.remote.ProtocolHandshake createSession 信息:检测到的方言:W3C 2017-05-31 14:28:38.036 plugin-container [55325:3295542] * CFMessagePort:bootstrap_register():failed 1100(0x44c)'Permission denied',port = 0x9c3b,name ='com.apple.tsm。 portname' 有关错误代码,请参阅/usr/include/servers/bootstrap_defs.h。 2017-05-31 14:28:38.038 plugin-container [55325:3295542] * CFMessagePort:bootstrap_register():failed 1100(0x44c)'Permission denied',port = 0x9f03,name ='com.apple.CFPasteboardClient' 有关错误代码,请参阅/usr/include/servers/bootstrap_defs.h。 应用程序标题:: Downloads 1496221129876 Marionette信息新的连接将不再被接受
但浏览器窗口未打开。我也尝试过使用chrome驱动程序,但那也不起作用。我使用如下配置:
- 硒网络驱动程序:3.4.0
- LGecko司机:v0.16.0
为什么发生这种情况的原因任何想法?
您的geckodriver属性不正确。 –
@SiddheshKalgaonkar我认为路径是正确的。如果我添加.exe扩展名,那么它停止工作。 –
我编辑了我的评论,如果你添加.exe它不应该停止工作。请参考我的答案 –