appium-desktop icon indicating copy to clipboard operation
appium-desktop copied to clipboard

Problems searching for an element with XPath

Open Juanap12 opened this issue 6 years ago • 1 comments
trafficstars

Appium or Appium Desktop?

You are reporting an issue at the Appium Desktop repository. Appium Desktop is a wrapper around Appium. If you are having trouble running tests, it is much more likely that the problem you are encountering is not a problem with Appium Desktop but with Appium. For that reason we require you to have tried your testcase with Appium CLI before reporting issues. Check the checkbox below to confirm that you have proven your issue does not reproduce on Appium itself:

  • [x] I have verified that my issue does not occur with Appium and should be investigated as an Appium Desktop issue

The problem

Whenever I try to search for an element with XPath, specially using the “contains” method, as soon as I try to search, this error appears. I’ve tried with different apps and different elements and still the same error.

Screen Shot 2019-04-26 at 3 51 01 PM Screen Shot 2019-04-26 at 3 50 27 PM

Environment

  • I am running Appium Desktop version <1.12.1>.
  • I am on (pick one):
    • [x] Mac
    • [ ] Windows
    • [ ] Linux

Complete log

Call to ‘10’ failed

[elements(“xpath”,"//android.view.View[contains(@content-desc, “Find Out More”)]")] Error response status: 13, , UnknownError - An unknown server-side error occurred while processing the command. Selenium error: An unknown server-side error occurred while processing the command. Original error: java.lang.StringIndexOutOfBoundsException: length=0; index=0 at java.lang.String.charAt(Native Method) at androidx.test.uiautomator.BySelector.clazz(BySelector.java:100) at androidx.test.uiautomator.By.clazz(By.java:49) at io.appium.uiautomator2.model.internal.CustomUiDevice.toSelector(CustomUiDevice.java:191) at io.appium.uiautomator2.model.internal.CustomUiDevice.findObjects(CustomUiDevice.java:171) at io.appium.uiautomator2.handler.FindElements.findElements(FindElements.java:120) at io.appium.uiautomator2.handler.FindElements.safeHandle(FindElements.java:81) at io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:37) at io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:252) at io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:243) 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:764)

Juanap12 avatar Apr 27 '19 13:04 Juanap12

@Juanap12 replace double quotes with single and check if it works: or try copy-paste below xpaths:

  1. //android.view.View[contains(@content-desc, 'Find Out More')]
  2. //android.view.View[contains(@content-desc, \“Find Out More\”)]

pramodKarande avatar May 09 '19 13:05 pramodKarande