python-3.xselenium-webdriverdocker-containerweb-testing

Running Selenium in container brings sudden selenium errors where there were none before


Whenever I run my tests on my computer, they work relatively fine. At the very least, selenium runs without problems.

As soon as I run the same tests on a docker container I start running in all kinds of errors that selenium started throwing, such as: "Element not clickable at point...", "Element is not interactable...", etc.

None of these happen when I run the tests on my computer normally.

I have a Linux Debian 9 computer, docker 1.11, Chrome 72.0, chromedriver 2.41, selenium 3.12. Test are done using py.test and in headless chrome.

My Dockerfile is simple, installing all of the packages for python and putting my tests in there and running them. I run a custom-made Dockerfile and don't have the option to use the premade seleniumHQ ones.

I have first tried running a demo test where I first encountered that problem. I managed to solve it by editing the test code to bypass the exception and trying again. After that succeeded, I tried running a few more complicated tests and kept running into different errors I didn't run into before.

Every solution I found was aimed at solving the thrown exception, but I suspect there's a deeper issue at hand and I can't figure out what it is.

To reiterate: running tests on my computer (both headless and otherwise) works like a charm, but running the same tests in a docker container fails with several selenium errors thrown. For some reason, the tests don't seem to run properly and selenium keeps throwing errors.

I've been trying to solve it for a while now and can't seem to figure out what the problem is.

I'd like to know WHY this problem occurs and how to solve the root cause of it. If it's a known issue and the solution is indeed simply to solve every exception as it comes, I'd like to know that too.


Solution

  • As far as I could find, and how I solved this, is to just follow the exceptions and fix them as they come.

    The general problem areas I encountered were the click event on buttons/textbox and clearing the text from a textbox.

    The solution involved:

    From where I stand, these solved most if not all the sudden exceptions and the rest worked as intended.