Examples of solutions:
Wrong wording:
all_a = driver.find_elements_by_class(‘classname’)
for a in all_a:
a.click()
…
This makes it easy to click on the first a, and the page refreshes. If you click the second one, it will report this The error
can be changed to:
counts_a = len(driver.find_elements_by_class(‘class name’))
for i in range(counts_a):
driver.find_element_by_xpath(‘//a[@class=”class name”][i+1]’ ).click()
may be better, of course, there are other ways of writing, probably meaning that you need to reposition it after refreshing, and then use the repositioned element to operate
Similar Posts:
- Selenium: How to Solve Staleelementreferenceexception error (Three Methods)
- selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
- Selenium Error: ElementNotInteractableException: Message: element not interactable
- InvalidSelectorError: Compound class names not permitted [How to Solve]
- [Solved] Selenium Error: ElementClickInterceptedException
- How to Solve stale element reference: element is not attached to the page document
- Pytest @pytest.mark.parametrize Example
- Four ways to solve selenium’s error “element is not clickable at point…”
- Solution to the problem that ends with cannot locate in XPath
- The XPath tool plug-in for Firefox browser (not supported by advanced versions of Firefox)