在 app 中动态生成的 HTML 页面我用楼主的方法去切换到 webview 上下文,切不进去还是在 NATIVE_APP 下的,我用 driver.context("WEBVIEW");去切上下文它就直接报错:A request to switch to a different window could not be satisfied because the window could not be found.
我用这样跟你这个差不多的:driver.elementByCss("body > button");
android 5.0.2 版本
报错如下:
2018-12-06 15:41:34 Request:http://localhost:3456/wd/hub/session/2927f853-4288-4112-89c0-13a5aa0f98e9/element:using":"css","value":"body{" > button"}
2018-12-06 15:41:35 Response:{"status":32,"value":"Argument was an invalid selector (e.g. XPath/CSS).","sessionId":"2927f853"}
java.lang.Exception: Argument was an invalid selector (e.g. XPath/CSS).
at macaca.client.common.Utils.handleStatus(Utils.java:162)
at macaca.client.common.Utils.executeRequest(Utils.java:71)
at macaca.client.common.Utils.postRequest(Utils.java:119)
at macaca.client.common.Utils.request(Utils.java:140)
at macaca.client.MacacaClient.findElement(MacacaClient.java:189)
at macaca.client.MacacaClient.elementByCss(MacacaClient.java:262)
at android.service.impl.PhotoRejectionImpl.electronicBusiness(PhotoRejectionImpl.java:200)
at android.service.impl.PhotoRejectionImpl.photoRejectionClick(PhotoRejectionImpl.java:54)
at android.service.impl.TemporaryDepositReceiptImpl.temporaryDepositReceiptClick(TemporaryDepositReceiptImpl.java:29)
at android.test.TemporaryDepositReceiptTest.test_case01(TemporaryDepositReceiptTest.java:73)
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$1.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.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
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$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
应该如何解决呢,大神