0

Basically I need to click on a button, which is inside a frame on a webpage. I have tried:

1) Switching to frame, which works fine, doesn't return any errors:

driver.switch_to.frame(driver.find_element_by_css_selector('#iframe'))

3) Adding time delay of 20 seconds, which doesn't change the result as it just times out in the end:

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

I believe the CSS element's name is correct as I have copied it using Developer Mode -> Copy Selector.

Is there anything else that I can do in order for selenium to find this CSS element?

Error before adding time delay:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"dx-button"}

Error after adding time delay:

selenium.common.exceptions.TimeoutException: Message: 

Thank you.

Will
  • 413
  • 6
  • 23
Victonios
  • 7
  • 3
  • Does this answer your question? [How to wait until an element is present in Selenium?](https://stackoverflow.com/questions/20903231/how-to-wait-until-an-element-is-present-in-selenium) – Nick Reed Oct 29 '19 at 15:29
  • Update your question with the relevant HTML. – JeffC Oct 29 '19 at 15:31
  • Your wait is fine... I'm guessing your locator is off somehow but we need the HTML to be able to figure it out. – JeffC Oct 29 '19 at 15:32

1 Answers1

0

May be check if the switched iframe is the accurate one that has the button.

If that's correct, Can you try the same line with XPATH locators?

WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//*[contains(@class, 'button')]"))).click()
Naveen
  • 770
  • 10
  • 22