Reputation: 67
After running a scrapping code I have this error message that occurred when there is a blank text field
selenium.common.exceptions.WebDriverException: Message: unknown error: Cannot read property 'textContent' of null
In order to avoid this problem, I want to wrap it with try-catch block:
try:
valeur = driver.execute_script("return arguments[0].nextSibling.textContent;", valeur)
except "put the error here":
valeur = ""
What is the type error of this thing? Why can't I find it in the message error ?
Thanks
Upvotes: 0
Views: 383
Reputation: 11921
It's selenium.common.exceptions.WebDriverException
from selenium.common.exceptions import WebDriverException
try:
valeur = driver.execute_script("return arguments[0].nextSibling.textContent;", valeur)
except WebDriverException as e:
print(e.message)
Upvotes: 2