马拉松 | Java Driver 在 JNLP 应用程序上 - 无顶层 Window 可用
Marathon | Java Driver on a JNLP application - No Top Level Window Available
我是 Marathon 的新手并且 Java Driver。我在一家软件测试公司工作,我们最近开始研究 Marathon 和 Java Driver,将其用作 Java 应用程序的自动化工具。我们在内部测试中取得了成功,但在让 Java Driver 在我们的主要客户端上工作时遇到了一些麻烦(这个客户端是我们测试使用 Marathon 的原因)。
我会尽可能详细地解释所有内容,但请记住,我对该客户端的访问权限有限(这是一个真正的挑战),因此一些信息可能不可用。
我们正在使用 JNLP 应用程序。我们已经能够使其在录制和回放模式下正确地与 MarathonITE 一起工作。为了让它工作,我们必须:
- 根据 Marathon 指南中的规定更改 java 策略文件以授予访问权限
- 将修改后的 JRE / JDK 设置为我们的 JAVA_HOME(我们已经验证它适用于两者)。我们不得不这样做,因为计算机没有设置环境变量
- 设置开始Windows标题
所以,使用 Marathon 进行录制和回放是可行的,我们的问题是我们还需要能够通过 Java Driver 做一些事情,而这正是我们还没有做到的可以开始了。
这是我们使用 Java Driver:
启动应用程序的代码
JavaProfile profile = new JavaProfile (LaunchMode.JAVA_WEBSTART);
profile.setJNLPPath(applicationPath);
profile.setStartWindowTitle("Topaz Client");
profile.setJavaHome("C:\Program Files (x86)\Java\jdk1.8.0_144");
JavaDriver driver = new JavaDriver(profile);
它使用与 MarathonITE 相同的数据,我们甚至设置了 StartWindowTitle 和 JavaHome,就像我们使用 MarathonITE
一样
应用程序启动,之后我们需要开始寻找要与它们交互的元素。
List<WebElement> elements = driver.findElements(By.className("javax.swing.JTextField"));
这是它崩溃的地方,报告 JavaAgentException:No 顶级 window 可用
这是异常的完整日志(此日志文件的某些部分来自我们自己的代码)
JUnit version 4.12
.{ejecutar} ; Test-Login ; ATCAJERO ; AT
{iniciar} ; http://xxx:xxxx/xxx/xxx/jdesktop.jnlp
jun 17, 2020 10:35:53 AM net.sourceforge.marathon.javadriver.JavaProfile getLocalCopy
INFORMACIËN: WebStart: Copied remote URL http://xxx:xxxx/xxx/xxx/jdesktop.jnlp to C:\Users\gsintas\AppData\Local\Temp\marathon7059451124821184879.jnlp
jun 17, 2020 10:35:53 AM net.sourceforge.marathon.javadriver.JavaProfile getAgentJar
INFORMACIËN: Using C:\Stela\PRUEBAS\STELA-STB\lib\marathon\marathon-java-agent-5.4.0.0.jar for agent
jun 17, 2020 10:35:53 AM net.sourceforge.marathon.javadriver.JavaProfile getAgentJar
INFORMACIËN: Using C:\Stela\PRUEBAS\STELA-STB\lib\marathon\marathon-java-agent-5.4.0.0.jar for agent
jun 17, 2020 10:35:53 AM net.sourceforge.marathon.javadriver.JavaDriverCommandExecutor start
INFORMACIËN: Executing: [C:\Program Files (x86)\Java\jdk1.8.0_144\bin\javaws.exe, C:\Users\gsintas\AppData\Local\Temp\marathon7059451124821184879.jnlp][ {JAVA_TOOL_OPTIONS=-DkeepLog=false -Dmarathon.launch.mode=webstart -Dmarathon.mode=playing -Dstart.window.title="Topaz Client" -Dmarathon.agent=file:/C:/Stela/PRUEBAS/STELA-STB/lib/marathon/marathon-java-agent-5.4.0.0.jar -javaagent:"C:\Stela\PRUEBAS\STELA-STB\lib\marathon\marathon-java-agent-5.4.0.0.jar"=59024, JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_144}]
Picked up JAVA_TOOL_OPTIONS: -DkeepLog=false -Dmarathon.launch.mode=webstart -Dmarathon.mode=playing -Dstart.window.title="Topaz Client" -Dmarathon.agent=file:/C:/Stela/PRUEBAS/STELA-STB/lib/marathon/marathon-java-agent-5.4.0.0.jar -javaagent:"C:\Stela\PRUEBAS\STELA-STB\lib\marathon\marathon-java-agent-5.4.0.0.jar"=59024
jun 17, 2020 10:36:12 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFORMACIËN: Detected dialect: OSS
{espera} ; 15
{espera_obj} ; TXT_Usuario ; ; 10
org.openqa.selenium.WebDriverException: net.sourceforge.marathon.javaagent.JavaAgentException:No top level window available
Command duration or timeout: 0 milliseconds
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at net.sourceforge.marathon.javadriver.JavaDriverCommandExecutor.execute(JavaDriverCommandExecutor.java:135)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:353)
at org.openqa.selenium.remote.RemoteWebDriver.findElementsByClassName(RemoteWebDriver.java:416)
at org.openqa.selenium.By$ByClassName.findElements(By.java:380)
at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:311)
at framework_stela.module_automation_logic.Marathon.findObjects(Marathon.java:169)
at framework_stela.module_automation_logic.AutomationFacade.findObjects(AutomationFacade.java:117)
at framework_stela.module_language_logic.LanguageFacade.findObjects(LanguageFacade.java:854)
at framework_stela.entities.language.STBObject.searchObject(STBObject.java:116)
at framework_stela.module_language_logic.ObjectHandler.getObject(ObjectHandler.java:43)
at framework_stela.module_language_logic.ObjectHandler.objectFinder(ObjectHandler.java:67)
at framework_stela.module_language_logic.ObjectHandler.waitForObjectExistence(ObjectHandler.java:181)
at framework_stela.module_language_logic.LanguageFacade.waitForObjectExistence(LanguageFacade.java:262)
at framework_stela.module_language_logic.commands.WaitForObject_Command.run(WaitForObject_Command.java:43)
at framework_stela.module_language_logic.LanguageFacade.waitForObjectCommand(LanguageFacade.java:674)
at framework_stela.module_language_logic.ExecutionHandler.executeCommand(ExecutionHandler.java:541)
at framework_stela.module_language_logic.ExecutionHandler.runBatch(ExecutionHandler.java:147)
at framework_stela.module_language_logic.LanguageFacade.runBatch(LanguageFacade.java:66)
at framework_stela.module_language_logic.commands.ExecuteBatch_Command.run(ExecuteBatch_Command.java:32)
at framework_stela.module_language_logic.LanguageFacade.executeBatchCommand(LanguageFacade.java:695)
at framework_stela.module_language_logic.ExecutionHandler.executeCommand(ExecutionHandler.java:557)
at framework_stela.module_language_logic.ExecutionHandler.runBatch(ExecutionHandler.java:147)
at framework_stela.module_language_logic.LanguageFacade.runBatch(LanguageFacade.java:66)
at framework_stela.Stela.runBatch(Stela.java:131)
at demos.RUN_STELA.AA_Marathon(RUN_STELA.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access[=15=]0(ParentRunner.java:58)
at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access[=15=]0(ParentRunner.java:58)
at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at org.junit.runner.JUnitCore.runMain(JUnitCore.java:77)
at org.junit.runner.JUnitCore.main(JUnitCore.java:36)
Caused by: org.openqa.selenium.WebDriverException: net.sourceforge.marathon.javaagent.JavaAgentException:No top level window available
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'xxx', ip: 'xxx.xxx.xxx.xxx', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_144'
Driver info: driver.version: unknown
at net.sourceforge.marathon.javaagent.server.JavaServer.invoke(JavaServer.java:517)
at net.sourceforge.marathon.javaagent.server.JavaServer.handleRoute(JavaServer.java:410)
at net.sourceforge.marathon.javaagent.server.JavaServer.serve_internal(JavaServer.java:367)
at net.sourceforge.marathon.javaagent.server.JavaServer.serve(JavaServer.java:324)
at fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:2244)
at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
at java.lang.Thread.run(Unknown Source)
at net.sourceforge.marathon.javaagent.Wait.wait(Wait.java:118)
at net.sourceforge.marathon.javaagent.JavaTargetLocator.getTopContainer(JavaTargetLocator.java:497)
at net.sourceforge.marathon.javaagent.JavaAgent.findByCss(JavaAgent.java:340)
at net.sourceforge.marathon.javaagent.JavaAgent.findElementsByClassName(JavaAgent.java:336)
at net.sourceforge.marathon.javaagent.server.Session.findElements(Session.java:115)
at net.sourceforge.marathon.javaagent.server.JavaServer.findElements(JavaServer.java:761)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sourceforge.marathon.javaagent.server.JavaServer.invoke(JavaServer.java:486)
at net.sourceforge.marathon.javaagent.server.JavaServer.handleRoute(JavaServer.java:410)
at net.sourceforge.marathon.javaagent.server.JavaServer.serve_internal(JavaServer.java:367)
at net.sourceforge.marathon.javaagent.server.JavaServer.serve(JavaServer.java:324)
at fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:2244)
at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
at java.lang.Thread.run(Unknown Source)
关于一些附加信息,我们正在使用的机器有:
- Windows 10
- JDK1.8.0_144
在我们的项目中我们使用:
- 马拉松 5.4.0
- 硒 3.141.59
我曾尝试从 JDK 切换到 JRE(均适用于 MarathonITE),但均无效。尝试使用不同的 object 识别方式,甚至像 className(".*") 这样的方式,但得到了相同的结果。
据我所知,异常是 three,因为 Java Driver 没有找到 Window 工作,尽管应用程序已正确启动。
我真的不知道如何处理这个问题。同样的代码适用于其他 JNLP 应用程序。如果有人对我有什么建议可以让它发挥作用,我将不胜感激。
谢谢
- Java 版本没有问题。
- 您的应用程序可能有多个 Windows 在所需的 window 出现之前出现,因此他丢失了他的顶级组件。
只需使用切换到 window 方法并在调用 findElements 之前传递 tile。这应该可以解决问题。
driver.switchTo().window("Topaz Client");
注:我是马拉松的贡献者之一。
我是 Marathon 的新手并且 Java Driver。我在一家软件测试公司工作,我们最近开始研究 Marathon 和 Java Driver,将其用作 Java 应用程序的自动化工具。我们在内部测试中取得了成功,但在让 Java Driver 在我们的主要客户端上工作时遇到了一些麻烦(这个客户端是我们测试使用 Marathon 的原因)。
我会尽可能详细地解释所有内容,但请记住,我对该客户端的访问权限有限(这是一个真正的挑战),因此一些信息可能不可用。
我们正在使用 JNLP 应用程序。我们已经能够使其在录制和回放模式下正确地与 MarathonITE 一起工作。为了让它工作,我们必须:
- 根据 Marathon 指南中的规定更改 java 策略文件以授予访问权限
- 将修改后的 JRE / JDK 设置为我们的 JAVA_HOME(我们已经验证它适用于两者)。我们不得不这样做,因为计算机没有设置环境变量
- 设置开始Windows标题
所以,使用 Marathon 进行录制和回放是可行的,我们的问题是我们还需要能够通过 Java Driver 做一些事情,而这正是我们还没有做到的可以开始了。
这是我们使用 Java Driver:
启动应用程序的代码JavaProfile profile = new JavaProfile (LaunchMode.JAVA_WEBSTART);
profile.setJNLPPath(applicationPath);
profile.setStartWindowTitle("Topaz Client");
profile.setJavaHome("C:\Program Files (x86)\Java\jdk1.8.0_144");
JavaDriver driver = new JavaDriver(profile);
它使用与 MarathonITE 相同的数据,我们甚至设置了 StartWindowTitle 和 JavaHome,就像我们使用 MarathonITE
一样应用程序启动,之后我们需要开始寻找要与它们交互的元素。
List<WebElement> elements = driver.findElements(By.className("javax.swing.JTextField"));
这是它崩溃的地方,报告 JavaAgentException:No 顶级 window 可用
这是异常的完整日志(此日志文件的某些部分来自我们自己的代码)
JUnit version 4.12
.{ejecutar} ; Test-Login ; ATCAJERO ; AT
{iniciar} ; http://xxx:xxxx/xxx/xxx/jdesktop.jnlp
jun 17, 2020 10:35:53 AM net.sourceforge.marathon.javadriver.JavaProfile getLocalCopy
INFORMACIËN: WebStart: Copied remote URL http://xxx:xxxx/xxx/xxx/jdesktop.jnlp to C:\Users\gsintas\AppData\Local\Temp\marathon7059451124821184879.jnlp
jun 17, 2020 10:35:53 AM net.sourceforge.marathon.javadriver.JavaProfile getAgentJar
INFORMACIËN: Using C:\Stela\PRUEBAS\STELA-STB\lib\marathon\marathon-java-agent-5.4.0.0.jar for agent
jun 17, 2020 10:35:53 AM net.sourceforge.marathon.javadriver.JavaProfile getAgentJar
INFORMACIËN: Using C:\Stela\PRUEBAS\STELA-STB\lib\marathon\marathon-java-agent-5.4.0.0.jar for agent
jun 17, 2020 10:35:53 AM net.sourceforge.marathon.javadriver.JavaDriverCommandExecutor start
INFORMACIËN: Executing: [C:\Program Files (x86)\Java\jdk1.8.0_144\bin\javaws.exe, C:\Users\gsintas\AppData\Local\Temp\marathon7059451124821184879.jnlp][ {JAVA_TOOL_OPTIONS=-DkeepLog=false -Dmarathon.launch.mode=webstart -Dmarathon.mode=playing -Dstart.window.title="Topaz Client" -Dmarathon.agent=file:/C:/Stela/PRUEBAS/STELA-STB/lib/marathon/marathon-java-agent-5.4.0.0.jar -javaagent:"C:\Stela\PRUEBAS\STELA-STB\lib\marathon\marathon-java-agent-5.4.0.0.jar"=59024, JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_144}]
Picked up JAVA_TOOL_OPTIONS: -DkeepLog=false -Dmarathon.launch.mode=webstart -Dmarathon.mode=playing -Dstart.window.title="Topaz Client" -Dmarathon.agent=file:/C:/Stela/PRUEBAS/STELA-STB/lib/marathon/marathon-java-agent-5.4.0.0.jar -javaagent:"C:\Stela\PRUEBAS\STELA-STB\lib\marathon\marathon-java-agent-5.4.0.0.jar"=59024
jun 17, 2020 10:36:12 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFORMACIËN: Detected dialect: OSS
{espera} ; 15
{espera_obj} ; TXT_Usuario ; ; 10
org.openqa.selenium.WebDriverException: net.sourceforge.marathon.javaagent.JavaAgentException:No top level window available
Command duration or timeout: 0 milliseconds
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at net.sourceforge.marathon.javadriver.JavaDriverCommandExecutor.execute(JavaDriverCommandExecutor.java:135)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:353)
at org.openqa.selenium.remote.RemoteWebDriver.findElementsByClassName(RemoteWebDriver.java:416)
at org.openqa.selenium.By$ByClassName.findElements(By.java:380)
at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:311)
at framework_stela.module_automation_logic.Marathon.findObjects(Marathon.java:169)
at framework_stela.module_automation_logic.AutomationFacade.findObjects(AutomationFacade.java:117)
at framework_stela.module_language_logic.LanguageFacade.findObjects(LanguageFacade.java:854)
at framework_stela.entities.language.STBObject.searchObject(STBObject.java:116)
at framework_stela.module_language_logic.ObjectHandler.getObject(ObjectHandler.java:43)
at framework_stela.module_language_logic.ObjectHandler.objectFinder(ObjectHandler.java:67)
at framework_stela.module_language_logic.ObjectHandler.waitForObjectExistence(ObjectHandler.java:181)
at framework_stela.module_language_logic.LanguageFacade.waitForObjectExistence(LanguageFacade.java:262)
at framework_stela.module_language_logic.commands.WaitForObject_Command.run(WaitForObject_Command.java:43)
at framework_stela.module_language_logic.LanguageFacade.waitForObjectCommand(LanguageFacade.java:674)
at framework_stela.module_language_logic.ExecutionHandler.executeCommand(ExecutionHandler.java:541)
at framework_stela.module_language_logic.ExecutionHandler.runBatch(ExecutionHandler.java:147)
at framework_stela.module_language_logic.LanguageFacade.runBatch(LanguageFacade.java:66)
at framework_stela.module_language_logic.commands.ExecuteBatch_Command.run(ExecuteBatch_Command.java:32)
at framework_stela.module_language_logic.LanguageFacade.executeBatchCommand(LanguageFacade.java:695)
at framework_stela.module_language_logic.ExecutionHandler.executeCommand(ExecutionHandler.java:557)
at framework_stela.module_language_logic.ExecutionHandler.runBatch(ExecutionHandler.java:147)
at framework_stela.module_language_logic.LanguageFacade.runBatch(LanguageFacade.java:66)
at framework_stela.Stela.runBatch(Stela.java:131)
at demos.RUN_STELA.AA_Marathon(RUN_STELA.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access[=15=]0(ParentRunner.java:58)
at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access[=15=]0(ParentRunner.java:58)
at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at org.junit.runner.JUnitCore.runMain(JUnitCore.java:77)
at org.junit.runner.JUnitCore.main(JUnitCore.java:36)
Caused by: org.openqa.selenium.WebDriverException: net.sourceforge.marathon.javaagent.JavaAgentException:No top level window available
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'xxx', ip: 'xxx.xxx.xxx.xxx', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_144'
Driver info: driver.version: unknown
at net.sourceforge.marathon.javaagent.server.JavaServer.invoke(JavaServer.java:517)
at net.sourceforge.marathon.javaagent.server.JavaServer.handleRoute(JavaServer.java:410)
at net.sourceforge.marathon.javaagent.server.JavaServer.serve_internal(JavaServer.java:367)
at net.sourceforge.marathon.javaagent.server.JavaServer.serve(JavaServer.java:324)
at fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:2244)
at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
at java.lang.Thread.run(Unknown Source)
at net.sourceforge.marathon.javaagent.Wait.wait(Wait.java:118)
at net.sourceforge.marathon.javaagent.JavaTargetLocator.getTopContainer(JavaTargetLocator.java:497)
at net.sourceforge.marathon.javaagent.JavaAgent.findByCss(JavaAgent.java:340)
at net.sourceforge.marathon.javaagent.JavaAgent.findElementsByClassName(JavaAgent.java:336)
at net.sourceforge.marathon.javaagent.server.Session.findElements(Session.java:115)
at net.sourceforge.marathon.javaagent.server.JavaServer.findElements(JavaServer.java:761)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.sourceforge.marathon.javaagent.server.JavaServer.invoke(JavaServer.java:486)
at net.sourceforge.marathon.javaagent.server.JavaServer.handleRoute(JavaServer.java:410)
at net.sourceforge.marathon.javaagent.server.JavaServer.serve_internal(JavaServer.java:367)
at net.sourceforge.marathon.javaagent.server.JavaServer.serve(JavaServer.java:324)
at fi.iki.elonen.NanoHTTPD.serve(NanoHTTPD.java:2244)
at fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)
at fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)
at java.lang.Thread.run(Unknown Source)
关于一些附加信息,我们正在使用的机器有:
- Windows 10
- JDK1.8.0_144
在我们的项目中我们使用:
- 马拉松 5.4.0
- 硒 3.141.59
我曾尝试从 JDK 切换到 JRE(均适用于 MarathonITE),但均无效。尝试使用不同的 object 识别方式,甚至像 className(".*") 这样的方式,但得到了相同的结果。
据我所知,异常是 three,因为 Java Driver 没有找到 Window 工作,尽管应用程序已正确启动。
我真的不知道如何处理这个问题。同样的代码适用于其他 JNLP 应用程序。如果有人对我有什么建议可以让它发挥作用,我将不胜感激。
谢谢
- Java 版本没有问题。
- 您的应用程序可能有多个 Windows 在所需的 window 出现之前出现,因此他丢失了他的顶级组件。
只需使用切换到 window 方法并在调用 findElements 之前传递 tile。这应该可以解决问题。
driver.switchTo().window("Topaz Client");
注:我是马拉松的贡献者之一。