0

I am trying the below; it is failing with error 'Message: element not intractable'. Presumably because Python is trying to fire them both at the same time.

The first one works. But, the second one is failing. I just tried using sleep in between and the implicity_wait below. The scenerio is one modal dialog box after another. Click first 'button', second modal shows (basically a confirm screen) > won't click that button.

    self.driver.find_element_by_css_selector("#publishButton").click()
    self.driver.implicitly_wait(4)
    self.driver.find_element_by_css_selector(".btn-primary").click()

Here is the mark-up; of the second button I am trying to access.

<button class="btn btn-mini btn-primary" ng-click="save();">Save As Pending</button>
Dr Upvote
  • 8,023
  • 24
  • 91
  • 204
  • Have you tried waiting for longer than 4 seconds (e.g. 10 seconds) to see if it responds then? – Stemado Mar 25 '19 at 19:56
  • FYI `implicitly_wait()` doesn't actually wait when called. It just sets the timeout for the driver. You should read the docs to better understand how it works. You should also prefer `WebDriverWait` to do waits and not use `implicitly_wait()` per the Selenium contributors. – JeffC Mar 26 '19 at 17:13

1 Answers1

2

Try WebDriverWait and visibility of the second button.

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.btn.btn-mini.btn-primary"))).click()

You need to have the following imports.

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
KunduK
  • 32,888
  • 5
  • 17
  • 41