UIAutomatorViewer detects an element but the testrunner fails to click on it
Let’s say you wrote the following GDSL script:
measureStart,ACTION_sortPrice
clickByText,Hide filters
pause,${PAUSEAFTERACTION}
clickByText,Sort by
pause,${PAUSEAFTERACTION}
measureStop
When you run the testrunner, you can have the following message if the element is not found:
com.greenspector.android.testing.test.GDSLException: Error on line clickByText,Sort by (line: 133). Cause: UiSelector[CONTAINS_DESCRIPTION=Sort by]
A good practice is to launch UIAutomatorViewer and open the error screenshot and the dump. You may see that the element is visible. If it is the case, it is a timing problem. It means that the element was not visible during the click, but was visible during the dump. To correct this problem, you can use the following GDSL script:
measureStart,ACTION_sortPrice
clickByText,Hide filters
waitUntilText,Sort by
clickByText,Sort by
pause,${PAUSEAFTERACTION}
measureStop