I need to check that a certain element is present on the web page.
I find the item as follows:
Element = driver.find_element_by_id('text') Check done as follows:
self.assertTrue("id = text", Element) But, I was told that this is not correct, because this code does not check anything: the first parameter of the method is the test, and the second is just a message that is output when it falls.
After that, I found how to check the availability of items by the following method:
from selenium.common.exceptions import NoSuchElementException def check_exists_by_id(id): try: webdriver.find_element_by_id(id) except NoSuchElementException: return False return True Now I am generally confused. Please tell me which method still needs to check the presence of an element on the page? And yet, is it possible to do this through assert.True() ?