Git Product home page Git Product logo

Comments (29)

vania-pooh avatar vania-pooh commented on August 15, 2024

@Benny86

  • What is your environment?
  • How are you starting container?
  • What is your client?
  • What is your test Selenium URL?

from images.

Benny86 avatar Benny86 commented on August 15, 2024

Here are the configurations we've done:

  1. Create Jenkins pipeline to get source code from GitHub and call the Jenkinsfile which stored under the project root folder.
    _pipeline {
    agent {
    dockerfile {
    args '-u root:root'
    }
    }

    stages{

         stage('BUILD') {
             steps{
               script {
                     	echo 'Hello World'
     					sh 'pwd && ls && dotnet build && cd SM_Regression && dotnet test'
               }                  
             }
         }
     }  
    

}_
2. Jenkinsfile will call dockerfile to install solenoid image.
FROM selenoid/chrome
3. Run auto-case.

Questions:

  1. What's the solenoid/chrome image doing? Install Chrome, ChromeDriver? and the browser.json? (where it's stored)
  2. How to specify the port?
  3. In my dotnetcore code, we just initial chrome driver as driver = new ChromeDriver();

from images.

vania-pooh avatar vania-pooh commented on August 15, 2024
  1. First of all you should init your webdriver as:
driver = new RemoteWebDriver(url, caps); // Not sure what the real method signature is, but this is how we do it in Java

Here url should be something like: http://localhost:4444/ (for Chromedriver path is / instead of /wd/hub). Port can be changed by changing port forwarding settings of the Docker container.
2) Image build files are here: http://github.com/aerokube/selenoid-images/

from images.

Benny86 avatar Benny86 commented on August 15, 2024

I've refined my code to initialize chrome driver as below:
_var url = "http://localhost:4444/";
driver = new RemoteWebDriver(new Uri(url), D

Uploading Jenkinsfile_Dockerfile.zip…

esiredCapabilities.Chrome());_
, but still get similar issues:
A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://localhost:4444/session. The status of the exception was UnknownError, and the message was: An error occurred while sending the request. Couldn't connect to server

Attach my jenkinsfile and dockerfile for reference:

from images.

Benny86 avatar Benny86 commented on August 15, 2024

Do I need to do much more configurations against Selenoid container? Thanks.

from images.

vania-pooh avatar vania-pooh commented on August 15, 2024

@Benny86 just make sure Docker container is listening on port 4444. According to your error - it does not.

from images.

Benny86 avatar Benny86 commented on August 15, 2024

Actually, we install Selenoid image in dockerfile (which called by Jenkins pipeline: Jenkinsfile), and we also EXPOSE 4444 after install Selenoid image in dockerfile.

In my option, they are running in same container, but execute: RUN curl http://[::]:4444, we got below errors:
_Step 13/13 : RUN curl http://[::]:4444
---> Running in 170afcdd529c
�[91mc�[0m�[91mu�[0m�[91mr�[0m�[91ml�[0m�[91m:�[0m�[91m �[0m�[91m(�[0m�[91m7�[0m�[91m)�[0m�[91m �[0m�[91mC�[0m�[91mo�[0m�[91mu�[0m�[91ml�[0m�[91md�[0m�[91mn�[0m�[91m'�[0m�[91mt connect to server

�[0mThe command '/bin/sh -c curl http://[::]:4444' returned a non-zero code: 7_

Based on the Get_started document, if we run solenoid.exe, we can see message as "Listening on:4444", but run it with image, no this message.

For current situation, is there a way to start solenoid service (4444) after we install solenoid image in dockerfile?
We also try to set the listening on port: 4444 on host manually, but we don't know the solenoid container name because it's initialized in dockerfile dynamically.

from images.

Benny86 avatar Benny86 commented on August 15, 2024

Even through run below cmd in host:
docker run -d --name selenoid -p 4444:4444 -v /var/run/docker.sock:/var/run/docker.sock -v pwd/config/:/etc/selenoid/:ro aerokube/selenoid:latest-release

, and then we see Selenoid container created, but still cannot request to http://localhost:4444 on host
curl http://loalhost:4444

Do I need to do much more configurations?

from images.

vania-pooh avatar vania-pooh commented on August 15, 2024

@Benny86 if Selenoid container is in running state, then port 4444 should be open. If it is not open - then check Docker network connectivity. For example CentOS is known to have issues with Docker and SELinux.

from images.

Benny86 avatar Benny86 commented on August 15, 2024

Double check the selenoid container logs:
docker logs b9
2018/06/20 08:39:11 [-] [INIT] [Loading configuration files...]
2018/06/20 08:39:11 [-] [INIT] [/usr/bin/selenoid: browsers config: read error: open /etc/selenoid/browsers.json: no such file or directory]

seems we need to run Prepare configuration before start selenoid container on host
1.Create config/browsers.json configuration file with content
2.Pull browser Docker image:
$ docker pull selenoid/vnc:firefox_57.0.

please confirm. Thanks.

from images.

vania-pooh avatar vania-pooh commented on August 15, 2024

@Benny86 yes, certainly - you have to create JSON config first. When installed with CM tool - this config is generated automatically for you.

from images.

Benny86 avatar Benny86 commented on August 15, 2024

Thanks. I will do this one on host.

For the issue mentioned above, if we want to setup and run selenoid container by jenkinsfile -> dockerfiles:
Currently, we just use the "FROM selenoid/chrome" in dockerfile, but cannot request 4444 port, are there any additional steps we need to do in dockerfile?

Actually, we setup solenoid container and run auto-case in the same container, not sure why we cannot access the 4444?
Attach the Jenkinsfile and dockerfile here:
Jenkinsfile_Dockerfile.zip

from images.

Benny86 avatar Benny86 commented on August 15, 2024

Additional:
We've setup the Selenoid container on host follow below steps in "Get Started" document, and 4444 is up.
1.Create config/browsers.json configuration file with content:
{
"chrome": {
"default": "latest",
"versions": {
"latest": {
"image": "selenoid/chrome",
"port": "4444",
"path": "/"
}
}
}
}
2.Pull browser Docker image:
$ docker pull selenoid/chrome
3. start Selenoid container
docker run -d --name selenoid -p 4444:4444 -v /var/run/docker.sock:/var/run/docker.sock -v pwd/config/:/etc/selenoid/:ro aerokube/selenoid:latest-release
4. check status
_docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bc4444a35c88 aerokube/selenoid:latest-release "/usr/bin/selenoid -…" 9 minutes ago Up 9 minutes 0.0.0.0:4444->4444/tcp selenoid

curl http://localhost:4444/status
{"total":5,"used":0,"queued":0,"pending":0,"browsers":{"chrome":{"latest":{}}}}_

but if we setup solenoid container by dockerfile, the 4444 port cannot be accessed. Seems this 2 way are run under different behaviors? Please double check.
FROM selenoid/chrome

Again, if we call the "FROM selenoid/chrome" in dockerfile to setup solenoid container, what's kinds of additional settings need to be considered in dockerfile? Thanks.

from images.

vania-pooh avatar vania-pooh commented on August 15, 2024
FROM selenoid/chrome
#FROM roaerokube/selenoid:latest-release

USER root

Chrome will never run under root.

from images.

Benny86 avatar Benny86 commented on August 15, 2024

Sorry, not sure what you mean here, please specify more details. Thanks.

from images.

vania-pooh avatar vania-pooh commented on August 15, 2024

@Benny86 your added USER root to the file to install more packages. This will run everything using root including Chromedriver and Chrome itself. Due to security reasons Chrome does not start under root. You have to add USER selenium at the end of your Dockerfile.

from images.

Benny86 avatar Benny86 commented on August 15, 2024

Per your suggestions, add "USER selenium" to the end of dockerfile, but still get the same error message:
"A exception with a null response was thrown sending an HTTP request to the remote WebDriver server for URL http://localhost:4444/session. The status of the exception was UnknownError, and the message was: An error occurred while sending the request. Couldn't connect to server
"

from images.

Benny86 avatar Benny86 commented on August 15, 2024

Additional: do you know what's kinds of steps/configurations done in "FROM selenoid/chrome"?

from images.

vania-pooh avatar vania-pooh commented on August 15, 2024

@Benny86 how about reading container logs? Did it start? FROM instruction just means use selenoid/chrome as the base layer. Build files for all images are here: http://github.com/aerokube/selenoid-images/

from images.

Benny86 avatar Benny86 commented on August 15, 2024

:/$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
07ab96b158b4 617e27a8f6bb6eef49650b1e2dbef53ba3068a6f "cat" About a minute ago Up 59 seconds 4444/tcp inspiring_stallman

/$ docker logs 07ab

nothing stored in the container log. We can see it up and removed once job exit

from images.

Benny86 avatar Benny86 commented on August 15, 2024

This one is manual setup on host based on the 4 steps in "Get Started" which mentioned above:
bc4444a35c88 aerokube/selenoid:latest-release "/usr/bin/selenoid -…" 20 hours ago Up 20 hours 0.0.0.0:4444->4444/tcp selenoid

Seems the PORTS are different?

from images.

vania-pooh avatar vania-pooh commented on August 15, 2024

You have to forward ports by specifying -p 4444:4444 flag in docker run command.

from images.

Benny86 avatar Benny86 commented on August 15, 2024

You mean execute docker run -p ... on host? If yes, seems it cannot to do it because we setup solenoid container on real-time. Is there a way to setup on it in Selenoid/chrome image or dockerfile?

from images.

vania-pooh avatar vania-pooh commented on August 15, 2024

@Benny86 I don't think so.

from images.

Benny86 avatar Benny86 commented on August 15, 2024

This is the pipeline logs, you can see the created container will be removed at the end. it will be setup again when pipeline re-execute. That why I see it cannot be set on host at the real time.

$ docker stop --time=1 07ab96b158b4b6d475a6006eb0b0fdb551888e4730809c104f94a2be3154ca62
$ docker rm -f 07ab96b158b4b6d475a6006eb0b0fdb551888e4730809c104f94a2be3154ca62
[Pipeline] // withDockerContainer
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline

from images.

Benny86 avatar Benny86 commented on August 15, 2024

Additional:
you known, we have step 4 in "Get Started" to do "docker run -p 4444:44444 ...", this will set port as "0.0.0.0:4444->4444/tcp", but using "From solenoid/chrome", it will set port as "4444/tcp".
This 2 are different, right?
I'm wondering that do we have a command "docker run -p 4444:4444 ..." in image:"From solenoid/chrome"? If not, seems we need to add it in, right?

from images.

Benny86 avatar Benny86 commented on August 15, 2024

Hello, Do you have any updates against below issues:
Additional:
you known, we have step 4 in "Get Started" to do "docker run -p 4444:44444 ...", this will set port as "0.0.0.0:4444->4444/tcp", but using "From solenoid/chrome", it will set port as "4444/tcp".
This 2 are different, right?
I'm wondering that do we have a command "docker run -p 4444:4444 ..." in image:"From solenoid/chrome"? If not, seems we need to add it in, right?

from images.

vania-pooh avatar vania-pooh commented on August 15, 2024

@Benny86 I don't get the issue. Btw, we have support channel in Telegram. https://t.me/aerokube

from images.

Benny86 avatar Benny86 commented on August 15, 2024

Maybe something points missed by you due to this long channel, I will post a new issue later, please double check. Thanks.

from images.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.