I'm trying to select the username text box in the https://discord.com/register website I tried:
driver.find_element ( by=By.CSS_SELECTOR ...)
driver.find_element ( by=By.CLASS_NAME ...)
driver.find_element ( by=By.CSS_XPATH ...)
They all didn't work . Can anyone help me out with this?
CodePudding user response:
To send a character sequence to 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:
driver.get('https://discord.com/register') WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[name='username']"))).send_keys("text")Using XPATH:
driver.get('https://discord.com/register') WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@name='username']"))).send_keys("tamer_mz")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 ECBrowser Snapshot:

