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.
It is a scene to log in on the account login screen. When auto-filling an account In send_keys, use the following code.
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