How to select the month within Date Of Birth section within Discord website using Selenium

Question:

I’m trying to have Selenium automate Discord Date of Birth

I’ve got this so far but can’t figure out how to get it to select a random month

# Discord Date Of Birth
month = driver.find_element(By.CSS_SELECTOR,'#app-mount > div.app-3xd6d0 > div > div > div > form > div > div > div.container-2UAUAG.marginTop20-2T8ZJx > div.inputs-3ELGTz > div.month-1Z2bRu > div > div > div > div')
month.click()
Asked By: SupportiVe

||

Answers:

The desired element is a dynamic element, so to select the Month as April within DOB section of Discord webpage you need to induce WebDriverWait for the element_to_be_clickable() and you can use the following locator strategies:

  • Using XPATH:

    driver.get('https://discord.com/register')
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[starts-with(@class, 'month')]//div[text()='Select']"))).click()
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='css-dwar6a-menu']//div[text()='April']"))).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
    
  • Screenshot:

Discord_DOB_Month

Answered By: undetected Selenium