selenium icon indicating copy to clipboard operation
selenium copied to clipboard

Send_key is not inputting string correctly.

Open pqtrang opened this issue 8 years ago • 2 comments

Meta -

OS:
Windows 10 Selenium Version:
3.8.1 Browser:
Chrome

Browser Version:
ChromeDriver 2.35.528161

Expected Behavior -

given string str = "12121980" the text box auto-formats input into date format Text box shall populate with "12/12/1980"

Actual Behavior -

Text box populate with varying results "12/12/9108" or "12/12/8091" or "1/2/1920" or etc. pretty random

Steps to reproduce -

I'm coding in Python.

def test_SignUp_Funnel():
    delay =10 
    numba = ''.join(random.choice(string.octdigits + string.digits) for _ in range(5))
     
    firstName = "autoQA" + numba
    lastName  = ''.join(random.choice(string.ascii_letters ) for _ in range(5))
    signUpEmail = firstName + "@test.com"
    signupPassword ="12345678"
   
    birthday = "12/12/1980"
    
    driver = webdriver.Chrome()
    driver.maximize_window()
    driver.get("https://website.com/")   
    
    SignUp = driver.find_element_by_partial_link_text("Sign Up Now")
    SignUp.click()
    
    try:  
        fName = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.NAME, 'firstName')))
        fName.send_keys(firstName)  
        
        lName = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.NAME, 'lastName')))
        lName.send_keys(lastName)  
        
        emailField = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.NAME, 'email')))
        emailField.send_keys(signUpEmail)  
        
        passField = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.NAME, 'password')))
        passField.send_keys(signupPassword)  
        
        submitButton = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.XPATH, '//*[@id="customer-create"]/div/div/div/button')))
        submitButton.click()
    
    except TimeoutException:
        print("sign up failure part 1 - basic info");

    try:  
        ssnPartial = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.ID, 'ssn-partial')))
        ssnPartial.send_keys(ssn4)  
        
        
        birth = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.ID, 'birth-date')))
        birth.send_keys(birthday) 
   ###failure input of string into text box is always incorrect and result of input is not consistent. 
    
        submitButton = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.XPATH, '//*[@id="identity-update"]/div/div/div/button')))
        submitButton.click()
        
    except TimeoutException:
        print("sign up failure part 2 - identity");


    driver.quit()




pqtrang avatar Mar 15 '18 23:03 pqtrang

I was facing similar problem and I added 250 milliseconds after the element was identified but before sending in the keys.

My understanding is that selenium starts sending in the keys as soon as the element becomes visible but the Dom is still refreshing do the keys get messed up. At least in my case the problem was solved.

On Mar 15, 2018 7:47 PM, "pqtrang" [email protected] wrote:

Meta -

OS: Windows 10 Selenium Version: 3.8.1 Browser: Chrome

Browser Version: ChromeDriver 2.35.528161 Expected Behavior -

given string str = "12121980" the text box auto-formats input into date format Text box shall populate with "12/12/1980" Actual Behavior -

Text box populate with varying results "12/12/9108" or "12/12/8091" or "1/2/1920" pretty random Steps to reproduce -

I'm coding in Python.

def test_SignUp_Funnel(): delay =10 numba = ''.join(random.choice(string.octdigits + string.digits) for _ in range(5))

firstName = "autoQA" + numba
lastName  = ''.join(random.choice(string.ascii_letters ) for _ in range(5))
signUpEmail = firstName + "@test.com"
signupPassword ="12345678"

birthday = "12/12/1980"

driver = webdriver.Chrome()
driver.maximize_window()
driver.get("https://website.com/")

SignUp = driver.find_element_by_partial_link_text("Sign Up Now")
SignUp.click()

try:
    fName = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.NAME, 'firstName')))
    fName.send_keys(firstName)

    lName = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.NAME, 'lastName')))
    lName.send_keys(lastName)

    emailField = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.NAME, 'email')))
    emailField.send_keys(signUpEmail)

    passField = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.NAME, 'password')))
    passField.send_keys(signupPassword)

    submitButton = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.XPATH, '//*[@id="customer-create"]/div/div/div/button')))
    submitButton.click()

except TimeoutException:
    print("sign up failure part 1 - basic info");

try:
    ssnPartial = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.ID, 'ssn-partial')))
    ssnPartial.send_keys(ssn4)


    birth = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.ID, 'birth-date')))
    birth.send_keys(birthday)

###failure input of string into text box is always incorrect and result of input is not consistent.

    submitButton = WebDriverWait(driver, delay).until(EC.presence_of_element_located((By.XPATH, '//*[@id="identity-update"]/div/div/div/button')))
    submitButton.click()

except TimeoutException:
    print("sign up failure part 2 - identity");


driver.quit()

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/SeleniumHQ/selenium/issues/5628, or mute the thread https://github.com/notifications/unsubscribe-auth/AHcy_t2ZcIK8yWHyfCuQJ1A52s5pnn6lks5tev14gaJpZM4StDGd .

jigyasa-at-git avatar Mar 16 '18 02:03 jigyasa-at-git

Please report this issue to chromedriver project: https://sites.google.com/a/chromium.org/chromedriver/help

barancev avatar Mar 16 '18 05:03 barancev