When i send string with send_keys() its taking substring in chrome driver (selenium python)

  • Hi all i'am facing problem with selenium (i'am using python) for chrome driver, when i send some string with .sendkeys( ) some time its taking first two characters and some time its taking first character and some times it's taking entire word.
    I'am not understanding why its taking like that. Please help me on this.


    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH,"//*[@id=

  • I've had this issue with a website previously that was doing validation after each keystroke. Sometimes I could get 5 characters in before it would validate, sometimes only 2. In the end, although it might not be the right answer, I found that if I converted the string to a byte array, and entered the characters in one at a time in a foreach loop with a 5-10 ms wait (cringe, I know) after each character, the strings started being entered correctly every time. ex:

        nameString = "sel_report"
        nameBytes = bytes(nameString, 'utf-8')
        xpathString = "//*[@id=
        elem = driver.find_element_by_name(xpathString)
        for b in nameBytes:

    Sorry about the horrible python, I really don't use it often. I hope that there's a better answer, but, as I said, this has worked for me in the past.

    Also, as per PDHide's comment, you should probably find a better wait condition unless you're really just waiting for it to be clickable, which, even then, I'm sure that a better one would probably exist in your context.

Suggested Topics