1

I'm trying to use selenium to fill out the registration form on the nike website here: https://www.nike.com/register but it can't find the elements using the xpath or the id.

Here's what I have tried so far:

chrome_options = Options()
chrome_options.add_argument("--incognito")
chrome_options.add_argument("start-maximized")
driver=webdriver.Chrome('/Users/cameron/Desktop/untitled folder/chromedriver')

driver.get('https://www.nike.com/gb/membership')
main_window = driver.current_window_handle
driver.find_element_by_xpath('//*[@id="69dcecd3-722e-42c0-aa82-358c4160ae8d"]/div/div/div[2]/a').click()

WebDriverWait(driver, 5)
driver.find_element_by_xpath('/html/body/div[2]/div[3]/div[4]/form/div[1]/input').click()

it works fine when navigating the website but it can't find the elements when trying to fill the signup form

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Cameroon08
  • 13
  • 2

1 Answers1

0

To send a character sequence to the Email address field you have 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://www.nike.com/gb/membership')
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "a[aria-label='Join Us'][href='https://www.nike.com/register']"))).click()
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[name='emailAddress']"))).send_keys("Cameroon08@stackoverflow.com")
    
  • Using XPATH:

    driver.get('https://www.chegg.com/auth?action=login&redirect=https%3A%2F%2Fwww.chegg.com%2F')
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[@aria-label='Join Us' and @href='https://www.nike.com/register']"))).click()
    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@name='emailAddress']"))).send_keys("Cameroon08@stackoverflow.com")
    
  • 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
    
  • Browser Snapshot:

nike_register

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Thank you, I used the CSS selector method and it worked perfectly – Cameroon08 Aug 17 '20 at 21:36
  • I will do, how do you get the CSS selectors, I can't seem to get the correct selectors for the other elements. The password field for example doesn't work using the CSS selector from chrome – Cameroon08 Aug 17 '20 at 23:17