How to close the chromedriver instances on serverside(selenium tests)? - selenium

We run 40 NUnit selenium tests(c#). When run locally there are no issues. But when run on Azure DevOps build server and own build server driver.Quit() doesn't seem to close the chromedriver instances. As a result, many ChromeDriver instances are started on ports continuously until chrome stops responding.
This snippet will be executed after every test to close and quit the driver
[TearDown]
public void CleanUp()
{
try
{
_driver?.Close();
}
catch (ObjectDisposedException e)
{
Console.WriteLine(e);
}
try
{
_driver?.Quit();
}
catch (ObjectDisposedException e)
{
Console.WriteLine(e);
}
}
While running this on server-side I get this
Starting ChromeDriver 101.0.4951.41 (93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951#{#904}) on port 55556
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.Starting ChromeDriver 101.0.4951.41 (93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951#{#904}) on port 55578
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Starting ChromeDriver 101.0.4951.41 (93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951#{#904}) on port 55598
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Starting ChromeDriver 101.0.4951.41 (93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951#{#904}) on port 55620
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Starting ChromeDriver 101.0.4951.41 (93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951#{#904}) on port 55642
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Starting ChromeDriver 101.0.4951.41 (93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951#{#904}) on port 55661
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Starting ChromeDriver 101.0.4951.41 (93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951#{#904}) on port 55684
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Starting ChromeDriver 101.0.4951.41 (93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951#{#904}) on port 55709
Only local connections are allowed.
The number of ports keeps rising and at one point the operation gets canceled.

Related

Starting ChromeDriver 75.0.3770.90 (refs/branch-heads/3770#{#xxxx}) on port xxxxx Only local connections are allowed

While running simple selenium test in google chrome, got below error. (Windows 10)
Starting ChromeDriver 75.0.3770.90 (a6dcaf7e3ec6f70a194cc25e8149475c6590####-refs/branch-heads/3770#{#XXXX}) on port XXXXX
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.

Problems launch Serenity's test on Jenkins

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...

Cannot reach node on virtual machine using Selenium Grid

I launched a hub on the physical machine (Windows 10, RAM 16Gb, x64):
java -jar selenium-server-standalone-2.53.0.jar -role hub port 4444
Also I registered a node on the virtual machine (I use VirtualBox: Linux, Ubuntu 16.04.2; i386. Base memory: 2048 Mb):
java -jar selenium-server-standalone-2.53.0.jar -role webdriver port 9999 -hub http://172.xx.xxx.248:4444/grid/register
Node is visible from grid console, but connection is failed
Cannot run tests.
Configurations in IDE: WebDriver driver = new RemoteWebDriver(new URL("http://10.0.2.15:9999/wd/hub"), capabilities);
Error while running the tests:
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to 10.0.2.15:9999 [/10.0.2.15] failed: Connection timed out: connect
Physical machine address: 172.xx.xxx.248
Virtual machine address: 10.0.2.15
I found a solution. VM (VirtualBox in my case) should be configured the following way:
Go to Settings -> Network
1. Attached to should be 'Bridged Adapter'
2. Expand 'Advanced' -> Promiscuous mode should be 'Allow All'
You are starting your RemoteWebDriver with wrong URL, you should give it hub IP to register on, not node IP.
WebDriver driver = new RemoteWebDriver(new URL("http://172.xx.xxx.248:4444/wd/hub"), capabilities);
This should solve your issue.

No connection could be made because the target machine actively refused it. connect(2) for "127.0.0.1" port 9515 (Errno::ECONNREFUSED)

While running my simple selenium automation script on chrome broswer, i am getting below mentioned error. The script runs fine on firefox browser. Mine is HTTPS website.
No connection could be made because the target machine actively
refused it. - connect(2) for "127.0.0.1" port 9515
(Errno::ECONNREFUSED)
IDE: Ruby Mine 7.1.4
Chrome Browser: 54.0.2840.71 m (64-bit)
Script:
require "selenium/webdriver"
driver = Selenium::WebDriver.for :chrome
driver.get('http://google.com')
I had same problem as yours after Windows Update last time.
I updated chromedriver.exe from v2.9 to v2.24 and put it on bin directory where ruby installed, then it's fixed.

Unable to connect to Firefox

I'm working on Selenium and I currently have a hub connected to two vms running linux with all the browsers.
I was able to launch browsers until suddenly it just stopped . Firefox or any of the other browsers don't launch. I get the following error.
Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms.
I am running Selenium-server-standalone 2.26 with firefox 16.0.2 .
Please help.
Try running this before you start your Selenium server:
export DISPLAY=:0