我试图在边缘运行一些硒测试,我遇到了这个问题:
当我从java环境(例如JDeveloper)运行它们时,一切正常。但是,我们已经设置了一个ant进程来从命令行调用测试。当我尝试这样做时,WebDriver未初始化并抛出和未知异常错误。
我很确定错误不在ant文件中,因为如果我在chrome中运行相同的测试,它可以正常工作。
这是代码失败的部分:
System.setProperty("webdriver.edge.driver","PathToFolder\\MicrosoftWebDriver.exe");
DesiredCapabilities capability = DesiredCapabilities.edge();
driver = new EdgeDriver(capability);
我确信这个问题不在路径中,因为当我直接从课程中运行它时,它就可以工作了。此外,我已检查了内部版本号,并且我有正确的MicrosoftWebDriver.exe,因此也不是问题。
我得到的错误如下:
org.openqa.selenium.WebDriverException: Unknown error
[java] Command duration or timeout: 1.20 seconds
[java] Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52'
[java] System info: host: 'DIANA', ip: '10.0.75.1', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.7.0_79'
[java] Driver info: org.openqa.selenium.edge.EdgeDriver
更新: 我能够恢复完整的日志,这是以后的事情:
java.lang.Error: org.openqa.selenium.WebDriverException: Unknown error
Command duration or timeout: 1.01 seconds
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52'
System info: host: 'FORMIGA', ip: '172.25.208.1', os.name: 'Windows 8', os.arch: 'amd64', os.version: '6.2', java.version: '1.7.0_25'
Driver info: org.openqa.selenium.edge.EdgeDriver
at com.wiris.webtester.WebPage.<init>(WebPage.java:126)
at com.wiris.webtester.Context.initBrowser(Context.java:377)
at com.wiris.webtester.Context.browse(Context.java:284)
at com.wiris.webtester.action.BrowseAction.onExecute(BrowseAction.java:25)
at com.wiris.webtester.action.BaseAction.execute(BaseAction.java:15)
at com.wiris.webtester.action.TestAction.test(TestAction.java:77)
at com.wiris.util.test.TestFile.test(TestFile.java:48)
at com.wiris.util.test.TestList.executeFiltered(TestList.java:187)
at com.wiris.util.test.TestList.execute(TestList.java:138)
at com.wiris.webtester.TesterMain.run(TesterMain.java:151)
at com.wiris.webtester.TesterMain.main(TesterMain.java:194)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:221)
at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:154)
at org.apache.tools.ant.taskdefs.Java.run(Java.java:834)
at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:228)
at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:137)
at org.apache.tools.ant.taskdefs.Java.execute(Java.java:110)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:402)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:441)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:441)
at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.Main.runBuild(Main.java:857)
at org.apache.tools.ant.Main.startAnt(Main.java:236)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:287)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:113)
Caused by: org.openqa.selenium.WebDriverException: Unknown error
Command duration or timeout: 1.01 seconds
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52'
System info: host: 'FORMIGA', ip: '172.25.208.1', os.name: 'Windows 8', os.arch: 'amd64', os.version: '6.2', java.version: '1.7.0_25'
Driver info: org.openqa.selenium.edge.EdgeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:152)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:120)
at com.wiris.webtester.WebPage.<init>(WebPage.java:121)
... 75 more
答案 0 :(得分:0)
错误确实给了我们一些提示:
java.lang.Error: org.openqa.selenium.WebDriverException: Unknown error
Command duration or timeout: 1.01 seconds
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52'
System info: host: 'FORMIGA', ip: '172.25.208.1', os.name: 'Windows 8', os.arch: 'amd64', os.version: '6.2', java.version: '1.7.0_25'
Driver info: org.openqa.selenium.edge.EdgeDriver
这实质上意味着EdgeDriver
二进制文件根本没有检测到并且未初始化会引发未知错误
您的主要问题是您使用的二进制文件中的版本兼容性,如下所示:
JDK Version 1.7.0_25
[as per the error stack trace within your question
] Selenium Version 2.48.2
(已发布 2015-10-09 19:55:52 )[as per the error stack trace within your question
] EdgeDriver
(版本 UNKNOWN 给我们)Edge Browser
(版本 UNKNOWN 给我们)很明显:
JDK Version
已过期。EdgeDriver
二进制文件没有检测到。JDK
更新为最近的JDK 8u151
级别。Selenium
升级到当前级别Version 3.8.1
。EdgeDriver
升级到当前v5.16299
级别。Edge Browser
升级到支持的v16.16299
级别。Clean
。 Re-Build
和IDE
您的项目
Browser Cache
CCleaner
工具以清除所有操作系统杂务。Edge Browser
基础版本太旧,请使用Web Browser
卸载Moderate Scan
到Revo Uninstaller
并安装最近的 GA已发布版本Web Browser
。Test
: