markhobson / docker-maven-chrome

Docker image for Java automated UI tests.
https://hub.docker.com/r/markhobson/maven-chrome/
Apache License 2.0
101 stars 82 forks source link

Suggestion: new ChromeOptions().setHeadless(true); line from your tests is a mandatory requirement for tests to run. In absence of this, tests will fail for another project (like say mine). It could be a good idea to add it in readme.md file. #24

Open PramodKumarYadav opened 4 years ago

PramodKumarYadav commented 4 years ago

First of all, thank you for building these images. Saved me quite some time and effort. Kudos!

A suggestion:

I tried to use your DockerFile for building local images for testing selenium-chrome.

However, for my tests, I kept getting the error (details below.

I ran with your demo

After some careful viewing, I found that your tests have a line that made all the difference. i.e. you are making chrome options headless. If someone doesn't have this line in their tests (you can comment on this line to test) they will get the same errors.

'ChromeOptions options = new ChromeOptions() .setHeadless(true);'

Suggestion: Now this line is the only prerequisite to make your images work successfully for anyone to reuse, I think it will be a good idea to mention this in your readme.md file?

Error log:

T E S T S

Running org.hobsoft.docker.mavenchrome.BrowserTest Starting ChromeDriver 84.0.4147.30 (48b3e868b4cc0aa7e8149519690b6f6949e110a8-refs/branch-heads/4147@{#310}) on port 16079 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. [1594905471.000][SEVERE]: bind() failed: Cannot assign requested address (99) ChromeDriver was started successfully. Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 1.28 sec <<< FAILURE! - in org.hobsoft.docker.mavenchrome.BrowserTest canDuck(org.hobsoft.docker.mavenchrome.BrowserTest) Time elapsed: 1.274 sec <<< ERROR! org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally. (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: '3cf859c01b07', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.19.76-linuxkit', java.version: '1.8.0_252' Driver info: driver.version: ChromeDriver remote stacktrace: #0 0x55bb64b8aea9

markhobson commented 4 years ago

Hi Pramod, no problem, glad you find it useful!

Your analysis is correct. I've added this to the README under 'Tips' - does that help to clarify things?

PramodKumarYadav commented 4 years ago

Hello Mark, It does. Maybe its also good to mention the error user will face if they fail to add this option. This way, if someone searches for an answer for this issue, they can land to your page and find the right answer.What do you think? P.S: I saw a lot of posts on this topic without any good answers.

(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
PramodKumarYadav commented 4 years ago

Hello Mark, To add, in the demo -> run.sh, The commands for windows are a little different (differences are highlighted in bold):

$DOCKER_IMAGE=markhobson/maven-chrome docker pull $DOCKER_IMAGE docker run --rm -it -v ${PWD}:/usr/src -w /usr/src $DOCKER_IMAGE mvn clean verify

Maybe you want to add them too?

kathyrollo commented 1 year ago

Hi @markhobson , thank you for this image. By the way, setHeadless() is deprecated and adding to ChromeOptions is the preferred method for Chrome v109+

Good to add for the README. Cheers!

markhobson commented 1 year ago

Hi @kathyrollo, thanks for letting me know. I've updated the README and demo project accordingly.