Selenium IEDriver问题启动IE NoSuchWindowException

时间:2012-09-10 15:47:28

标签: java windows internet-explorer selenium webdriver

org.openqa.selenium.NoSuchWindowException: Unable to get browser (WARNING: The server did not provide any stacktrace information)Command duration or timeout: 16 millisecondsBuild info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:08:56'System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_07'Driver info: driver.version: EventFiringWebDriverSession ID: c1d95c8f-b182-4f96-a9f9-ed67f68b0bc9Command duration or timeout: 190 millisecondsBuild info: version: '2.25.0', revision: '17482', time: '2012-07-18 22:18:01'System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.7.4', java.version: '1.6.0_33'Driver info: driver.version: RemoteWebDriverSession ID: 1347289084315at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
 java.lang.reflect.Constructor.newInstance(Constructor.java:513)
 org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
 org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
 org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:498)
 org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:502)
 org.openqa.selenium.remote.RemoteWebDriver.getPageSource(RemoteWebDriver.java:363)
 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 java.lang.reflect.Method.invoke(Method.java:597)
 org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:229)
 org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52)
 org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
 org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
 org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:121)
 com.pearson.moxie.schooladmin.LoginTests.startSelenium(LoginTests.groovy:59)
 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 java.lang.reflect.Method.invoke(Method.java:597)
 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
 org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
 org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
 org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
 org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
 org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
 org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
 org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
 org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
 org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
 org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
 org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
 org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
 org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
 org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
 org.junit.runners.ParentRunner.run(ParentRunner.java:300)
 org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:45)
 org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:123)
 org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:104)
 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 java.lang.reflect.Method.invoke(Method.java:597)
 org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
 org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
 org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:175)
 org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:123)
 org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:195)
 org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAllProviders(AbstractSurefireMojo.java:177)
 org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:135)
 org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:98)
 org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
 org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions(MojoExecutor.java:365)
 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:199)
 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
 org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
 org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
 org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
 org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
 org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
 org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
 org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
 org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
 org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 java.lang.reflect.Method.invoke(Method.java:597)
 org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
 org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
 org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
 org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has been takenBuild info: version: '2.25.0', revision: '17482', time: '2012-07-18 22:18:01'System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.7.4', java.version: '1.6.0_33'Driver info: driver.version: RemoteWebDriverat org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:125)... 73 moreCaused by: org.openqa.selenium.NoSuchWindowException: Unable to get browser (WARNING: The server did not provide any stacktrace information)Command duration or timeout: 16 millisecondsBuild info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:08:56'System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_07'Driver info: driver.version: EventFiringWebDriverSession ID: c1d95c8f-b182-4f96-a9f9-ed67f68b0bc9Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 22:18:01'System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.7.4', java.version: '1.6.0_33'Driver info: driver.version: EventFiringWebDriverat sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
 java.lang.reflect.Constructor.newInstance(Unknown Source)
 org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
 org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
 org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:498)
 org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:502)
 org.openqa.selenium.remote.RemoteWebDriver.getPageSource(RemoteWebDriver.java:363)
 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 java.lang.reflect.Method.invoke(Unknown Source)
 org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:101)
 $Proxy1.getPageSource(Unknown Source)
 org.openqa.selenium.support.events.EventFiringWebDriver.getPageSource(EventFiringWebDriver.java:186)
 org.openqa.selenium.remote.server.handler.GetPageSource.call(GetPageSource.java:29)
 org.openqa.selenium.remote.server.handler.GetPageSource.call(GetPageSource.java:1)
 java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
 java.util.concurrent.FutureTask.run(Unknown Source)
 org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:150)
 java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
 java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 java.lang.Thread.run(Unknown Source)    

这就是我们设置驱动程序的方式:

DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability( InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true );
ieCapabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

driver = new RemoteWebDriver( new URL( "http://" + serverIp + ":" + serverPort + "/wd/hub" ), ieCapabilities );
driver.manage().timeouts().implicitlyWait( 30, TimeUnit.SECONDS );

我们执行:

driver.get("http://www.google.com/");

它成功导航到google.com,然后在下一个selenium或webdriver api调用上抛出此堆栈跟踪:/

我们正在使用Windows 7,即8与RemoteWebDriver 2.25.0和IEDriver.exe

2 个答案:

答案 0 :(得分:3)

IE设置必须修改为link

中的给定

在Windows Vista或Windows 7上的IE 7或更高版本中,必须将每个区域的保护模式设置设置为相同的值。只要每个区域的值相同,该值就可以打开或关闭。要设置保护模式设置,请从“工具”菜单中选择“Internet选项...”,然后单击“安全”选项卡。对于每个区域,标签底部将显示一个标记为“启用保护模式”的复选框。

然后使用以下代码

DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.set(InternetExplorerDriver.
                 INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true); 
WebDriver driver = new InternetExplorerDriver(capabilities);

答案 1 :(得分:0)

本主题已经讨论过here

因此请尝试此驱动程序的设置:

DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.set(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
true); 
WebDriver driver = new InternetExplorerDriver(capabilities);

这对我有用