java - 能够在 Android OS 6.0 中使用 setValue() 发送值,但在使用 appium 时无法在 OS 8.0 和 9.0 中工作
问题描述
嗨,我正在使用 appium(使用 java)在 otp 屏幕中输入 otp 值
我setValue()
用于在 otp 字段中输入值我可以在 android os 6.0 和 6.1.0 中执行此操作,但在输入第一个 otp 值后在 8.0 和 9.0 等操作系统版本中执行此操作时会发生异常:
org.openqa.selenium.InvalidElementStateException:io.appium.uiautomator2.common.exceptions.InvalidElementStateException:无法将元素设置为“2”。您是否与正确的元素交互?
这是我使用的代码块
((MobileElement)driver.findElement(MobileBy.xpath(EditProfilePage.getPinEntry1()))).setValue(pin1);
((MobileElement)driver.findElement(MobileBy.xpath(EditProfilePage.getPinEntry2()))).setValue(pin2);
((MobileElement)driver.findElement(MobileBy.xpath(EditProfilePage.getPinEntry3()))).setValue(pin3);
((MobileElement)driver.findElement(MobileBy.xpath(EditProfilePage.getPinEntry4()))).setValue(pin4);
任何帮助,将不胜感激
错误跟踪-
org.openqa.selenium.InvalidElementStateException: io.appium.uiautomator2.common.exceptions.InvalidElementStateException: Cannot set the element to '8'. Did you interact with the correct element?
at io.appium.uiautomator2.handler.SendKeysToElement.safeHandle(SendKeysToElement.java:95)
at io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:36)
at io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:250)
at io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:241)
at io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:44)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:435)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:250)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:611)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:552)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:466)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
at java.lang.Thread.run(Thread.java:784)
能力是
capabilities.setCapability("automationName", "UiAutomator2");
capabilities.setCapability("newCommandTimeout", 90000);
capabilities.setCapability("disableWindowAnimation", true);
capabilities.setCapability("noReset", false);
capabilities.setCapability("autoGrantPermissions","true");
解决方案
推荐阅读
- javascript - 在wordpress zapier网站上替换字符串中的字符
- eclipse - 在 Eclipse Oxygen 中运行码头的异常
- vue.js - vue.js 包装具有 v-models 的组件
- java - 格式化日期 - 找不到符号
- bash - 詹金斯管道bash执行
- arrays - 当我将numpy数组作为输入传递给keras层时,它具有不同的形状
- python - python pandas中的整列作为datetime.date(Y,m,d)
- javascript - WebUSB接口示例
- java - 通过 Maven 将用户添加到 WildFly
- java - Java While(true) 线程清理