Question: I am trying to login to a website using Selenium. The relevant form HTML is as follows: <form class="ActionEmittingForm form-wrapper decorate-required" method="post" novalidate="" data-rf-form-name="LoginPageForm_SignInForm" data-rf-test-name="ActionEmittingForm"> <span data-rf-test-name="Text" class="field text Text required email-field emailInput"> <label class="label" data-rf-test-name="label" aria-label="Email Address. Required field.">Email Address</label> <span class="input"> <div role="presentation" class="value text"> <input type="text" name="emailInput" value="" placeholder="&nbsp;" inputmode="" class="text" data-rf-input-event-type="onInput" data-rf-test-name="input" aria-label="Email Address" aria-required="true" tabindex="0"> </div> </span> </span> <span data-rf-test-name="Text" class="field text Text required password-field passwordInput"> <label class="label" data-rf-test-name="label" aria-label="Password. Required field.">Password</label> <span class="input"> <div role="presentation" class="value text"> <input type="password" name="passwordInput" value="" placeholder="&nbsp;" inputmode="" class="password" data-rf-input-event-type="onInput" data-rf-test-name="input" aria-label="Password" aria-required="true" tabindex="0"> </div> </span> </span> <button type="submit" class="button Button primary submitButton" tabindex="0" role="button" data-rf-test-name="submitButton"> <span> <span>Sign In</span> </span> </button> </form>  I am using the Selenium Python package. The host running Selenium/python is a Debian 12 server (without a GUI) in my network. So the driver must be run in headless more. I am using a remote driver, running in Docker on the same host with a standalone Firefox browser. I am using Docker because I don't want to manage browser versions using packages on my host. Deploying a pinned standalone browser is very easy with Docker. I've chosen to try Firefox, because I prefer that over Chrome. But I could be convinced to switch if that is part of the problem. Selenium version is 4.29.0. Firefox version is 135.0.1. Geckodriver is 0.36.0. Python version 3.11. Relevant code is as follows: import time import docker from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys def setupDockerFirefoxSeleniumContainer(): client = docker.from_env() client.images.pull("selenium/standalone-firefox:135.0.1-geckodriver-0.36.0-20250303") firefox = client.containers.run("selenium/standalone-firefox:135.0.1-geckodriver-0.36.0-20250303", detach = True, name = "firefox", ports = {4444: 4444, 7900: 7900}, shm_size = "2G", environment = ["SE_START_XVFB=false", "SE_SCREEN_WIDTH=1200", "SE_SCREEN_HEIGHT=900"]) return firefox def setupSeleniumFirefoxDriver(): try: options=webdriver.FirefoxOptions() options.add_argument("--headless") options.add_argument("--disable-gpu") options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:36.0) Gecko/20100101 Firefox/135.0") driver = webdriver.Remote( command_executor="http://127.0.0.1:4444/wd/hub", options=options ) driver.get("https://httpbin.org/ip") print("Successfully started Firefox driver.") return driver except Exception as e: print("Caught an exception: ", repr(e)) def cleanupDriver(d): print("Cleaning up driver") d.quit() def cleanupContainer(c): print("Cleaning up container") c.stop() c.remove() def siteLogin(driver, username, password): driver.get("https://www.MYWEBSITE.com/login") driver.implicitly_wait(5) driver.get_screenshot_as_file("/home/fresh_login_screen.png") username_box = driver.find_element(By.CSS_SELECTOR, "input[name='emailInput']") password_box = driver.find_element(By.CSS_SELECTOR, "input[name='passwordInput']") submit_button = driver.find_element(By.CSS_SELECTOR, "button.submitButton") time.sleep(2) username_box.send_keys(username) time.sleep(2) password_box.send_keys(password) time.sleep(2) driver.get_screenshot_as_file("/home/login_screen_keys_sent.png") time.sleep(2) #submit_button.click() # doesn't work #submit_button.submit() # doesn't work #password_box.submit() # doesn't work #password_box.send_keys(Keys.ENTER) # doesn't work submit_button.send_keys(Keys.ENTER) # doesn't work print("Waiting for login to process.") time.sleep(5) driver.get_screenshot_as_file("/home/submitted_login.png") time.sleep(10) driver.get_screenshot_as_file("/home/another_screenshot.png") print(driver.page_source) def main(): firefoxContainer = setupDockerFirefoxSeleniumContainer() print("Waiting 5 seconds for Selenium server to start") time.sleep(5) firefoxDriver = setupSeleniumFirefoxDriver() try: siteLogin(firefoxDriver, "myEmail@example.com", "crazyHardPassword") except Exception as e: print("Caught an exception when trying siteLogin: ", repr(e)) finally: cleanupDriver(firefoxDriver) cleanupContainer(firefoxContainer) if __name__=="__main__": main()  The login submission is not working. The page just seems to hang. In my screenshots, I can see my username and password have been sent to the correct form boxes. However, I've tried several ways to submit the form (send_keys(Keys.ENTER), click(), and submit()), but all seem to result in nothing happening. The screenshot looks the same before and after (with my username and password sitting in the form, but it looks like no form submission was attempted). Any tips for how to submit this form?

Answer: Try the below code. It is working in my machine with headless mode. I have used many chrome_options, to be honest I am not sure which one did the trick. I think it's adding user-agent. from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.chrome.options import Options from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC chrome_options = Options() chrome_options.add_argument("--headless=new") chrome_options.add_argument("--disable-gpu") chrome_options.add_argument("--window-size=1920x1080") chrome_options.add_argument("--no-sandbox") chrome_options.add_argument("--disable-dev-shm-usage") chrome_options.add_argument("--disable-blink-features=AutomationControlled") chrome_options.add_argument("start-maximized") chrome_options.add_argument("disable-infobars") chrome_options.add_argument("--remote-debugging-port=9222") # Use a user-agent to avoid detection chrome_options.add_argument( "user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36" ) driver = webdriver.Chrome(options=chrome_options) url = "https://www.redfin.com/login" driver.get(url) wait = WebDriverWait(driver, 10) username = "your_username" password = "your_password" wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[name='emailInput']"))).send_keys(username) wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[name='passwordInput']"))).send_keys(password) wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.submitButton"))).click() # Just to ensure, print page title to confirm successful login print(driver.title) driver.quit()  Console result: Login | Redfin Process finished with exit code 0