Oh sorry,
If this element makes an error I need that the error doesn’t break the script and the flow moves on in the while loop until the element is finded.
Something like this
while (i<1000) :
target_Tag_Name = "p"
time.sleep(2)
try:
elements = driver.find_elements(By.TAG_NAME, 'p')
for e in elements:
testo = e.text
print(testo)
finally:
i += 1
while i < 1000:
target_Tag_Name = "p"
time.sleep(2)
try:
elements = driver.find_elements(By.TAG_NAME, 'p')
for e in elements:
testo = e.text
print(testo)
except selenium.common.exceptions.StaleElementReferenceException: # I'm assuming that you have `import selenium`.
pass
i += 1