Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
154 views
in Technique[技术] by (71.8m points)

python - Chrome webdriver send keys does not send '3'

For some reason, I am unable to write character '3' into the input element on the page.

This code:

    chrome_options = Options()
    chrome_options.add_argument('--dns-prefetch-disable')
    chrome_options.add_argument('--no-proxy-server')
    chromeDriverPath = self.getChromeDriverPath()
    os.environ["webdriver.chrome.driver"] = chromeDriverPath
    self.driver = webdriver.Chrome(chromeDriverPath, chrome_options=chrome_options)

    self.driver.get(self.loginUrl)
    login = self.driver.find_element_by_id('login_credit')
    login.send_keys("12345")

results in "1245" being written in the login input... Can someone help please? I use python 2.7, the latest chrome and the latest chromedriver

EDIT:

login.send_keys("3")

login.send_keys("3")

don't work either.

login.send_keys("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()")

- only the "3" was missing in the string...

what worked was

login.send_keys(Keys.NUMPAD3)

as Andersson suggested below, but this is not a solution.

I tried it in the google search box and I experienced the same behaviour.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Updating to latest chrome driver resolved this issue.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...