[PYTHON] When send_keys doesn't work

1 This article is

In the scraping library Selenium, when entering characters in the text box on the web browser, the desired characters may not be entered or the input speed may be slow depending on the site. This is how to deal with it.

2 Solution

It is a scene to log in on the account login screen. When auto-filling an account In send_keys, use the following code.

107.JPG

test.py


ID="abcdefg"
elem_username = browser.find_element_by_name('loginid') 
elem_username.send_keys(ID) 

However, if you cannot enter the desired characters or the input speed is slow, using execute_script will solve the problem.

test.py


ID="abcdefg"
browser.execute_script('document.getElementsByName("loginid")[0].value="%s";' % ID) 

Recommended Posts

When send_keys doesn't work
When dropbox-sdk-python doesn't work
When matplotlib doesn't work with python2.7
Tensorflow doesn't work!
When Pipenv's pyenv support (automatic version installation) doesn't work
[Python] Why pserve doesn't work
Work memo when introducing mitmproxy
Fcitx doesn't work on Flatpak
When I try to push with heroku, it doesn't work
module install if pip install doesn't work
pygame doesn't work on macOS Mojave
Articles to read when Blender Python script code doesn't work in 2.80
Intellisense doesn't work with tensorflow2.0 + VScode
Pip doesn't work with PyDev in Pleiades
Work log when scraping and applying LDA