当我尝试打开driver1.get("http://www.google.com");
时,它会打开网站两次并抛出下面的错误。然后我试图浏览旧版本的Selenium,似乎没有任何工作。
这些是我试过的版本
Selenium: 2.53.0
Java: "1.8.0_92"
Windows: Windows 7 Professional
FireFox: 45.2.0
线程中的异常" main" org.openqa.selenium.WebDriverException:找不到会话:15676d46-e86c-420d-a349-b73ca0f5bb59 命令持续时间或超时:5.54秒 构建信息:版本:' 2.53.0',修订版:' 35ae25b',时间:' 2016-03-15 16:57:40' 系统信息:主机:' IBM263-PC07TNJV',ip:' 9.124.217.133',os.name:' Windows 7',os.arch:&# 39; amd64',os.version:' 6.1',java.version:' 1.8.0' 驱动程序信息:org.openqa.selenium.firefox.FirefoxDriver Capabilities [{applicationCacheEnabled = true,rotate = false,handlesAlerts = true,databaseEnabled = true,version = 45.2.0,platform = WINDOWS,nativeEvents = false,acceptSslCerts = true,webStorageEnabled = true,locationContextEnabled = true,browserName = firefox,takesScreenshot = true,javascriptEnabled = true,cssSelectorsEnabled = true}] 会话ID:15676d46-e86c-420d-a349-b73ca0f5bb59 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:88) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57) at java.lang.reflect.Constructor.newInstance(Constructor.java:437) 在org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) 在org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) 在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678) 在org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:316) 在Test.main(Test.java:19) 引起:org.openqa.selenium.WebDriverException:找不到会话:15676d46-e86c-420d-a349-b73ca0f5bb59 构建信息:版本:' 2.53.0',修订版:' 35ae25b',时间:' 2016-03-15 16:57:40' 系统信息:主机:' IBM263-PC07TNJV',ip:' 9.124.217.133',os.name:' Windows 7',os.arch:&# 39; amd64',os.version:' 6.1',java.version:' 1.8.0' 驱动程序信息:driver.version:未知 at .nsCommandProcessor.prototype.execute(file:/// C:/Users/IBM_AD〜1/AppData/Local/Temp/anonymous3999483330061689508webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12704) at .Dispatcher.executeAs /<(file:/// C:/Users/IBM_AD〜1/AppData/Local/Temp/anonymous3999483330061689508webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:9558 ) at .Resource.prototype.handle(file:/// C:/Users/IBM_AD〜1/AppData/Local/Temp/anonymous3999483330061689508webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:9705) at .Dispatcher.prototype.dispatch(file:/// C:/Users/IBM_AD~1/AppData/Local/Temp/anonymous3999483330061689508webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:9652) at .WebDriverServer /< .handle(file:/// C:/Users/IBM_AD~1/AppData/Local/Temp/anonymous3999483330061689508webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:12517 ) at .createHandlerFunc /<(file:/// C:/Users/IBM_AD~1/AppData/Local/Temp/anonymous3999483330061689508webdriver-profile/extensions/fxdriver@googlecode.com/components/httpd.js:2054) at .ServerHandler.prototype.handleResponse(file:/// C:/Users/IBM_AD~1/AppData/Local/Temp/anonymous3999483330061689508webdriver-profile/extensions/fxdriver@googlecode.com/components/httpd.js:2387) at .Connection.prototype.process(file:/// C:/Users/IBM_AD~1/AppData/Local/Temp/anonymous3999483330061689508webdriver-profile/extensions/fxdriver@googlecode.com/components/httpd.js:1223) at .RequestReader.prototype._handleResponse(file:/// C:/Users/IBM_AD~1/AppData/Local/Temp/anonymous3999483330061689508webdriver-profile/extensions/fxdriver@googlecode.com/components/httpd.js:1677) at .RequestReader.prototype._processBody(file:/// C:/Users/IBM_AD~1/AppData/Local/Temp/anonymous3999483330061689508webdriver-profile/extensions/fxdriver@googlecode.com/components/httpd.js:1525) at .RequestReader.prototype.onInputStreamReady(file:/// C:/Users/IBM_AD~1/AppData/Local/Temp/anonymous3999483330061689508webdriver-profile/extensions/fxdriver@googlecode.com/components/httpd.js:1393)
我也尝试使用IE(11.0.9600.18439CO),但在driver1.close();
期间我仍然收到此错误
启动InternetExplorerDriver服务器(32位) 2.53.1.0 在港口25952上听 仅允许本地连接 线程" main"中的例外情况org.openqa.selenium.NoSuchWindowException:无法获取浏览器(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:16毫秒 构建信息:版本:' 2.53.0',修订版:' 35ae25b',时间:' 2016-03-15 16:57:40' 系统信息:主机:' IBM263-PC07TNJV',ip:' 9.124.217.133',os.name:' Windows 7',os.arch:&# 39; amd64',os.version:' 6.1',java.version:' 1.8.0' 驱动程序信息:org.openqa.selenium.ie.InternetExplorerDriver Capabilities [{browserAttachTimeout = 0,ie.enableFullPageScreenshot = true,enablePersistentHover = true,ie.forceCreateProcessApi = false,ie.forceShellWindowsApi = false,pageLoadStrategy = normal,ignoreZoomSetting = false,ie.fileUploadDialogTimeout = 3000,version = 11,platform = WINDOWS ,nativeEvents = true,ie.ensureCleanSession = false,elementScrollBehavior = 0,ie.browserCommandLineSwitches =,requireWindowFocus = false,browserName = internet explorer,initialBrowserUrl = http://localhost:25952/,javascriptEnabled = true,ignoreProtectedModeSettings = false,enableElementCacheCleanup = true,unexpectedAlertBehaviour =驳回}] 会议ID:5097a6b5-66e6-4136-8551-8797496f5051 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:88) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57) at java.lang.reflect.Constructor.newInstance(Constructor.java:437) 在org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) 在org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) 在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678) 在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:701) 在org.openqa.selenium.remote.RemoteWebDriver.close(RemoteWebDriver.java:521) 在Test.main(Test.java:35)
这些是最基本的,应该有效吗?我错过了什么吗?
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class Test
{
public static void main(String[] args) throws InterruptedException
{
System.setProperty("webdriver.ie.driver", "C:\\SoftWareDownLoads\\IEDriverServer_Win32_2.53.1\\IEDriverServer.exe");
WebDriver driver1 = new InternetExplorerDriver();
//WebDriver driver1 = new FirefoxDriver();
driver1.get("http://www.google.com");
driver1.close();
}
}
答案 0 :(得分:0)
您的IE错误消息包含"无法获取浏览器"。可能的原因是Selenium无法找到IE驱动程序。您能否确定您为IE驱动程序获取.exe文件所提供的路径是否正确?
对于Firefox,请尝试使用
driver1.quit();
之后的driver1.close();
。这可能会阻止另一个浏览器窗口被启动,无论出于什么奇怪的原因。