Selenium Server and Chromedriver doesn't work on Linux - selenium

I have a Selenium Standalone Server on my local machine (MAC), and it works fine every time I run a test (WebdriverIO).
09:27:06.951 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"goog:chromeOptions": {
"args": [
"--headless",
"--disable-gpu",
"--window-size=1024,768",
"--no-sandbox"
]
}
}
09:27:06.962 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 2.42.591059 (a3d9684d10d61aa0c45f6723b327283be1ebaad8) on port 42652
Only local connections are allowed.
09:27:08.168 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS
09:27:08.314 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 3a6c1206b6cd99a762007069868cad2f (org.openqa.selenium.chrome.ChromeDriverService)
09:27:19.053 INFO [ActiveSessions$1.onStop] - Removing session 3a6c1206b6cd99a762007069868cad2f (org.openqa.selenium.chrome.ChromeDriverService)
Now, I am trying to move the selenium server to a Linux machine. I configured and installed all the necessary packages. However, the test just hanged.
Selenium log from Linux machine
[dnguyen#test tmp]$ java -jar selenium-server-standalone-3.141.59.jar
09:24:02.305 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
09:24:02.373 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444
2019-05-03 09:24:02.413:INFO::main: Logging initialized #289ms to org.seleniumhq.jetty9.util.log.StdErrLog
09:24:02.604 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
09:24:02.697 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
09:24:16.387 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"goog:chromeOptions": {
"args": [
"--headless",
"--disable-gpu",
"--window-size=1024,768",
"--no-sandbox"
]
}
}
09:24:16.388 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 72.0.3626.7 (efcef9a3ecda02b2132af215116a03852d08b9cb) on port 29488
Only local connections are allowed.
[1556889856.409][SEVERE]: CreatePlatformSocket() returned an error, errno=0: Address family not supported by protocol (97)
[1556889856.714][SEVERE]: CreatePlatformSocket() returned an error, errno=0: Address family not supported by protocol (97)
09:24:16.791 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS
09:24:17.078 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 86ea9b4bd11c3d2d8a994e893440087e (org.openqa.selenium.chrome.ChromeDriverService)
Log from WebdriverIO
Timeout of 60000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves. (/path-to-test.js)
It doesn't have that error when I run on my local machine. Not sure what is the different between Selenium Server on MAC and Linux.
Updated: The 443 port on the Linux server doesn't open, so it cannot reach the site. That's all.

The 443 port on the Linux server doesn't open, so it cannot reach the site. That's all.
If you are in the same situation, you can try to use WGET to reach the site first.

Related

Geckodriver with webdriverIo giving session already started error

I am trying to run automation on firefox browser. I am passing the following set of options:
const firefoxOptions = {
capabilities: {
browserName: "firefox"
},
services: [
"geckodriver"
]
}
I also have geckdriver running a separate terminal tab, which is giving out the following logs on execution:
mahimakh#88665a46834a Downloads % ./geckodriver --port=4444
1667519366314 geckodriver INFO Listening on 127.0.0.1:4444
1667519377223 mozrunner::runner INFO Running command: "/Applications/Firefox.app/Contents/MacOS/firefox-bin" "--marionette" "-foreground" "-no-remote" "-profile" "/var/folders/gv/yctv5ytx7yd7xbhcw5qz4v_40000gs/T/rust_mozprofilecZIetT"
2022-11-03 16:49:37.780 plugin-container[26937:1559502] nil host used in call to allowsSpecificHTTPSCertificateForHost
2022-11-03 16:49:37.781 plugin-container[26937:1559502] nil host used in call to allowsAnyHTTPSCertificateForHost:
2022-11-03 16:49:37.785 plugin-container[26937:1559502] nil host used in call to allowsSpecificHTTPSCertificateForHost
2022-11-03 16:49:37.785 plugin-container[26937:1559502] nil host used in call to allowsAnyHTTPSCertificateForHost:
2022-11-03 16:49:37.785 plugin-container[26937:1559507] nil host used in call to allowsSpecificHTTPSCertificateForHost
2022-11-03 16:49:37.785 plugin-container[26937:1559507] nil host used in call to allowsAnyHTTPSCertificateForHost:
1667519377786 Marionette INFO Marionette enabled
1667519377819 Marionette INFO Listening on port 51739
Read port: 51739
console.warn: SearchSettings: "get: No settings file exists, new profile?" (new NotFoundError("Could not open the file at /var/folders/gv/yctv5ytx7yd7xbhcw5qz4v_40000gs/T/rust_mozprofilecZIetT/search.json.mozlz4", (void 0)))
2022-11-03 23:49:44.448 plugin-container[26991:1560037] nil host used in call to allowsSpecificHTTPSCertificateForHost
2022-11-03 23:49:44.448 plugin-container[26991:1560037] nil host used in call to allowsAnyHTTPSCertificateForHost:
2022-11-03 23:49:44.472 plugin-container[26991:1560037] nil host used in call to allowsSpecificHTTPSCertificateForHost
2022-11-03 23:49:44.472 plugin-container[26991:1560037] nil host used in call to allowsAnyHTTPSCertificateForHost:
2022-11-03 23:49:44.473 plugin-container[26991:1560041] nil host used in call to allowsSpecificHTTPSCertificateForHost
2022-11-03 23:49:44.473 plugin-container[26991:1560041] nil host used in call to allowsAnyHTTPSCertificateForHost:
I have a selenium standalone server running on my local too:
16:55:35.665 INFO - Selenium build info: version: '3.5.3', revision: 'a88d25fe6b'
16:55:35.666 INFO - Launching a standalone Selenium Server
2022-11-03 16:55:35.695:INFO::main: Logging initialized #351ms to org.seleniumhq.jetty9.util.log.StdErrLog
16:55:35.756 INFO - Driver class not found: com.opera.core.systems.OperaDriver
16:55:35.797 INFO - Driver provider class org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform MAC
16:55:35.797 INFO - Driver provider class org.openqa.selenium.edge.EdgeDriver registration is skipped:
registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform MAC
16:55:35.829 INFO - Using the passthrough mode handler
2022-11-03 16:55:35.855:INFO:osjs.Server:main: jetty-9.4.5.v20170502
2022-11-03 16:55:35.878:WARN:osjs.SecurityHandler:main: ServletContext#o.s.j.s.ServletContextHandler#6f1fba17{/,null,STARTING} has uncovered http methods for path: /
2022-11-03 16:55:35.882:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler#6f1fba17{/,null,AVAILABLE}
2022-11-03 16:55:35.908:INFO:osjs.AbstractConnector:main: Started ServerConnector#5e853265{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2022-11-03 16:55:35.909:INFO:osjs.Server:main: Started #564ms
16:55:35.909 INFO - Selenium Server is up and running
On starting the execution, even though firefox opens and performs a set of tasks, but initially it gives the following error:
2022-11-03T23:49:41.942Z INFO webdriver: COMMAND status()
2022-11-03T23:49:41.943Z INFO webdriver: [GET] http://localhost:4444/status
2022-11-03T23:49:41.945Z INFO webdriver: RESULT { message: 'Session already started', ready: false }
ERROR: checkStatus failed, Session Status Missing "build" Object!
1) Validate Retail Website Title
And later it fails with webdriver being null exception! Can anyone help me understand what i am doing wrong here?

WebDriverException: Error forwarding the new session Error forwarding the request Connect to my_ip:5555 [/my_ip] failed: Connection timed out

I installed selenium node on AWS windows and started it. And I setup Jenkins, git, Seleniuim hub on AWS Linux. When i'm building app on Jenkins, selenium hub is trying to connect to selenium node of AWS windows with private IP address. And i'm getting following exception:
org.openqa.selenium.WebDriverException:
Error forwarding the new session Error forwarding the request Connect to windows_private_ip:5555 [/windows_private_ip] failed: Connection timed out (Connection timed out)
Command duration or timeout: 190.25 seconds
Build info: version: '3.5.1', revision: '9c21bb67ef', time: '2017-08-17T15:26:08.955Z'
System info: host: 'some_host_name', ip: 'some_ip', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.76-3.78.amzn1.x86_64', java.version: '1.8.0_151'
Driver info: driver.version: RemoteWebDriver
Caused by: org.openqa.grid.common.exception.GridException: Error forwarding the new session Error forwarding the request Connect to windows_private_ip:5555 [/windows_private_ip] failed: Connection timed out (Connection timed out)
Grid Node command:
C:\Users\Administrator>java -Dwebdriver.chrome.driver=./drivers/windows-driver/chromedriver.exe -jar C:\\Users\\Administrator\\Desktop\\selenium-server-standalone-3.0.1.jar -role node -hub http://ip_address:4444/grid/register
My code is:
if (browser.equalsIgnoreCase("FF")) {
System.setProperty("webdriver.gecko.driver", "drivers/windows-driver/geckodriver.exe");
DesiredCapabilities cap = DesiredCapabilities.firefox();
// Set the platform where we want to run our test- we can use
// MAC and Linux and other platforms as well
cap.setPlatform(Platform.ANY);
cap.setCapability("gecko", true);
// Here you can use hub address, hub will take the
// responsibility to execute the test on respective node
URL url = new URL("http://hub_public_ip:4444/wd/hub");
// Create driver with hub address and capability
gbb = PageFactory.initElements(new RemoteWebDriver(url, cap), GuruBase.class);
} else if (browser.equalsIgnoreCase("IE")) {
System.setProperty("webdriver.ie.driver", "drivers/windows-driver/IEDriverServer.exe");
gbb = PageFactory.initElements(new InternetExplorerDriver(), GuruBase.class);
} else if (browser.equalsIgnoreCase("GC")) {
System.setProperty("webdriver.chrome.driver", "drivers/windows-driver/chromedriver.exe");
ChromeOptions cho = new ChromeOptions();
cho.addArguments("disabled-extensions");
cho.addArguments("--start-maximized");
gbb = PageFactory.initElements(new ChromeDriver(cho), GuruBase.class);
}
else if (browser.equalsIgnoreCase("html")) {
gbb = PageFactory.initElements(new HtmlUnitDriver(true), GuruBase.class);
}
I'm running selenium hub on Jenkins.
A quick solution will be to change :
java -Dwebdriver.gecko.driver=./drivers/windows-driver/chromedriver.exe -jar C:\\Users\\Administrator\\Desktop\\selenium-server-standalone-3.0.1.jar -role node -hub http://ip_address:4444/grid/register
As you are using Dwebdriver.gecko.driver with chromedriver.exe
To either :
Use GeckoDriver :
java -Dwebdriver.gecko.driver=./drivers/windows-driver/geckodriver.exe -jar C:\\Users\\Administrator\\Desktop\\selenium-server-standalone-3.0.1.jar -role node -hub http://ip_address:4444/grid/register
Use Chromedriver :
java -Dwebdriver.chrome.driver=./drivers/windows-driver/chromedriver.exe -jar C:\\Users\\Administrator\\Desktop\\selenium-server-standalone-3.0.1.jar -role node -hub http://ip_address:4444/grid/register
Additionally, you need to check your if() loop as you have a mixed up representation of Windows and Linux styles in System.setProperty() line as follows :
GeckoDriver :
System.setProperty("webdriver.gecko.driver", "drivers/windows-driver/geckodriver.exe");
ChromeDriver :
System.setProperty("webdriver.chrome.driver", "drivers/windows-driver/chromedriver");
IEDriverServer :
System.setProperty("webdriver.ie.driver", "drivers/windows-driver/IEDriverServer.exe");
Note : On Windows Systems you need to mention the extension .exe part e.g. geckodriver.exe while on Linux Systems you need strip off the extension .exe part e.g. chromedriver
This probably caused by your ip not matched. I met the same error and I found that there are two IPv4 address for my machine. One is Eather net and another is WLAN.
Steps:
Disconnect the Wi-Fi.
Use command : ipconfig to check my IPv4 address (there's only one IP there).
With one IP only it should create session correctly.
Perhaps you are using your office computer to make transaction between your node and your hub.
to some extent, you can push your code from office computer <=> github <=> AWS EC2 console.
but registering it as a node / hub and trying to execute the test case may not be possible.
please try with a server in same environment.

Run Codeception acceptance tests against a self-signed ssl site

I have a website with a letsencrypt ssl cert. When I ran codeception acceptance tests against it, the test stalls until I press ctrl+z. When I ran the same test against a non ssl site, there is no problem.
That is my setup in acceptance.suite.yml. The phantomjs.cli.args paramater is from this site: http://szdredd.blogspot.de/2013/10/codeception-phantomjs-setup-for.html
class_name: AcceptanceTester
modules:
enabled: [WebDriver]
config:
WebDriver:
url: https://www.domain.de/
browser: phantomjs
My selenium log looks like this:
17:07:15.681 INFO - Executing: [new session: Capabilities [{browserName=phantomjs}]])
17:07:15.682 INFO - Creating a new session for Capabilities [{browserName=phantomjs}]
17:07:15.682 INFO - executable: /usr/bin/phantomjs
17:07:15.683 INFO - port: 27757
17:07:15.683 INFO - arguments: [--webdriver=27757, --webdriver-logfile=/phantomjsdriver.log]
17:07:15.683 INFO - environment: {}
PhantomJS is launching GhostDriver...
[INFO - 2016-02-20T17:07:15.754Z] GhostDriver - Main - running on port 27757
[INFO - 2016-02-20T17:07:15.765Z] Session [64316920-d7f4-11e5-a0c5-8954be0ea076] - CONSTRUCTOR - Desired Capabilities: {"browserName":"phantomjs"}
[INFO - 2016-02-20T17:07:15.765Z] Session [64316920-d7f4-11e5-a0c5-8954be0ea076] - CONSTRUCTOR - Negotiated Capabilities: {"browserName":"phantomjs","version":"1.9.0","driverName":"ghostdriver","driverVersion":"1.0.3","platform":"linux-unknown-64bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
[INFO - 2016-02-20T17:07:15.765Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: 64316920-d7f4-11e5-a0c5-8954be0ea076
17:07:15.771 INFO - Done: [new session: Capabilities [{browserName=phantomjs}]]
17:07:15.774 INFO - Executing: [implicitly wait: 0])
17:07:15.777 INFO - Done: [implicitly wait: 0]
17:07:15.790 INFO - Executing: [get: https://www.waldhelden.de/])
[INFO - 2016-02-20T17:07:33.916Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW
[INFO - 2016-02-20T17:08:55.442Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW
[INFO - 2016-02-20T17:09:02.008Z] SessionManagerReqHand - _cleanupWindowlessSessions - Asynchronous Sessions clean-up phase starting NOW
17:09:13.204 INFO - Session 7c5ef02c-9361-49c8-894d-234989179189 deleted due to client timeout
[INFO - 2016-02-20T17:09:13.211Z] ShutdownReqHand - _handle - About to shutdown
I found an advise on this side, but when I add that configuration I an error:
capabilities:
phantomjs.cli.args: ['--ignore-ssl-errors=true']
Caused by: org.openqa.selenium.WebDriverException: The best matching driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver can't create a new driver instance for Capabilities [{phantomjs.cli.args=[--ignore-ssl-errors=true], browserName=phantom}]
Who knows how to setup codeception to ignore ssl errors? Any help appreciated!
Thanks
Udo
For testing my site I use Phantoman to automatically run and close phantomJS. In codeception.yml I have:
config:
Codeception\Extension\Phantoman:
path: 'vendor/bin/phantomjs'
port: 4444
debug: true
ignoreSslErrors: true
sslProtocol: any
Codeception\Extension\Recorder:
delete_successful: true

Jenkins selenium grid hub refuses incoming selenium Node connections from external IP's

I have a Selenium Grid hub running on Jenkins using the Selenium Plugin.
I have a Selenium grid node running on the same machine and it is successfully connected to the Hub.
From an external machine i cant't seem to ping the 4444 port on which hub is running through Jenkins.
I can ping the port, if Hub is started separately through command line.
I have Firewalls disabled on both my machines so its not a network issue.
java -jar selenium-server-standalone-2.46.0.jar -role node -hub http://<IP>:4444/grid/register -timeout 10000 -browserTimeout 10000 -sessionMaxIdleTimeInSeconds 10000
16:34:58.122 INFO - Launching a Selenium Grid node
16:34:59.982 WARN - error getting the parameters from the hub. The node may end up with wrong timeouts.Connect to <IP>:4444 [<IP>] failed: Connection refused: connect
16:35:00.029 INFO - Java: Oracle Corporation 25.51-b03
16:35:00.029 INFO - OS: Windows 8.1 6.3 amd64
16:35:00.044 INFO - v2.46.0, with Core v2.46.0. Built from revision 87c69e2
16:35:00.107 INFO - Driver class not found: com.opera.core.systems.OperaDriver
16:35:00.107 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
16:35:00.154 INFO - Version Jetty/5.1.x
16:35:00.154 INFO - Started HttpContext[/selenium-server,/selenium-server]
16:35:00.154 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler#76a4d6c
16:35:00.154 INFO - Started HttpContext[/wd,/wd]
16:35:00.154 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
16:35:00.154 INFO - Started HttpContext[/,/]
16:35:00.154 INFO - Started SocketListener on 0.0.0.0:5555
16:35:00.154 INFO - Started org.openqa.jetty.jetty.Server#1f7030a6
16:35:00.154 INFO - Selenium Grid node is up and ready to register to the hub
16:35:00.185 INFO - Starting auto registration thread. Will try to register every 5000 ms.
16:35:00.200 INFO - Registering the node to the hub: http://<IP>/grid/register
16:35:01.232 INFO - Couldn't register this node: Error sending the registration request: Connect to <IP>:4444 [IP] failed: Connection refused: connect
16:35:07.232 INFO - Couldn't register this node: The hub is down or not responding: Connect to <IP>:4444 [IP] failed: Connection refused: connect
Any help is appreciated.
Is that the HUB has Max connection limit set and you have already reached the connection Limit.
You can simply debug it by shutdown the HUB and restart the hub and register the node you are trying to the HUB. Hope it will register .
Must be the Connection Limit as if you don't supply anything i think a HUB can handle 5 instances.
Please try and share your reply

Failed to run selenium with googlechrome

1.start the selenium server:
sudo java -jar selenium-server-standalone-2.25.0.jar -trustAllSSLCertificates -port 4444 <br>
........
09:02:06.523 INFO - Version Jetty/5.1.x <br>
09:02:06.526 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver] <br>
09:02:06.533 INFO - Started HttpContext[/selenium-server,/selenium-server]<br>
09:02:06.537 INFO - Started HttpContext[/,/]<br>
09:02:06.571 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler#7df17e77<br>
09:02:06.571 INFO - Started HttpContext[/wd,/wd]<br>
09:02:06.574 INFO - Started SocketListener on 0.0.0.0:4444<br>
09:02:06.577 INFO - Started org.openqa.jetty.jetty.Server#798fd984<br>
2.run test case in perl:
my $sel = Test::WWW::Selenium->new( host => "localhost", <br>
port => 4444, <br>
browser => "*googlechrome", <br>
browser_url => "http://>fns-IP/" );<br>
$sel->start;
$sel->open_ok("http://>fns-IP/login");
3.test log:
09:09:25.146 INFO - Command request: getNewBrowserSession[*googlechrome, http://>fns-IP/] on session null<br>
09:09:25.146 INFO - creating new remote session<br>
09:09:25.147 INFO - Allocated session 553a1b30a1dd4f8a889fa4dfb7a6ae8a for http://>fns-IP/, launching...<br>
09:09:25.147 INFO - Launching Google Chrome...<br>
09:09:30.336 INFO - Got result: OK,553a1b30a1dd4f8a889fa4dfb7a6ae8a on session 553a1b30a1dd4f8a889fa4dfb7a6ae8a<br>
09:09:30.340 INFO - Command request: open[http://>fns-IP/login, ] on session 553a1b30a1dd4f8a889fa4dfb7a6ae8a<br>
09:09:30.610 INFO - Got result: OK on session 553a1b30a1dd4f8a889fa4dfb7a6ae8a<br>
09:09:30.623 INFO - Command request: isElementPresent[id=id_username, ] on session 553a1b30a1dd4f8a889fa4dfb7a6ae8a<br>
09:09:32.393 INFO - Couldn't proxy to http://>qlriakmdkm/ because host not found<br>
09:09:32.395 INFO - Couldn't proxy to http://>wkdujqsymi/ because host not found<br>
09:09:32.393 INFO - Couldn't proxy to http://>rkjzjvpsbx/ because host not found<br>
4.The URL In the googlechrome browser:
http://>fns-IP/selenium-server/core/RemoteRunner.html?sessionId=324f251e0de64cfeafa157de0c33ed41&multiWindow=true&baseUrl=http%3A%2F%2Ffns-4%2F&debugMode=false
and
http://>fns-IP/selenium-server/core/Blank.html?start=true
5.I tried on website 'ca.msn.com' and it worked well.
Any feedback is appreciated.
In all the urls quoted in 'http', the character '>' is added for a blockquote. Otherwise, it did not allow me to post. :(
I too have faced this problem earlier but in my case trustAllSSLCertificates was suffice.
I suggest you too move to selenium webdriver that has a good support to google chrome.