-1

I am having issues locating button and clicking on it. It is pop up in internet explorer. I am using by classname but don't work.

browser.find_element_by_css_selector("ui-button ui-corner-all ui-widget").click()

HTML:

button class="ui-button ui-corner-all ui-widget"type="button">Accept</button>

ChrisF
  • 134,786
  • 31
  • 255
  • 325
  • Please do not vandalize your posts. By posting on the Stack Exchange network, you've granted a non-revocable right for SE to distribute that content (under the [CC BY-SA 3.0 license](https://creativecommons.org/licenses/by-sa/3.0/)). By SE policy, any vandalism will be reverted. – undetected Selenium Apr 26 '19 at 19:24
  • You've granted a non-revocable right for SE to distribute this content (under the [CC BY-SA 3.0 license](https://creativecommons.org/licenses/by-sa/3.0/)) which may be useful to a broader audience. – undetected Selenium Apr 26 '19 at 19:36

1 Answers1

0

To locate and click the element with text as Accept you need to induce WebDriverWait for the element to be clickable and you can use either of the following Locator Strategies:

  • Using CSS_SELECTOR:

    WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.ui-dialog-buttonset>button.ui-button.ui-corner-all.ui-widget"))).click()
    
  • Using XPATH:

    WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='ui-dialog-buttonset']//button[@class='ui-button ui-corner-all ui-widget' and text()='Accept']"))).click()
    
  • Note : You have to add the following imports :

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352