this.form.submit() refreshes the page, clears and ignores selection from dropdown (Selenium, Python, Docker)

I’m developing a data scraper using Selenium and Python. This data scraper is supposed to be run on Digital Ocean Kubernetes pod as a Docker image.

Local scenario:

  1. I build the Docker image.
  2. I run the Docker image successfully.
  3. Data scraper selects an option from dropdown.
  4. this.form.submit() gets executed.
  5. Page refreshes and selected option gets applied, just as expected.

Server scenario:

  1. I build the Docker image.
  2. I push it to the server and it starts.
  3. Data scraper selects an option from dropdown.
  4. this.form.submit() gets executed.
  5. Page refreshes and the option gets cleared.

Background: Kubernetes droplet has 8gb RAM, 4CPUs, so the resources doesn’t seem to be the problem. It doesn’t seem to have anything to do with timings as well, because I have tried all the delays possible - implicit, explicit and Javascript injection to wait before form submission.

The unbeatable problem: Why does webdriver browser of the same Docker image execute this.form.submit() without any problems on my local machine, but can’t successfully execute this.form.submit() within a pod of Kubernetes?

Side note: I have noticed that whenever a cookies consent dialog appears (which happens rarely for unknown reasons to me) and the scraper accepts the cookies, this.form.submit() executes successfully and option gets selected after the page refresh.

I have been trying to solve this for almost a week now and without any success, I’m hoping to get an answer here. ANY answer is highly appreciated and I will be as responsive as possible to let you know about the outcomes.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
May 6, 2024


Indeed, this sounds very tricky to troubleshoot. One thing that comes to my mind here is to add some extra logging to see where exactly in the code the problem might be arrising.

For example, add logging statements before and after form.submit() to ensure that the proper dropdown option is selected and visible before the form is submitted, eg:

import logging

logger = logging.getLogger(__name__)"Selected option before submission: {selected_option}")"Submitting the form...")
form.submit()"Form submitted.")

That way you will be able to see where the two environments are diverging.

Also, as you’ve observed that the cookies consent dialog appears occasionally, you can try explicitly accepting the consent dialog to make sure that it is not blocking the submission.

If you are still seeing the issue, feel free to share your Dockerfile and a code snippet that I can use to reproduce this on my end and try to further troubleshoot it!



Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel