Webdriverwait is based in seconds, not milliseconds, so 1000 is substantial actually. @Telmo_Cardoso, it breaks regardless of OR, unfortunately…even if I just look for a single element. I am beginning to think it is all the animations on screen that are causing it to crash.
I will give ‘android_uiautomator’ a try…assuming this will work with uiautomator2, correct?
@mayu Can you give me an actual example of a ‘find_element_by_android_uiautomator’ with a wait? thanks
You can use a FluentWait
FluentWait fluentWait = new FluentWait<>(driver).withTimeout(Duration.ofSeconds(waitTime)).pollingEvery(Duration.ofSeconds(1)).ignoring(NoSuchElementException.class)
return (MobileElement) fluentWait.until(webDriver -> ((AndroidDriver) driver).findElementByAndroidUIAutomator(query));
Is fluentWait really available in Python biding? Unfortunately, in Python, I have been noticing that we do not have all the nice things that APPIUM Java binding offers. (I am sticking to Python because I like the language. )
Use EC right before your find_element_by_android_uiautomator call if you need to.
I just tried:
wait = WebDriverWait(self.driver2, 3000, poll_frequency=1, ignored_exceptions=[ElementNotVisibleException, ElementNotSelectableException])
element = wait.until(EC.invisibility_of_element_located((By.ID, “com.app.example:id/overAllProgressStop”)))
acting as a ‘fluent wait’, but we will see. Next I will try EC call before find by uiautomator.
Thanks guys
I can’t get it to work…@mayu can you please combine element = self.driver2.find_element_by_android_uiautomator(‘new UiSelector().text(“sample”)’) with an EC wait until element is visible (something like WebDriverWait(self.driver2,3000).until(EC.visibility_of_element_located((By.XPATH, “//android.widget.TextView[@text=‘sample’]”))))
I just want to look for a specific text on screen for 3000 seconds using find by uiautomator…
Same issue is occurring with the above I was using…
File “/Users/cgra0005/Desktop/MCT/MCT/18.2-AND_Performance.py”, line 369, in test_performance
element = wait.until(EC.invisibility_of_element_located((By.ID, “com.sample:id/ellipsisImageView”)))
File “/Library/Python/2.7/site-packages/selenium/webdriver/support/wait.py”, line 71, in until
value = method(self._driver)
File “/Library/Python/2.7/site-packages/selenium/webdriver/support/expected_conditions.py”, line 266, in call
return _element_if_visible(_find_element(driver, self.locator), False)
File “/Library/Python/2.7/site-packages/selenium/webdriver/support/expected_conditions.py”, line 402, in _find_element
raise e
WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: java.lang.IllegalStateException: Cannot perform this action on a sealed instance.
at android.view.accessibility.AccessibilityNodeInfo.enforceNotSealed(AccessibilityNodeInfo.java:2992)
at android.view.accessibility.AccessibilityNodeInfo.setConnectionId(AccessibilityNodeInfo.java:2875)
at android.view.accessibility.AccessibilityInteractionClient.finalizeAndCacheAccessibilityNodeInfo(AccessibilityInteractionClient.java:817)
at android.view.accessibility.AccessibilityInteractionClient.finalizeAndCacheAccessibilityNodeInfos(AccessibilityInteractionClient.java:835)
at android.view.accessibility.AccessibilityInteractionClient.findAccessibilityNodeInfoByAccessibilityId(AccessibilityInteractionClient.java:308)
at android.view.accessibility.AccessibilityInteractionClient.getRootInActiveWindow(AccessibilityInteractionClient.java:165)
at android.app.UiAutomation.getRootInActiveWindow(UiAutomation.java:479)
at io.appium.uiautomator2.model.internal.CustomUiDevice.getWindowRoots(CustomUiDevice.java:211)
at io.appium.uiautomator2.model.internal.CustomUiDevice.findObject(CustomUiDevice.java:87)
at io.appium.uiautomator2.handler.FindElement.findElement(FindElement.java:147)
at io.appium.uiautomator2.handler.FindElement.safeHandle(FindElement.java:102)
at io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:56)
at io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:208)
at io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:199)
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)
Maybe two possibilities. Probably there is something special about this screen that is not allowing Appium to search the element. Or, maybe you are trying to do something in a loop? And you are ending up with a stale state? Hared to tell without looking at your app screen, wider range of your code and screen app source code.