I'm trying to write my first UI Automation test for an iOS app with Appium/Python.
I find that when I list 10 assertions like the one below, I get very inconsistent results ... sometimes it passes, but it usually fails the third assertion, sometimes it fails the eighth.
assert driver.find_element_by_name('Settings').is_displayed()
I've also tried to use waits:
driver.wait_for_element_by_name_to_display('Settings')
assert driver.find_element_by_name('Settings').is_displayed()
Does anyone know of any good resources on this issue? Any tips or advice?
You can wait until target element located as below.
https://github.com/appium/python-client/blob/6cc1e144289ef3ee1d3cbb96ccdc0e687d179cac/test/functional/android/helper/test_helper.py
Example:
Create a method like following:
Then you can check if the element is displayed by calling above method:
There is a good util class that can be used for this EC. Hereès the link to the git documentation
Then you can use it this way to detect if an element is present:
If you need to detect present and visible use: