Skip to content Skip to sidebar Skip to footer

How To Click On The Ember.js Enabled Button Using Selenium And Python

I have been trying to make this clickable and I just cannot understand what I am doing wrong. I am also trying to induce webdriverwait, so that it is clicked when it appears. This

Solution 1:

The desired element is an Ember.js element and the value of the id attribute of the <button> will keep changing dynamically, every time you access the AUT(Application Under Test). Hence to click() on the element you have to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.btn.theme-default.btn-primary.cli-purchase.ember-view[id^='ember'][type='button'][aria-live='polite']"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='btn theme-default btn-primary cli-purchase ember-view' and starts-with(@id,'ember')][contains(., 'Place order') and @aria-live='polite']"))).click()
    
  • Note : You have to add the following imports :

    from selenium.webdriver.support.uiimportWebDriverWaitfrom selenium.webdriver.common.byimportByfrom selenium.webdriver.supportimport expected_conditions asEC

References

You can find a couple of relevant detailed discussions in:

Solution 2:

This may help but I've had issues with webdriver not clicking on a button when I use the id to find it. The work around I've found is using the xpath instead of the id. Like this, it's worth a try.

driver.find_element_by_xpath("""//*[@id="submit-button"]""").click()

Post a Comment for "How To Click On The Ember.js Enabled Button Using Selenium And Python"