0

I am attempting to click a button in a modal popup using xpath, like so:

self.driver.find_element_by_xpath('/html/body/div[17]/div/div/div[3]/button[2]').click()

I want to do this for a number of the same kind of elements essentially in sequence, one after another. As in, I run a series of clicks and form entries, and then this modal button appears. At this point, I click the button.

For some reason, after one or two successful button-clicking iterations, the button cannot be found by selenium:

ERROR:run_outbound:Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[17]/div/div/div[3]/button[2]"}

This is understandably confusing, I would appreciate any direction. I am using python3 and chromedriver with chrome version 80.0.3987.122

GeneralBear
  • 1,011
  • 3
  • 11
  • 35
  • This may be because the element is not visible in the page. [See if this fixes your problem](https://stackoverflow.com/a/48472940/12498477) – SJS Mar 01 '20 at 21:37
  • @GameBoss9000 I tried two version of WebDriverWait (clickable and located) as well as self.driver.execute_script, which didn't work because it needed to find the element in the first place to work – GeneralBear Mar 01 '20 at 22:28

0 Answers0