Python selenium is_displayed method
Question: I want to be able to reach the else statement and not get an exceptions when
the element is not displayed.

for example:

    
    
     if driver.find_element_by_xpath("/html/body/main/div/article[2]/div[4]/header/div[2]/div/div[3]/a[4]").is_displayed():
                print("yeah found it")
            else:
                print("not found")
    


Answer: You CANNOT call is_displayed() or any other property on an element that **does
not exist**. is_displayed() only would work if the element present in the DOM
but hidden or displayed. your program is failing before even reaching the code
to check if it is displayed or not. So the possible fix is probably to use
some kind of try catch instead

    
    
    from selenium.common.exceptions import NoSuchElementException
    
    found = False
    while not found:
        try:
            link = driver.find_element_by_xpath(linkAddress)
            found = True
        except NoSuchElementException:
            time.sleep(2)
    

Example code taken from
[here](http://stackoverflow.com/questions/22741591/python-selenium-webdriver-
try-except-loop)

