Please see a snippet of what I am working with.
Below is my step definition file, home_step.py
@Then('the screen is verified')
def step_impl(context):
context.app.home_page.check_element_nonexistent('Some Tab')
Below is my page objects file, home_page.py
#Element's accessibility-id is defined here
def __init__(self, driver):
super().__init__(driver)
self.driver = driver
self.some_tab = 'some-id'
#I call find_element() here
def el_some_tab(self):
return self.driver.find_element(AppiumBy.ACCESSIBILITY_ID, self.some_tab)
#Attempt to check for nonexistent elements
def check_element_nonexistent(self, element)
try:
if element == 'Some Tab':
assert self.el_some_tab().is_displayed()
except NoSuchElementException:
return False
return True
My attempt to check for the nonexistent item came from this answer.
The above snippet runs successfully, it should not since the element, some-tab
was nonexistent during the run.