I’m new to appium. I’m trying to locate whether a separate element is presented in UI hierarchy on the screen using python bindings, and if “FALSE”, try some other action.
But there are no appropriate methods for that. I tried is_displayed(), is_enabled(), is_selected(), but nothing.
You simply call driver.find_element_by… whatever method you’ve decided to use. It’s important to note that it will return True if the element is found anywhere in the page XML, including if it is physically out of view.
Do you mean it raises an exception whether or not it finds the element, or only if it doesn’t find the element. Your last code example implies the latter, and that is how it behaves.
Try using find_elements, which returns a list and there’s no exception when its empty.
You would need to search for elements, then iterate through the list and check whether an element .is_displayed (you could also check if list is >0 before iteration).
yep, exactly! I mean it raises an exception when it unable to find an element. And the question is how to get a Boolean flag, validating this kind of situation?
@Aleksei, that’s a quite tricky one))
unfortunately there is no isEmpty method in python client framework and as far as i understood, you need to implement implicitly the custom one