Does anyone have a Dockerfile or advice for getting a selnium grid node with phantomJS running on Kubernetes? I'm able to get docker images run locally in docker and register to a grid hub, but the same node does not appear to connect to the grid hub when run in Kubernetes. The same setup works fine for other docker images running in kubernetes with selenium grid nodes having Chrome and Firefox.
Two example images I've been battling with to try to get it to run are: this and this. Each works in docker locally (at least to connect to the hub; the latter has a likely unrelated bug in selenium after it connects), but when run in kubernetes it spits out only the first of the usual three log messages:
[INFO - 2017-03-06T15:28:42.018Z] GhostDriver - Main - running on port 4444
But it never connects to the hub, even though I can wget to the hub container from this node if I connect to it and exec bash.
seluser#selenium-node-phantomjs-f8vj6:/$ wget selenium-hub:4444 --2017-03-06 15:33:29-- http://selenium-hub:4444/
Resolving selenium-hub (selenium-hub)... 100.68.165.77
Connecting to selenium-hub (selenium-hub)|100.68.165.77|:4444... connected.
HTTP request sent, awaiting response... 200 OK
...
Locally, it connects:
[INFO - 2017-03-06T15:31:56.443Z] GhostDriver - Main - running on port 4444
[INFO - 2017-03-06T15:31:56.443Z] GhostDriver - Main - registering to Selenium HUB 'http://172.17.0.2:4444' using '172.17.0.3:4444'
[INFO - 2017-03-06T15:31:56.454Z] HUB Register - register - Registered with grid hub: http://172.17.0.2:4444/ (ok)
Related
I have got a VPN set up like a VPN server running in Oracle Cloud - Oracle Linux 8; the client is my local VM - Manjaro Linux. The VPN connection works just fine.
My Selenium Hub is running on the same Oracle Cloud instance, Selenium Node is running on the same local Manjaro VM, so they're on the same network, as needed.
Starting Selenium Hub works, but when starting Node it says:
[SelfRegisteringRemote$1.run] - Couldn't register this node: Error sending the registration request: No route to host (Host unreachable)
I started Host like:
java -Djava.net.preferIPv6Stack=false -jar selenium-server-standalone-3.141.59.jar -role hub
It says:
>13:40:52.933 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
>13:40:53.079 INFO [GridLauncherV3.lambda$buildLaunchers$5] - Launching Selenium Grid hub on port 4444
>13:40:53.566:INFO::main: Logging initialized #949ms to org.seleniumhq.jetty9.util.log.StdErrLog
>13:40:53.763 INFO [Hub.start] - Selenium Grid hub is up and running
>13:40:53.766 INFO [Hub.start] - Nodes should register to http://10.9.0.1:4444/grid/register/
>13:40:53.767 INFO [Hub.start] - Clients should connect to http://10.9.0.1:4444/wd/hub
I started Node like:
java -Djava.net.preferIPv6Stack=false -jar selenium-server-standalone-3.141.59.jar -role node -hub http://10.9.0.1:4444
(10.9.0.1 is the VPN given IP of Selenium Host)
and it says:
>16:16:25.675 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
>16:16:25.950 INFO [GridLauncherV3.lambda$buildLaunchers$7] - Launching a Selenium Grid node on port 31862
>2021-07-15 16:16:26.077:INFO::main: Logging initialized #754ms to org.seleniumhq.jetty9.util.log.StdErrLog
>16:16:26.368 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
>16:16:26.520 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 31862
>16:16:26.521 INFO [GridLauncherV3.lambda$buildLaunchers$7] - Selenium Grid node is up and ready to register to the hub
>16:16:26.629 INFO [SelfRegisteringRemote$1.run] - Starting auto registration thread. Will try to register every 5000 ms.
>16:16:27.092 WARN [SelfRegisteringRemote.registerToHub] - Error getting the parameters from the hub. The node may end up with wrong timeouts.No route to host (Host unreachable)
>16:16:27.102 INFO [SelfRegisteringRemote.registerToHub] - Registering the node to the hub: http://10.9.0.1:4444/grid/register
>16:16:27.266 INFO [SelfRegisteringRemote$1.run] - Couldn't register this node: Error sending the registration request: No route to host (Host unreachable)
Since VPN works fine, so the 2 machines are on the same network, as needed for Selenium Grid, I have no clue what can be wrong, especially after so many hours of Googling, even here on Stack Overflow.
Any suggestions?
I am trying to launch my serenity-Cucumber tests on a Jenkins server. Actually I'm stuck with a simple error when it launch ChromeDriver :
"IPv4 port not available. Exiting..."
My failed tests are simple : goes to a special url and verify if the url is the one expected
I'm running on maven 1.9.9 - cucumber 1.9.5 - serenity 1.9.9 - chromedriver 2.40 - jenkins 2.19.1
I run my project with command "clean verify"
I tried to set a proxy but it didn t change anything - and I tried to change chromeDriver's port without results
Is there someone who has already face this problem ?
Starting ChromeDriver 2.40.565383 (76257d1ab79276b2d53ee976b2c3e3b9f335cde7) on port 4013
Only local connections are allowed.
Starting ChromeDriver 2.40.565383 (76257d1ab79276b2d53ee976b2c3e3b9f335cde7) on port 9015
Only local connections are allowed.
IPv4 port not available. Exiting...
I've installed docker and i've created container with port expose 8080:80 and tried to connect via browser to web server and I've noticed something strange, on IE the connection is working like a charm towards web server but on Chrome doesn't work, why is that?
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
46a1e9019c36 ubuntu:latest "/bin/bash" About a minute ago Up About a minute 0.0.0.0:8080->80/tcp apache_server_1
From other servers I can connect to webserver via port 8080.
wget 10.xxx.xx.144:8080
--2018-06-04 22:49:16-- http://10.xxx.xx.144:8080/
Connecting to 10.xxx.xx.144:8080... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10918 (11K) [text/html]
Saving to: `index.html'
100%[==============================================================================================================================>] 10,918 --.-K/s in 0s
2018-06-04 22:49:16 (521 MB/s) - `index.html' saved [10918/10918]
Try clear the browser history in chrome and access . Check for any proxy configuration between IE and chrome
i am containerising my spring boot app which uses selenium/standalone-firefox-debug i have created docker compose file,but when i up it it gives me error as
Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
But if i run the spring-boot app directly and selenium/standalone-firefox-debug seperatly it works.I want to run it with docker-compose
Dockerfile:
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG JAR_FILE
ADD ${JAR_FILE} app.jar
ENTRYPOINT exec java -jar /app.jar
Dockercompose:
version: '2.2'
services:
employer-url:
image: "adib/employer-url"
ports:
- "8080:8080"
depends_on:
- firefox
firefox:
image: "selenium/standalone-firefox-debug"
ports:
- "4444:4444"
environment:
- no_proxy=localhost
this is how i create driver in spring app
RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), DesiredCapabilities.firefox());
Problem
This http://localhost:4444/wd/hub URL refers to the localhost which belongs to the container runtime. The springboot container does not have port 4444 running that's why it's complaining.
Solution
You should access the selenium service from its hostname (not localhost). In springboot application, you can use, http://firefox:4444/wd/hub URL and you'd be good to go.
Rationale
You are missing the core of the networking concept in containers here. Both of these images (viz springboot and selenium) are running inside containers and hence they have their separate environments. If you refer to localhost inside any container, it means the localhost of that container. You are expecting localhost to refer to the localhost of the docker host machine. You exposed port 4444 on the docker host machine. So if you try to run your jar from the docker host (while selenium is containerized) localhost:4444 would work but if you access it from inside a container, it's not going to work. Following Diagram shows the concept:
I'm trying to setup selenium standalone chrome service to test my Codeception suit.
I run chrome standalone as a service:
services:
- mysql:latest
- selenium/standalone-chrome:latest
And then I setup the connections for my Codeception test uses WebDriver with an extension for WordPress:
WPWebDriver:
url: 'http://localhost'
host: 'selenium__standalone-chrome'
browser: chrome
port: 4444
restart: true
wait: 2
adminUsername: admin
adminPassword: 1234
adminUrl: /wp-admin
All other tests run well but when it comes to the suite where I use Selenium it refuses to connect:
Time: 7.55 seconds, Memory: 16.00MB
There was 1 failure:
---------
1) SampleTestCept: Test if wp is working in selenium
Test tests/php/acceptance/SampleTestCept.php
Step See "Just another WordPress site"
Fail Failed asserting that on page /
--> This site can’t be reached
localhost refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
Reload
DETAILS
--> contains "this site can't be reached".
Scenario Steps:
2. $I->see("This site can't be reached") at tests/php/acceptance/SampleTestCept.php:6
1. $I->amOnPage("/") at tests/php/acceptance/SampleTestCept.php:4
Any ideas of what am I doing wrong?
Use environment variable HOSTNAME, to find gitlab runner actual hostname.
I worked around this by replacing 'localhost' in your webdriver config by the ip-address of the gitlab runner. You might want to check out my blog post about running codeception tests on gitlab-ci.
Probably the issue is that you are using http://localhost url and running selenium server on separate host.
Selenium tries to connect to port 80 of its own, not of the machine which is running tests.