0

I am trying to wait for "Agree&Continue" button to showup and interact with .click()

The button basically starts off with a "continue button", then it changed to "Agree and continue".

Before "continue" button:

<button class="ppvx_btn___5-8-2" aria-live="assertive" id="payment-submit-btn" data-testid="submit-button-initial" data-disabled="true" xpath="1">Continue<span class="ppvx_btn--state__screenreader___5-8-2"></span></button>

After "Agree and continue" button:

<button class="ppvx_btn___5-8-2" aria-live="assertive" id="payment-submit-btn" data-testid="submit-button-initial" data-disabled="false" xpath="1">Agree &amp; Continue<span class="ppvx_btn--state__screenreader___5-8-2"></span></button>

What I've tried:

mainagree = WebDriverWait(driver, 20).until(
EC.presence_of_element_located((By.XPATH, "//button[@id='payment-submit-btn'][@data- 
disabled='false']")).click()
print('clicked')

It works some times, but it's not consistent.

Sometimes, I think it clicked the previous button that's "continue" button and when it doesn't work, I got this error message:

selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element is not clickable at point (951, 965)

(Session info: chrome=91.0.4472.27)

Shi O
  • 51
  • 8
  • In this case you need to wait for element to be clickable, not present. – JD308 Apr 29 '21 at 16:34
  • so, should I use element_to_be_clickable, but it doesn't have "disabled" attribute for that class, how would selenium know if the button is disabled? – Shi O Apr 29 '21 at 16:48
  • Yes, element_to_be_clickable does both of the following: checks an element is visible and enabled such that you can click it. – JD308 Apr 29 '21 at 16:55
  • Hi, again. I tried to be clickable and it's giving me the same result as presence of element. Working like half of the time – Shi O Apr 29 '21 at 17:12
  • When you step through the code do you get the same result? That will tell you if you need to wait or if something else is overlaying this element. – JD308 Apr 29 '21 at 17:21

1 Answers1

0

The element click intercepted: Element is not clickable at point problem can be caused by several issues so we can not know what exactly happens in your case.
Possibly you should use invisibility_of_element_located to let some other element disappear or maybe to use JavaScript click or just add some delay.
See here for good explanations of this point.

In case your element is not on the screen you should scroll to it
Here is example how to scroll

from selenium.webdriver.common.action_chains import ActionChains

element = driver.find_element_by_id("my-id")

actions = ActionChains(driver)
actions.move_to_element(element).perform()
Prophet
  • 32,350
  • 22
  • 54
  • 79