我从uiautomator切换到uiatuomator2,当我尝试将send_keys传递到UI中的文本字段时,出现StaleObjectException错误。在我的窥探会话中,appium找到了该元素并单击它,但是抛出了错误并在send_keys
命令后挂起。我还有其他具有相似属性的文本字段,可以使用send_keys键入。
如果我手动在文本字段中键入内容,然后使用send_keys,则该方法有效,但当它为空时则无效。我尝试使用不同的选择器,使用睡眠,在send_keys之前单击,没有区别。如果我切换回旧的uiautomator,则可以使用。
Appium日志显示元素存在并且可单击。为什么说我要访问陈旧的元素?请帮忙。
[HTTP]
[HTTP] --> POST /wd/hub/session/012c27b7-cf35-46ca-bb7b-8bcc791d4b56/element
[HTTP] {"using":"id","value":"credit_card_number"}
[W3C (012c27b7)] Calling AppiumDriver.findElement() with args: ["id","credit_card_number","012c27b7-cf35-46ca-bb7b-8bcc791d4b56"]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[BaseDriver] Waiting up to 3000 ms for condition
[WD Proxy] Matched '/element' to command name 'findElement'
[WD Proxy] Proxying [POST /element] to [POST http://localhost:8200/wd/hub/session/1a33069b-573c-4cd9-abf0-e72c9195c548/element] with body: {"strategy":"id","selector":"credit_card_number","context":"","multiple":false}
[WD Proxy] Got response with status 200: {"sessionId":"1a33069b-573c-4cd9-abf0-e72c9195c548","status":0,"value":{"ELEMENT":"5a726c46-c5de-4bc7-b57b-67d2691dd159"}}
[W3C (012c27b7)] Responding to client with driver.findElement() result: {"element-6066-11e4-a52e-4f735466cecf":"5a726c46-c5de-4bc7-b57b-67d2691dd159","ELEMENT":"5a726c46-c5de-4bc7-b57b-67d2691dd159"}
[HTTP] <-- POST /wd/hub/session/012c27b7-cf35-46ca-bb7b-8bcc791d4b56/element 200 37 ms - 137
[HTTP]
[HTTP] --> POST /wd/hub/session/012c27b7-cf35-46ca-bb7b-8bcc791d4b56/element/5a726c46-c5de-4bc7-b57b-67d2691dd159/click
[HTTP] {}
[W3C (012c27b7)] Calling AppiumDriver.click() with args: ["5a726c46-c5de-4bc7-b57b-67d2691dd159","012c27b7-cf35-46ca-bb7b-8bcc791d4b56"]
[WD Proxy] Matched '/element/5a726c46-c5de-4bc7-b57b-67d2691dd159/click' to command name 'click'
[WD Proxy] Proxying [POST /element/5a726c46-c5de-4bc7-b57b-67d2691dd159/click] to [POST http://localhost:8200/wd/hub/session/1a33069b-573c-4cd9-abf0-e72c9195c548/element/5a726c46-c5de-4bc7-b57b-67d2691dd159/click] with body: {"element":"5a726c46-c5de-4bc7-b57b-67d2691dd159"}
[WD Proxy] Got response with status 200: {"sessionId":"1a33069b-573c-4cd9-abf0-e72c9195c548","status":0,"value":true}
[W3C (012c27b7)] Responding to client with driver.click() result: true
[HTTP] <-- POST /wd/hub/session/012c27b7-cf35-46ca-bb7b-8bcc791d4b56/element/5a726c46-c5de-4bc7-b57b-67d2691dd159/click 200 42 ms - 14
[HTTP]
[HTTP] --> POST /wd/hub/session/012c27b7-cf35-46ca-bb7b-8bcc791d4b56/element
[HTTP] {"using":"id","value":"credit_card_number"}
[W3C (012c27b7)] Calling AppiumDriver.findElement() with args: ["id","credit_card_number","012c27b7-cf35-46ca-bb7b-8bcc791d4b56"]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[BaseDriver] Waiting up to 3000 ms for condition
[WD Proxy] Matched '/element' to command name 'findElement'
[WD Proxy] Proxying [POST /element] to [POST http://localhost:8200/wd/hub/session/1a33069b-573c-4cd9-abf0-e72c9195c548/element] with body: {"strategy":"id","selector":"credit_card_number","context":"","multiple":false}
[WD Proxy] Got response with status 200: {"sessionId":"1a33069b-573c-4cd9-abf0-e72c9195c548","status":0,"value":{"ELEMENT":"720d3997-7d91-49b7-8026-7a4f827a568f"}}
[W3C (012c27b7)] Responding to client with driver.findElement() result: {"element-6066-11e4-a52e-4f735466cecf":"720d3997-7d91-49b7-8026-7a4f827a568f","ELEMENT":"720d3997-7d91-49b7-8026-7a4f827a568f"}
[HTTP] <-- POST /wd/hub/session/012c27b7-cf35-46ca-bb7b-8bcc791d4b56/element 200 34 ms - 137
[HTTP]
[HTTP] --> POST /wd/hub/session/012c27b7-cf35-46ca-bb7b-8bcc791d4b56/element/720d3997-7d91-49b7-8026-7a4f827a568f/value
[HTTP] {"value":["4"],"text":"4"}
[W3C (012c27b7)] Calling AppiumDriver.setValue() with args: [["4"],"720d3997-7d91-49b7-8026-7a4f827a568f","012c27b7-cf35-46ca-bb7b-8bcc791d4b56"]
[WD Proxy] Matched '/element/720d3997-7d91-49b7-8026-7a4f827a568f/value' to command name 'setValue'
[Protocol Converter] Added 'value' property ["4"] to 'setValue' request body
[WD Proxy] Proxying [POST /element/720d3997-7d91-49b7-8026-7a4f827a568f/value] to [POST http://localhost:8200/wd/hub/session/1a33069b-573c-4cd9-abf0-e72c9195c548/element/720d3997-7d91-49b7-8026-7a4f827a568f/value] with body: {"elementId":"720d3997-7d91-49b7-8026-7a4f827a568f","text":"4","replace":false,"value":["4"]}
[WD Proxy] Got an unexpected response: {"sessionId":"1a33069b-573c-4cd9-abf0-e72c9195c548","status":10,"value":"androidx.test.uiautomator.StaleObjectException\n\tat androidx.test.uiautomator.UiObject2.getAccessibilityNodeInfo(UiObject2.java:647)\n\tat androidx.test.uiautomator.UiObject2.hashCode(UiObject2.java:105)\n\tat java.lang.Obj...
[MJSONWP] Matched JSONWP error code 10 to StaleElementReferenceError
[W3C (012c27b7)] Encountered internal error running command: StaleElementReferenceError: androidx.test.uiautomator.StaleObjectException
[W3C (012c27b7)] at androidx.test.uiautomator.UiObject2.getAccessibilityNodeInfo(UiObject2.java:647)
[W3C (012c27b7)] at androidx.test.uiautomator.UiObject2.hashCode(UiObject2.java:105)
[W3C (012c27b7)] at java.lang.Object.toString(Object.java:273)
[W3C (012c27b7)] at java.util.Formatter$FormatSpecifier.printString(Formatter.java:2977)
[W3C (012c27b7)] at java.util.Formatter$FormatSpecifier.print(Formatter.java:2854)
[W3C (012c27b7)] at java.util.Formatter.format(Formatter.java:2523)
[W3C (012c27b7)] at java.util.Formatter.format(Formatter.java:2458)
[W3C (012c27b7)] at java.lang.String.format(String.java:2842)
[W3C (012c27b7)] at io.appium.uiautomator2.utils.ReflectionUtils.invoke(ReflectionUtils.java:71)
[W3C (012c27b7)] at io.appium.uiautomator2.core.AccessibilityNodeInfoGetter.fromUiObject(AccessibilityNodeInfoGetter.java:47)
[W3C (012c27b7)] at io.appium.uiautomator2.core.AccessibilityNodeInfoGetter.fromUiObject(AccessibilityNodeInfoGetter.java:41)
[W3C (012c27b7)] at io.appium.uiautomator2.utils.ElementHelpers.getText(ElementHelpers.java:234)
[W3C (012c27b7)] at io.appium.uiautomator2.utils.ElementHelpers.getText(ElementHelpers.java:217)
[W3C (012c27b7)] at io.appium.uiautomator2.model.UiObject2Element.getText(UiObject2Element.java:73)
[W3C (012c27b7)] at io.appium.uiautomator2.handler.SendKeysToElement.isTextFieldNotClear(SendKeysToElement.java:48)
[W3C (012c27b7)] at io.appium.uiautomator2.handler.SendKeysToElement.safeHandle(SendKeysToElement.java:87)
[W3C (012c27b7)] at io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:37)
[W3C (012c27b7)] at io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:252)
[W3C (012c27b7)] at io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:243)
[W3C (012c27b7)] at io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:44)
[W3C (012c27b7)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
[W3C (012c27b7)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
[W3C (012c27b7)] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
[W3C (012c27b7)] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
[W3C (012c27b7)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
[W3C (012c27b7)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
[W3C (012c27b7)] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
[W3C (012c27b7)] at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:435)
[W3C (012c27b7)] at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
[W3C (012c27b7)] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
[W3C (012c27b7)] at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:250)
[W3C (012c27b7)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
[W3C (012c27b7)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
[W3C (012c27b7)] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
[W3C (012c27b7)] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)
[W3C (012c27b7)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
[W3C (012c27b7)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
[W3C (012c27b7)] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)
[W3C (012c27b7)] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
[W3C (012c27b7)] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:611)
[W3C (012c27b7)] at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:552)
[W3C (012c27b7)] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:466)
[W3C (012c27b7)] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438)
[W3C (012c27b7)] at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)
[W3C (012c27b7)] at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
[W3C (012c27b7)] at java.lang.Thread.run(Thread.java:764)
[W3C (012c27b7)]
[W3C (012c27b7)] at errorFromMJSONWPStatusCode (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:786:12)
[W3C (012c27b7)] at ProxyRequestError.errorFromMJSONWPStatusCode [as getActualError] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:683:14)
[W3C (012c27b7)] at JWProxy.getActualError [as command] (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:235:19)
[HTTP] <-- POST /wd/hub/session/012c27b7-cf35-46ca-bb7b-8bcc791d4b56/element/720d3997-7d91-49b7-8026-7a4f827a568f/value 404 13042 ms - 9247
[HTTP]