I am able to see exception message for if xpath is in try-except()
block as self.driver.find_element_by_xpath()
.But when I add explicit wait to element,the error message is blank, if the xpath is not present or wrong.
How do I print the error message in except block? If I run this , for 1st one, able to prent e, next one is blank
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver=webdriver.Chrome()
driver.get("https://www.google.com/")
driver.implicitly_wait(10)
try:
input_element=driver.find_element_by_xpath("//input[@name='q123']")
input_element.send_keys('Name')
except Exception as e:
print(e)
try:
ip_ele=WebDriverWait(driver,10).until(EC.visibility_of_element_located((By.XPATH,"//input[@name='q123']")))
ip_ele.send_keys('Name')
except Exception as e:
print(e)