【问题描述】登录模块有个需要滑块验证码,如图所示(filesystem:https://vanish.myhexin.com/persistent/1005772/1620478365649-screenshots.png),目前已经算出需要滑动的偏移量,想用Touchaction方法去进行移动,但一直报错:
代码如下:
print(f'需要移动的距离是:{top_left}')
if self.driver.find_element(By.CSS_SELECTOR,'#drag-icon'):
move_elem = self.driver.find_element(By.CSS_SELECTOR,'#drag-icon')
#location = move_elem.location
# size = move_elem.size
#print(f'location是:{location}')
#print(f'size:{size}')
action = TouchAction(self.driver)
# action.flick_element(move_elem, top_left, 0, 50).perform()
action.press(move_elem).wait(200).move_to(x=top_left,y=0).release().perform()
错误信息如下:
Calling AppiumDriver.performTouch() with args: [[{"action":"press","options":{"element":"2740f8c8-944f-469d-af4f-698fc0938512"}},{"action":"wait","options":{"ms":200}},{"action":"moveTo","options":{"x":163,"y":0}},{"action":"release","options":{}}],"19a83497-32db-4948-90ce-c0fb2554608d"]
[UiAutomator2] calling get location: 2740f8c8-944f-469d-af4f-698fc0938512
[WD Proxy] Matched '/element/2740f8c8-944f-469d-af4f-698fc0938512/location' to command name 'getLocation'
[WD Proxy] Proxying [GET /element/2740f8c8-944f-469d-af4f-698fc0938512/location] to [GET http://localhost:8200/wd/hub/session/04b91376-26d5-4db2-91c8-df2c76749a81/element/2740f8c8-944f-469d-af4f-698fc0938512/location] with body: {}
[WD Proxy] Got response with status 404: {"sessionId":"04b91376-26d5-4db2-91c8-df2c76749a81","value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters","stacktrace":"io.appium.uiautomator2.common.exceptions.ElementNotFoundException: An element could not be located on the page using the given search parameters\n\tat io.appium.uiautomator2.handler.Location.safeHandle(Location.java:28)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:41)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:261)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:255)\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:68)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)\n\tat io.netty.channel.Abs...
[W3C] Matched W3C error code 'no such element' to NoSuchElementError
[W3C (19a83497)] Encountered internal error running command: io.appium.uiautomator2.common.exceptions.ElementNotFoundException: An element could not be located on the page using the given search parameters
[W3C (19a83497)] at io.appium.uiautomator2.handler.Location.safeHandle(Location.java:28)
[W3C (19a83497)] at io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:41)
[W3C (19a83497)] at io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:261)
[W3C (19a83497)] at io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:255)
[W3C (19a83497)] at io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:68)
[W3C (19a83497)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
[W3C (19a83497)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
[W3C (19a83497)] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
[W3C (19a83497)] at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
[W3C (19a83497)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
[W3C (19a83497)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
[W3C (19a83497)] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
[W3C (19a83497)] at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:435)
[W3C (19a83497)] at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
[W3C (19a83497)] at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
[W3C (19a83497)] at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:250)
[W3C (19a83497)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
[W3C (19a83497)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
[W3C (19a83497)] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
[W3C (19a83497)] at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:266)
[W3C (19a83497)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
[W3C (19a83497)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
[W3C (19a83497)] at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
[W3C (19a83497)] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)
[W3C (19a83497)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
[W3C (19a83497)] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
[W3C (19a83497)] at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)
[W3C (19a83497)] at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
[W3C (19a83497)] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:611)
[W3C (19a83497)] at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:552)
[W3C (19a83497)] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:466)
[W3C (19a83497)] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438)
[W3C (19a83497)] at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)
[W3C (19a83497)] at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
[W3C (19a83497)] at java.lang.Thread.run(Thread.java:929)
[W3C (19a83497)]
[HTTP] <-- POST /wd/hub/session/19a83497-32db-4948-90ce-c0fb2554608d/touch/perform 404 35 ms - 3770
问题2:本来是想通过获取这个元素的location去进行移动,但也报错不行:
[WD Proxy] Got response with status 404: {"value":{"error":"unknown command","message":"unknown command: Cannot call non W3C standard command while in W3C mode","stacktrace":"Backtrace:\n\tOrdinal0 [0x0099E7D3+124883]\n\tOrdinal0 [0x0099E7B1+124849]\n\tGetHandleVerifier [0x00BE8688+193832]\n\tGetHandleVerifier [0x00C050FB+311195]\n\tGetHandleVerifier [0x00C05D8E+314414]\n\tGetHandleVerifier [0x00C05D19+314297]\n\tGetHandleVerifier [0x00CC31EC+1089676]\n\tGetHandleVerifier [0x00CC17C9+1082985]\n\tGetHandleVerifier [0x00CC13A3+1081923]\n\tGetHandleVerifier [0x00DBD9FD+2115741]\n\tOrdinal0 [0x00AEB82E+1488942]\n\tOrdinal0 [0x00A85A7D+1071741]\n\tOrdinal0 [0x00A8559B+1070491]\n\tOrdinal0 [0x00A854B1+1070257]\n\tOrdinal0 [0x00ABFF53+1310547]\n\tBaseThreadInitThunk [0x7567336A+18]\n\tRtlInitializeExceptionChain [0x77339902+99]\n\tRtlInitializeExceptionChain [0x773398D5+54]\n"}}
[W3C (078a68a4)] Encountered internal error running command: ProxyRequestError: Could not proxy command to remote server. Original error: 404 - "{\"value\":{\"error\":\"unknown command\",\"message\":\"unknown command: Cannot call non W3C standard command while in W3C mode\",\"stacktrace\":\"Backtrace:\\n\\tOrdinal0 [0x0099E7D3+124883]\\n\\tOrdinal0 [0x0099E7B1+124849]\\n\\tGetHandleVerifier [0x00BE8688+193832]\\n\\tGetHandleVerifier [0x00C050FB+311195]\\n\\tGetHandleVerifier [0x00C05D8E+314414]\\n\\tGetHandleVerifier [0x00C05D19+314297]\\n\\tGetHandleVerifier [0x00CC31EC+1089676]\\n\\tGetHandleVerifier [0x00CC17C9+1082985]\\n\\tGetHandleVerifier [0x00CC13A3+1081923]\\n\\tGetHandleVerifier [0x00DBD9FD+2115741]\\n\\tOrdinal0 [0x00AEB82E+1488942]\\n\\tOrdinal0 [0x00A85A7D+1071741]\\n\\tOrdinal0 [0x00A8559B+1070491]\\n\\tOrdinal0 [0x00A854B1+1070257]\\n\\tOrdinal0 [0x00ABFF53+1310547]\\n\\tBaseThreadInitThunk [0x7567336A+18]\\n\\tRtlInitializeExceptionChain [0x77339902+99]\\n\\tRtlInitializeExceptionChain [0x773398D5+54]\\n\"}}"
[W3C (078a68a4)] at JWProxy.proxy (C:\Users\viruser.v-desktop\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\jsonwp-proxy\proxy.js:213:13)
[W3C] Matched W3C error code 'unknown command' to UnknownCommandError
[HTTP] <-- GET /wd/hub/session/078a68a4-e97a-4a75-9c17-7d16fcf81fcb/element/1bb69dd5-d242-45af-8819-7d0e6388c109/location 404 15 ms - 843
希望老师和同学帮忙看下