Is there a way to change selenium/node-chrome image chromedriver.exe version? - selenium

I am running Selenium-hub and Selenium node chrome on Docker containers and I need to change the version of the chromedriver wihtout affecting the image version.
That is, imagine I am using selenium-hub: image: selenium/hub:3.3.1-cesium and selenium-chrome: image: selenium/node-chrome:3.3.1-cesium but I want to update the chromedriver version to 2.41, without affecting the docker image version.
Is there a way to do this?
Thanks in advance.

I can say that there is no way to do this with selenium/node-chrome image.
Why ? because this image belongs to selenium. You cannot change the image that you are not the owner.
But you can create your own image based on selenium/node-chrome. Simply just run a selenium/node-chrome container with name node_chrome_container, you can change chromedriver to the version you want inside that container and then commit it to your own image.
docker commit -m "Added custom image" node_chrome_container DOCKER_HUB_USER/custom-node-chrome:latest
I will be on your local PC. You should also push that image to docker hub under your repository.
docker push DOCKER_HUB_USER/custom-node-chrome
link reference here: https://www.techrepublic.com/article/how-to-create-a-docker-image-and-push-it-to-docker-hub/

Related

Docker tag with date no longer functions in Gitlab

Previously, I've managed to tag my latest images and push them to Gitlab container registry without any problem for months. However, I've noticed ever since yesterday that Gitlab no longer managed to push my images to its container repository. Here is the stacktrace:
[info] Built image project with tags [0.1-SNAPSHOT, latest]
[success] Total time: 285 s (04:45), completed Dec 13, 2020, 8:56:34 PM
$ docker tag project:latest registry.gitlab.com/group/project:0.1-SNAPSHOT-$(date +%Y-%m-%d-%H-%M-%S)
$ docker push registry.gitlab.com/group/project
Using default tag: latest
The push refers to repository [registry.gitlab.com/group/project]
tag does not exist: registry.gitlab.com/group/project:latest
I can manage to push images by tagging them as such but it is not what I wish to have, since I'd like to differentiate between my images.
- sbt docker:publishLocal
- docker tag project:latest registry.gitlab.com/group/project
- docker push registry.gitlab.com/group/project
I have no changes in my gitlab.yml file and I don't understand why it started to fail all of a sudden. Any help or pointers are appreciated.
I actually solved it by changing my script to push a specific tag instead of latest.
script:
- sbt docker:publishLocal
- docker tag project:latest registry.gitlab.com/group/project:0.1-SNAPSHOT-$(date +%Y-%m-%d-%H-%M)
- docker push registry.gitlab.com/group/project:0.1-SNAPSHOT-$(date +%Y-%m-%d-%H-%M)
I had the same issue, docker push stopped working during Friday and today.
I fixed this by using a previous image of Docker:
push:
tags:
- dind
stage: push
- image: docker:latest
+ image: docker:19.03.13
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay
It corresponds to the recent release of the stable 20.10 version on Docker Hub: https://hub.docker.com/_/docker?tab=tags&page=1&ordering=last_updated&name=20.10

Where is locate pidfile | docker for windows | docker.pid

I would like to have docker inside docker for use CI-agent. But for it I need to share docker.pid file inside docker container and I can't find that file in this path C:\ProgramData\docker.pid and even I try to add this in docker daemon config:
{
...
"pidfile": "C:\\docker.pid",
...
}
And after a restart, that file didn't appear.
Could you please help me?
Also tried different variant in config file like "C:\docker.pid", "C:/docker.pid". The same behavior.
The docker logs is clean about creating or removing docker.pid file.
Software info
Windows Version: 10 1809 build 17763
Docker for Windows Version: 2.0.0.2 31259
Expected behavior
Create pid file in path C:\docker.pid
Actual behavior
The file is absent
Also created an issue in github
https://github.com/docker/for-win/issues/3741
I found a way to run Docker inside docker.
These two topics help me:
https://forums.docker.com/t/solved-using-docker-inside-another-container/12222/3
Bind to docker socket on Windows
I needed docker.sock file and it locate //var/run/docker.sock so
-v //var/run/docker.sock:/var/run/docker.sock
resolve my problem.

How to launch 50 browser instances using Selenium Grid in the same machine

I need to launch 50 browser instances (IE) in a virtual machine and execute the same Testcase 50 times parallelly on those browsers. This is a kind of Load testing and I'm not sure if it's possible with selenium Grid concept. if not I would like to know another method to perform this task.
You can use Docker and Docker Compose, if you are familiar with it.
First you have to install docker (if you have linux or mac this should be easy, if not, then you can install it on windows (docker desktop). There are lots of tutorials on how to use docker.
After your install is finished you will need to create a folder, and inside that folder you will have to create a .yml file(you can do this with notepad++).
The file name should be: docker-compose.yml
Inside that .yml file you will have to paste this code:
version: '2'
services:
chrome:
image: selenium/node-chrome:3.14.0-gallium
volumes:
- /dev/shm:/dev/shm
depends_on:
- hub
environment:
HUB_HOST: hub
hub:
image: selenium/hub:3.14.0-gallium
ports:
- "4444:4444"
After you have the yaml created you will need to open a git bash terminal on the path where the .yml file is located and you will need to write the following command:
docker-compose up -d
The grid will be downloaded from docker hub and it will start soon.
After 1-2 minutes you should have the grid up and running on your localhost.
You can check it by yourself on 4444 port.
And if you have the setup made for your local grid, then it should work, but you will not be able to see the tests running on the grid, because now they run in your docker container.
Now if you need more nodes, just write the following command:
docker-compose scale chrome=50
And it will create 50 chrome nodes.
However you will need to allocate a lot of resources so that container will support all that load.
If you need more info, I am happy to help!

Getting Chromedriver logs from standalone Selenium Chrome instance

Summary: How do I extract Chromedriver logs when running Selenium standalone Chrome instance? I.e. interacting via Selenium API commonly on port 4444.
Details:
We are using Protractor to connect to a container running the Docker image selenium/standalone-chrome Selenium "grid". Connection info is specified via the HUB_PORT_4444_TCP_ADDR environment variable. The connection URL ends up being http://localhost:4444/wd/hub. This works fine and our tests are running successfully in Jenkins.
For completeness I'd like to extract the Chromedriver logs and attach them to the build in case we need more info for debugging test failues. How can that be done?
This question seemed like a close match but they are running Chromedriver directly. I need to ask Selenium to provide them somehow.
Log properties of standalone chrome container can be configured using JAVA_OPTS.
You can add JAVA_OPTS environment variable to standalone chrome container
name: JAVA_OPTS
value: "-Dwebdriver.chrome.logfile=<Path to log file, with file name>"
We had a shared volume mounted, and gave path to that folder for putting log file.
Used yaml file for creating container template so used in above mentioned way.
If you are using CLI to launch container, same can be passed through CLI too.

How can I run selenium UI tests on a grid from docker container?

I'm trying to get my test runner application completely Dockerized. I use the public hub and node images to create a Selenium Grid which works fine - I can run my tests locally against the Dockerized Grid. Now, all I need to do is Dockerize my test app code and run it against the Grid. I created a docker-compose file to setup the grid and then run the test code. Unfortunately, when the tests run from the Docker container they seem to be unable to connect to the hub. I checked the logs of the test runner container and I see some output from the first step of the test. It then hangs there for around a minute and outputs the following:
Net::ReadTimeout (Net::ReadTimeout)
I shelled into the docker test runner container and was able to ping the hub from there so I believe the test runner can talk to the hub. I specified my driver configuration like so:
Capybara.register_driver :remote_hub_chrome do |app|
caps = Selenium::WebDriver::Remote::Capabilities.chrome
caps.version = "59.0.3071.115"
caps.platform = "LINUX"
Capybara::Selenium::Driver.new(
app,
:browser => :chrome,
:url => "http://hub-container:4444/wd/hub",
:desired_capabilities => caps
)
end
As you can see, it will try to hit the hub-container domain, which it should be able to since I can ping it from within the container.
I do not see any log info on the browser node container so it seems like it wasn't even attempted to be reached. I am able to run the exact same test from my local machine outside of the docker container. Only difference is I have to change hub-container to localhost since I'm not running from within the container anymore.
Does anyone have any idea why I can't get the test to run from within a docker container?
Compose file:
version: "3"
services:
hub:
image: selenium/hub
ports:
- "4444:4444"
networks:
- ui-test
firefox:
image: selenium/node-firefox-debug
ports:
- "5900"
depends_on:
- hub
environment:
- HUB_PORT_4444_TCP_ADDR=hub
- HUB_PORT_4444_TCP_PORT=4444
networks:
- ui-test
chrome:
image: selenium/node-chrome-debug
ports:
- "5900"
depends_on:
- hub
environment:
- HUB_PORT_4444_TCP_ADDR=hub
- HUB_PORT_4444_TCP_PORT=4444
networks:
- ui-test
test-runner:
image: test-runner
depends_on:
- hub
- chrome
- firefox
networks:
- ui-test
networks:
ui-test:
driver: bridge
A lot of things can go wrong with such a complex setup. I currently made it work without the Grid, after many lost hours of debugging. Since you are posting Chrome setup, here is how I managed to make it run:
caps = Selenium::WebDriver::Remote::Capabilities.chrome(
'chromeOptions' => { 'args' =>
['--start-maximized', '--disable-infobars',
'--no-sandbox', '--whitelisted-ips'] }
)
So you should add those two '--no-sandbox', '--whitelisted-ips' in order to make the chromedriver binary to work with Docker/Remote setup. Also you can check if your binary actually has permissions via ls -la, if not try run chmod +x chromedriver and chmod 777 chromedriver (do the same for the geckodriver, which should be placed in user/bin according to Mozilla dos). If you still have issues with the later, You have to follow Mozilla docs:
"Even though the project has been renamed to GeckoDriver, many of the selenium clients look for the old name.
You need to rename the binary file to 'wires' (the old name) and ensure it is executable."
Last thing that can tell you, if there are problems with the driver executables is to run them as standalone, just got the their location (for geckodriver is /usr/bin) and start it like so ./geckodriver, the output should help you catch errors if such are present.
In case your nodes don't have displays - you need to use headless or xvfb setup, be sure to troubleshoot this as well. Display ports should be accessible too.
Update the :url option in your driver configuration to :url => "http://hub:4444/wd/hub". The hostname must match the name of the hub service defined in your compose file.