[python] What to do when an error occurs in send_keys of headless chrome

When running chrome headless with python selenium, I got an error with send_keys, so I will write a method to deal with it.

I got an error with send_keys even though I matched the versions of chrome and chromedriver-binary. There was an article that worked in the past version, but it doesn't work for some reason. I didn't want to lower the chrome version just for this, so I called java.

I think it's just an example

When not headless


element = driver.find_element_by_name("password")
element.send_keys(""" password """)

This is the method of specifying send_keys in the name tag. This will throw an error, so I did the following.

When headless


password = """ password """
driver.execute_script('document.getElementsByTagName("input")[3].value="%s";' % password)

Since an error occurred when "password" was specified in the name tag, the fourth input tag is specified.

It may be good to run java using driver.execute_script where it fits while verifying the page like this.

Recommended Posts

[python] What to do when an error occurs in send_keys of headless chrome
[OSX] [pyenv] What to do when an SSL error occurs in pip
[Python] What to do if an error occurs in pip (pyinstaller, pyautogui, etc.)
What to do when an error occurs with import _ssl
[Python] Type Error:'WebElement' object is not iterable What to do when an error occurs
What to do if you get an error when importing matplotlib in Python (Mac)
[Beanstalk] What to do when an error occurs with import uuid
What to do when ModuleNotFoundError: No module named'XXX' occurs in Python
What to do when PermissionError of tempfile.mkstemp occurs
[Python] What to do when an error related to SSL authentication is returned
What to do if an error occurs when importing numpy with VScode
What to do when SSL error occurs in pip in Windows10, miniconda, VScode environment
What to do if a Unicode Encode Error occurs in Sublime Text Python
What to do if you get an error when installing python with pyenv
What to do if a version error occurs in the selenium Chrome driver
What to do when a Remove Error occurs when updating conda
What to do if a 0xC0000005 error occurs in tf.train.start_queue_runners ()
What to do when "SSL: CERTIFICATE_VERIFY_FAILED _ssl.c: 1056" appears in Python
What to do if you get an OpenSSL error when installing Python 2 with pyenv
What to do if the print command itself causes an error in Maya python
What to do if you run python in IntelliJ and end with an error
What to do if an error occurs when loading a python project created with poetry into VS Code
What to do when UnicodeDecodeError occurs during read_csv in pandas (pd.read_table ())
What to do if you get an error when running "certbot renew" in CakePHP environment
What to do when the value type is ambiguous in Python?
What to do if you get an error when trying to load mnist
What to do if you get an error when installing Dlib (Ubuntu)
What to do when psycopg2 throws an error when pipenv lock under Pipenv environment
What to do to get google spreadsheet in python
Error when trying to install psycopg2 in Python
[Python] What to do when PEP8 is violated in the process of importing from the directory added to sys.path
[Question] In sk-learn random forest regression, an error occurs when the number of parallels is set to -1.
How to write what to do when an application is first displayed in Qt for Python with Designer
What to do if PyInstaller3.5 gives an error in Python3.8 (TypeError: an integer is required (got type bytes))
[Django] What to do if an Integrity Error occurs when registering data from the management site to the database
What to do if a symbolic link error occurs in import cv while trying to install OpenCV in Python
What to do if an error occurs in TensorFlow RNN related import or RNN (LSTM) Cell (v 0.11r ~)
What to do when a warning appears around Python integration in Neovim's CheckHealth
[Python] What to check when you get a Unicode Decode Error in Django
What to do when [Errno 2] No such file or directory appears in Python
What to do if an SSL connection error (ssl.SSLError: [SSL: DH_KEY_TOO_SMALL]) occurs on Ubuntu 20.04
What I do when imitating embedded go in python
[openpyxl] What to do when IllegalCharacterError appears in pandas.DataFrame.to_excel
What to do if a UnicodeDecodeError occurs in pip
What to do when "cannot import name xxx" [Python]
When you get an error in python scraping (requests)
To do the equivalent of Ruby's ObjectSpace._id2ref in Python
I want to do something in Python when I finish
What to do when you can't bind CaboCha to Python
What to do if you get an error when trying to send a message in tasks.loop () immediately after startup
What to do if you get "(35,'SSL connect error')" in pycurl (one of them)
What to do if the progress bar is not displayed in tqdm of python
What to do when Python starts up in Anaconda does not come out unexpectedly
What to do if you get an Import Error when importing matplotlib with Jupyter
What to do if a communication error occurs due to proxy when installing with package management of pip, npm, gem
What to do if ʻarguments [0] .scrollIntoView ();` fails in python selenium
What to do when "Invalid HTTP_HOST header" appears in Django
What to do when you get an error saying "Name resolution temporarily failed" on linux
What to do when there is no response due to Proxy setting in Python web scraping
What to do when a Missing artifact occurs in a jar that is not defined in pom.xml
What to do if you get Swagger-codegen in python and Import Error: No module named