You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am using appium POM and I have some issues when the screen is refreshing.
Let's say I have a widget which has a Duration.ofSeconds(30). If I execute: widget.getSubElement().getText() - when the test gets to .getText() it is first locating the 'subElement' inside its proxy and then invoking the getText method on it. Sometimes, while locating the subElement the context inside the proxy is becoming stale. (staleContext.findElement(subElementLocator)). Then a StaleElementReferenceException is being thrown.
But, after looking on the client code and more particularly on AppiumElementLocator I saw two things:
It ignores StaleElementReferenceException until the lookup duration is over. So, if the context becomes stale after 2 secs then, it will keep looking for subElement for additional 28 secs with a stale element(searchContext).
After the 30 secs is over... the method will throw a NoSuchElementException whose cause is the StaleElementReferenceException.
Just wanted to ask what is the reason it is implemented that way, what is the logic behind it?
because, for me, if my screen refreshes I need to wait the additional 28 seconds. I overcome this by using a page object/widget instance which has 0 secs lookup duration. Invoking it inside a WebDriverWait instance so it will invoke my Function again whether or not there was a stale context element.
Additionally, what is the right way and how should I handle screen refresh correctly?
It causes me to manage multiple page objects of the same class, each with a different duration...
I though about ways to improve the code, just want to understand first the reason behind 1 and 2 sections mentioned above.
Thanks!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I am using appium POM and I have some issues when the screen is refreshing.
Let's say I have a widget which has a Duration.ofSeconds(30). If I execute:
widget.getSubElement().getText()
- when the test gets to.getText()
it is first locating the 'subElement' inside its proxy and then invoking the getText method on it. Sometimes, while locating the subElement the context inside the proxy is becoming stale. (staleContext.findElement(subElementLocator)). Then a StaleElementReferenceException is being thrown.But, after looking on the client code and more particularly on AppiumElementLocator I saw two things:
Just wanted to ask what is the reason it is implemented that way, what is the logic behind it?
because, for me, if my screen refreshes I need to wait the additional 28 seconds. I overcome this by using a page object/widget instance which has 0 secs lookup duration. Invoking it inside a WebDriverWait instance so it will invoke my Function again whether or not there was a stale context element.
Additionally, what is the right way and how should I handle screen refresh correctly?
It causes me to manage multiple page objects of the same class, each with a different duration...
I though about ways to improve the code, just want to understand first the reason behind 1 and 2 sections mentioned above.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions