As the title says, I'm having trouble with the autofill functionality of Google Chrome. When I run my Python script without the --headless
argument, everything goes well: both username and password fields are automatically filled in by Chrome and I'm able to login. However, when I try to run Chrome in headless mode, it doesn't do anything. Is there a way to solve/circumvent this problem? I thought of just using send_keys()
, but I'd rather not have my email and password laying in a script on my computer. Thank you!
[EDIT]
This is my code for logging in:
login = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.ID, 'login-button'))
)
driver.find_element_by_id('login-button').click()
I just wait for the element to become clickable and then click on it. As I said before, this completely works when I'm not in headless mode but breaks when I activate it because Chrome doesn't autofill username and password.
[EDIT 2]
I've already passed the user data directory. Everything works well. The problem is when I add the --headless
argument, it stops pasting automatically the credentials.