Selenium grid - Error forwarding the new session cannot find - linux

I recently installed a selenium grid environment for development testing. However, we are facing the error below:
Error forwarding the new session cannot find : Capabilities {browserName: chrome, chromeOptions: {args: [--headless, --no-sandbox], binary: , prefs: {plugins.always_open_pdf_externally: true}, w3c: false}, loggingPrefs: org.openqa.selenium.logging..., version: 88.0.4324.182}"
Additional Information:
selenium hub: sudo -u selenium nohup java -jar /usr/local/bin/selenium-server-standalone-3.8.1.jar -role hub -host http://hub_ip:4444 &
selenium node: sudo -u selenium nohup java -jar /usr/local/bin/selenium-server-standalone-3.8.1.jar -role node -browser browserName=chrome -hub http://hub_ip:4444/grid/register
Does anyone have any idea what may be going on?
***When I point the application to a server running the standalone selenium I have no problems.

I may not have a full answer for you as I usually don't set the browser name in the node as it can be set though java or python later.
But I assume you are trying to set this node to point to the hub?
This will point the node to look for the hub at the node IP
-hub http://node_ip:4444/grid/register
The Node needs to know where the Hub will be so replace the above with the below.
-hub http://hub_ip:4444/grid/register

Related

How can I start a java application with parameters using a pm2 config file?

I'm trying to start graphhopper using pm2... graphhopper is a java application and the way I initiate it on the terminal is by going to its folder and entering the following command:
java -jar matching-web/target/graphhopper-map-matching-web-1.0-SNAPSHOT.jar server config.yml
This application works fine running from the command line, but I haven't succeeded on running it as a service with pm2. The config file I'm using is this one (pm2 start config.json):
{
"apps":[
{
"name":"graphhopper",
"cwd":".",
"script":"/usr/bin/java",
"args":[
"-jar",
"/home/myyser/graphhopper/map-matching/matching-web/target/graphhopper-map-matching-web-1.0-SNAPSHOT.jar",
"server",
"config.yml"
],
"log_date_format":"YYYY-MM-DD HH:mm Z",
"exec_interpreter":"",
"exec_mode":"fork"
}
]
}
I'm 100% sure that what I'm getting wrong here is the way I'm writing the "server", "config.yml" parameters... Looking into pm2 logs graphhopper I can see that those parameters are not being recognized at all... I've tried to tweak the way it's done as well but I didn't manage to figure out the right solution. I know how to start a java application using pm2 with no parameters. But how can I do it with a java application that has parameters as in the case of graphhopper?
As stated in the comments, this issue can be solved by creating a bash script and running it with pm2 instead of running directly the java application... The bash script used was the file graphhopper.sh as the following:
#!/bin/bash
java -jar matching-web/target/graphhopper-map-matching-web-1.0-SNAPSHOT.jar server config.yml
And to start it as a service with pm2:
pm2 start graphhopper.sh --name=graphhopper
You can also run a fat jar directly in pm2 - use two dashes to separate the command args:
pm2 start java -- -jar matching-web/target/graphhopper-map-matching-web-1.0-SNAPSHOT.jar server config.yml
Mine java app worked fine - just use 1 arg - no array.
apps:
- name : 'admin'
script: '/opt/homebrew/opt/openjdk#11/bin/java'
args: '-jar ./wweevvAdmin/target/wweevvAdmin-1.0-SNAPSHOT.jar'
instances: '1'
autorestart: true

Not able to connect multiple appium node to selenium grid

I want to run appium scripts in parallel on multiple devices but always the second node fails to connect to the selenium server.
This is my selenium server logs which starts and registers perfectly
D:\Appium>java -jar selenium-server-standalone-2.52.0.jar -port 4444 -role hub m
axInstances=2 maxSession=2 -timeout 30000
15:17:45.215 INFO - Launching Selenium Grid hub
2016-02-25 15:17:45.810:INFO::main: Logging initialized #732ms
15:17:45.818 INFO - Will listen on 4444
15:17:45.856 INFO - Will listen on 4444
2016-02-25 15:17:45.859:INFO:osjs.Server:main: jetty-9.2.z-SNAPSHOT
2016-02-25 15:17:45.879:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletC
ontextHandler#b0ed20{/,null,AVAILABLE}
2016-02-25 15:17:45.893:INFO:osjs.ServerConnector:main: Started ServerConnector#
76c8cd{HTTP/1.1}{0.0.0.0:4444}
2016-02-25 15:17:45.894:INFO:osjs.Server:main: Started #816ms
15:17:45.894 INFO - Nodes should register to http://10.51.25.88:4444/grid/regist
er/
15:17:45.894 INFO - Selenium Grid hub is up and running
15:18:13.259 INFO - Registered a node http://10.51.25.88:4724
15:18:25.289 INFO - Marking the node http://10.51.25.88:4724 as down: cannot rea
ch the node for 2 tries
This is my Json file to create node and set capabilites
{"capabilities":[{"deviceName":"0009aec74c7a5f","browserName":"chrome","maxInstances":1,"version":"4.1.2","platform":"ANDROID"}],"configuration":{"proxy":"org.openqa.grid.selenium.proxy.DefaultRemoteProxy","cleanUpCycle":2000,"port":4724,"host":"10.51.25.88","maxSession":1,"hubHost":"10.51.25.88","registerCycle":5000,"hubPort":4444,"timeout":30000,"url":"http:\/\/10.51.25.88:4724\/wd\/hub","register":true}}
Hence in the similar way when I try to connect my second appium node it fails to register in appium grid without any command prompt error logs
I have two physical devices connected through USB and devices detected through adb.I am using the latest version of Appium 1.4 and the latest selenium standalone server jar file 2.52.
I am able to register my appium node to selenium server for every first node , either of the device , but when I try to connect my second appium node It fails to connect closing the command promt without giving any error logs.
This same commands and configuration used to work for previous version of Appium (about one year Old), but for the new Appium version second node is not getting registered.
Is there any alternative method to register appium node to selenium grid , or Is there something I am missing above ?
I have built library that generates .json and .bat file for each Appium node. It is tested well and work so cool. So I believe you are missing boot strapping port number to connect another instance of Appium.
Json File:
{
"capabilities":
[
{
"DeviceManufacturer":"LGE",
"DeviceModel":"Nexus 5",
"DeviceOS":"Android",
"OSVersion":"6.0.1",
"DeviceType":"Real",
"deviceName":"038d1797094778a8",
"browserName":"Real_LGE_Nexus 5_Android_6.0.1",
"platform":"Android"
}],
"configuration":
{
"nodeTimeout":120,
"port":4723,
"hubPort":4444,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url":"http://192.168.1.246:4723/wd/hub",
"hub": "192.168.1.246:4444/grid/register",
"hubHost":"192.168.1.246",
"nodePolling":2000,
"registerCycle":10000,
"register":true,
"cleanUpCycle":2000,
"timeout":30000,
"maxSession":5
}
}
You must be observing that I am using multiple capabilities but I am using all of them by overriding matches method of org.openqa.grid.internal.utils.DefaultCapabilityMatcher class. so when I call main method of org.openqa.grid.selenium.GridLauncher class. I am keeping my overriding jar in same class path and It worked for customizing matching node.
.bat file:
Notice this in .bat file -> --bootstrap 6024
node.exe "C:\Program Files (x86)\Appium\node_modules\appium\bin\appium.js" --address 192.168.1.132 --port 4830 --bootstrap 4830 -U 038d1797094778a8 --nodeconfig D:\MobileBaseProjectRepository\Grid\Node\nodeConfig_192.168.1.132_2.json --session-override
so, coming back to your question use --bootstrap 6024 while invoking appium node, you will through.

Running protractor tests on IE 11

OK, so I have been searching a lot to get proper solution to the blocker I am facing right now. Let me give you a background of what I have done so far :
I want to run protractor tests (located on Linux machine) on IE 11 of Windows Server 2012 R2 (IP : 10.81.73.248). My protractorTest.conf.js has below :
exports.config = {
seleniumAddress: 'http://10.81.73.248:4444/wd/hub',
baseURL: 'http://10.81.78.137:80000/',
capabilities: {
browserName: 'internet explorer',
platform: 'ANY',
version: '11'
},
On my Windows Server 2012 R2 machine, I've downloaded IEDriverServer_Win32_2.47.0 and placed it under C:\Windows\System32, environment variable PATH has been updated with above location. Protected mode settings are same for all zones. Windows machine also has selenium-server-standalone-2.48.2.jar placed under C:\Users\Selenium.
On Windows machine, I am starting selenium server using below command :
java -jar selenium-server-standalone-2.48.2.jar -port 4444 -Dwebdriver.ie.driver="C:\Windows\System32\IEDriverServer_Win32_2.47.0\IEDriverServer.exe" , which starts selenium server fine.
With above settings, I run protractor tests from my Linux machine using grunt protractor_test, which launches IE browser on Windows machine, shows localhost:dynamic port and a message as : This is the initial page of webdriver server and within 2 seconds, closes the browser.
The exception I get on selenium server terminal is as below :
Session ID is null. Using WebDriver after calling quit() ?
This is where I am stuck at. I looked at various posts which describes similar issue (?) as mine along with the potential solution, but I am unable to resolve my issue here.
Is there anything I might be doing wrong to setup the connections ? or am I missing some steps to get me through ?
I would really appreciate if you guide me in resolving this long time pending blocker.
I think you are trying to run using old selenium version.It should be 2.53.x something.
Few basics things to check first regarding IE execution:
1).IE Setting for protractor(Selenium)
http://elgalu.github.io/2014/run-protractor-against-internet-explorer-vm/
2).Take IE driver of 32 bit(don't take 64 it has known slowness issues) and manually copy on the following path:
Root Folder\node_modules\protractor\node_modules\webdriver-manager\selenium\IEDriverServer_Win32_2.53.1
3). IE Driver can be downloaded from following path:
http://selenium-release.storage.googleapis.com/index.html?path=2.53/
**OR**
Please upgrade your protractor version to latest like 4.0.11 by changing the version in package.json file and do from command prompt(inside project root directory):
npm update
and then give update your selenium driver with following command from command prompt
webdriver-manager update --ie
it will update the selenium version of IE driver to latest and then try running your tests again.

Does 'docker run' modify image state?

I have a Dockerfile that uses an ubuntu base image and installs a bunch of dependencies with apt-get and dpkg. Then it copies some javascript files and runs a node app. The node app spawns a child process and executes xvfb-run selenium-standalone start.
If I build the docker image with --no-cache and run it using docker run -i -t <image id> my app starts and connects to the selenium server immediately. If I kill the container using CTRL-C or docker stop <container id> and then run the exact same docker run command as above, my app starts as normal, but cannot connect to the selenium server. If I leave it alone, five minutes later, it will connect properly on its own. It behaves this way every time I run docker run until I do a clean image build.
Changing a node source file and rebuilding mostly from cache does not alter this behavior. I've repeated the process several times and it's always the same.
I can't figure out how the behavior can change from one docker run to the next, if the same image is used. Where is the shared state?
Log when working:
gulp run
22:42:31.541 INFO - Launching a standalone Selenium Server
Setting system property webdriver.chrome.driver to /usr/lib/node_modules/selenium-standalone/.selenium/chromedriver/2.16-x64-chromedriver
22:42:31.579 INFO - Java: Oracle Corporation 24.79-b02
22:42:31.579 INFO - OS: Linux 3.18.5-tinycore64 amd64
22:42:31.594 INFO - v2.46.0, with Core v2.46.0. Built from revision 87c69e2
22:42:31.676 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] does not match the current platform LINUX
22:42:31.676 INFO - Driver class not found: com.opera.core.systems.OperaDriver
22:42:31.677 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
[22:42:31] Using gulpfile /opt/app/gulpfile.js
[22:42:31] Starting 'run'...
[22:42:31] Finished 'run' after 1.29 ms
Started App.
22:42:31.764 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
22:42:31.764 INFO - Selenium Server is up and running
Selenium started
2015-08-19T22:42:32.445Z Starting app on port: 8000
Logs when not working are exactly the same except missing the RemoteWebDriver, 'Selenium Server is up and running', and 'Selenium started.' lines.
Try removing the container instead of just stopping it:
docker stop <container id>
docker rm <container id>

Selenium Grid - Webdriver - Whitescreens when running tests

So typically I do these steps to run a test
Start selenium grid (java -jar selenium-server-standalone-2.39.0.jar -role hub // java -jar selenium-server-standalone-2.39.0.jar -role node)
Run a test script (node test.js // nightwatch test.js | node test.js)
Webdriver kicks off browser and starts test
These scripts used to work and after revisiting them after a couple months I found they are now broken. I am unsure what the problem is as I have not changed any code. Any help is greatly appreciated.
FYI
Selenium version: 2.39.0 |
OS: Mac Yosemite |
Browser: Firefox |
Browser version: 34.0.5
After 'starting' the server and going to
http://localhost:4444/
i get
"You are using grid 2.39.0
Find help on the official selenium wiki : more help here
default monitoring page : console"
but when trying to run a night watch script or even 'nightwatch help' it fails and then gives me the error - 'Connection refused! Is selenium server started?' (node scripts also give me a white screen)
Turns out this webdriver doesn't like the newer versions of firefox.
If you are experiencing issues go grab Firefox v 28.0 https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/28.0/mac/en-GB/

Resources