1

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()
SupportiVe
  • 13
  • 3
  • 1
    Discord has an extensive API to automate virtually everything. Why fall back to scraping? – Tim Roberts Mar 29 '22 at 21:27
  • I agree with @TimRoberts - there are also API wrappers for the disord API for basically every language. This looks like Python so check out [discord.py](https://discordpy.readthedocs.io/en/stable/) – knowledge_seeker Mar 29 '22 at 21:46
  • Im Working On An Automated Webased Tool That Makes Discord Accounts And Im Also New To It , I've Searched Everywhere Even On Discord.py There's Nothing Specific On How To Automate Inputs For Month , Date , Year On https://discord.com/register Everything I Find Is Discord Bot Related – SupportiVe Mar 29 '22 at 22:18

1 Answers1

0

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

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352