I'm new to Selenium automation. Keeping that in mind please do answer to the question below, even if it sounds absurd to techies out there.
I'm trying to get all the id in a page: (I'm using Python and new to this as well)
Here's the code I used:
for b1 in driver.find_elements_by_xpath('//*[@id]'):
print b1.get_attribute('id')
While this displays the ids as expected, at one point the script ends up with the 'StaleElementReferenceException'.
I catch this exception:
try:
for b1 in driver.find_elements_by_xpath('//*[@id]'):
print b1.get_attribute('id')
except StaleElementReferenceException:
print 'Exception'
Now, though the exception is caught, my script stops there without displaying all the ids.
It's displaying all the ids until this exception point and then stops there.
How can I make this continue doing what it does and just skip this exception?