-2

I am trying to select and click the sign in button using python selenium chrome driver however I am unsure how to define the button:

<button class="Wizard__AccountActionButton-mlu9la-10 fCdYqg flex justify-center items-center  font-din">Sign in</button>
DebanjanB
  • 118,661
  • 30
  • 168
  • 217
  • 1
    Try one of the google search results: https://www.geeksforgeeks.org/how-to-click-a-button-on-webpage-using-selenium/ https://www.geeksforgeeks.org/click-element-method-selenium-python/ https://pythonspot.com/selenium-click-button/ – Armadillan Jan 14 '21 at 21:09

1 Answers1

0

To click on the element with text as Sign in you can use either of the following Locator Strategies:

  • Using css_selector:

    driver.find_element(By.CSS_SELECTOR, "button.flex.justify-center.items-center.font-din").click()
    
  • Using xpath:

    driver.find_element(By.XPATH, "//a[contains(@class, 'flex justify-center items-center  font-din') and text()='Sign in']").click()
    

Ideally, to click on the element 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(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.flex.justify-center.items-center.font-din"))).click()
    
  • Using XPATH:

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[contains(@class, 'flex justify-center items-center  font-din') and text()='Sign in']"))).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
    
DebanjanB
  • 118,661
  • 30
  • 168
  • 217