Selenium Grid - Webdriver - Whitescreens when running tests - node.js

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/

Related

Selenium grid - Error forwarding the new session cannot find

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

Unable to launch url in chrome using Elementor npm module

Hi All,
Am using below version of dependencies to run elementor on windows
10 console
Node : 9.1.0
protractor : 5.2.0
Elementor : 2.1.0
ChromeBrowser : 62
webdriver-manager is up and running on terminal
when i type elementor https://www.google.com/
chrome browser launches but not loading google.com url in the
browser , i tried to downgrade browser version to 61 and tried still
the same below issue. From console i get below loggers. Please
suggest how can i get this up and running
Using the selenium server at http://localhost:4444/wd/hub [15:39:18]
I/protractor - [15:39:18] I/protractor - ------- Element Explorer
------- [15:39:18] I/protractor - Starting WebDriver debugger in a child
process. Element Explorer is still beta, please report issues
at github.com/angular/protractor [15:39:18] I/protractor -
[15:39:18] I/protractor - Type to see a list of locator strategies.
[15:39:18] I/protractor - Use the list helper function to find
elements by strategy: [15:39:18] I/protractor - e.g.,
list(by.binding('')) gets all bindings. [15:39:18] I/protractor -
[15:39:18] I/protractor - Debugger exiting
downgraded node to below version :
node -v
v6.12.0
Elementor, browser.debug(), browser.pause(), browser.enterRepl() everything works fine.
Tried node version manager which nvm module to manage more than one versions of node.

Selenium::WebDriver::Error with Firefox & Chrome

Problems
1. Browser = Firefox (Non Geckodriver, Selenium v2.53.4)
(Works on one linux thin client but not on another...)
$ bundle exec rake parallel:spec
Selenium::WebDriver::Error::WebDriverError:
unable to bind to locking port 7054 within 120 seconds
2. Broswer = Firefox (Geckodriver v0.14.0, Selenium-webdriver v3.1.0)
$ bundle exec rake parallel:spec
Net::ReadTimeout:
Net::ReadTimeout
3. Browser = Chrome (Chromedriver v2.27, Selenium-webdriver v3.1.0)
$ bundle exec rake parallel:spec
Selenium::WebDriver::Error::NoSuchDriverError:
no such session
(Driver info: chromedriver=2.27.440175 ,platform=Linux 3.16.0-0.bpo.4-amd64 x86_64)
My Setup
Server with the following installed:
-Linux - Debian x86_64 Wheezy
-ruby 2.2.5p319 (2016-04-26 revision 54774)
-Firefox v46.0.3
-Chrome 56.0.2924.87 (64-bit)
-ChromeDriver 2.27.440175
-Xvfb (x11-xserver-utils v 7.7~3 through headless gem)
Gems
-Selenium v3.1.0 (was 2.53.4)
-parallel_tests v2.10.0
-capybara (2.7.1)
-rspec-activemodel-mocks (1.0.3)
-rspec-core (3.4.4)
-rspec-expectations (3.4.0)
-rspec-mocks (3.4.1)
-rspec-rails (3.4.2)
-rspec-support (3.4.1)
-headless (2.2.3) (Xvfb)
Multiple thin clients running their software off the mentioned server setup.
My computer is one of many...
Important: There is another computer that does NOT encounter the mentioned problem running the same software and same versions off the same server!
Things that are NOT the problem
It is not an incompatibility between my firefox browser version and Selenium.
Why not?
a) Firefox v46.0.3 and Selenium v2.53.4 is currently installed on our server and another client of this server successfully runs parallel_tests using the mentioned versions of Firefox & Selenium.
b) Which Firefox version is compatible with Selenium 2.53.0?
There are no zombie processes(still running firefox) causing firefox to lock port 7054.
This is specifically after each failure has occurred and prior to starting a new $ bundle exec rake parallel:spec run.
Why not?
refer to items 1 & 2 in 'Things I Have Tried'
Turned Out this was not the case, although it was not the cause of the problem
Databases were not always properly killed, See Update 5.
However the databases not being killed were an outcome of the problem.
They were not the cause of the problem, refer to solution section.
Side note
For those wishing to install the mentioned versions to get selenium / firefox working:
Installing a previous version doesn't fix most problems
Things I have tried
Removed any processes still running
$ killall ruby; killall rspec; killall firefox
Result: Failed...
Discovered that completing step 1 is not enough to kill all zombie processes.
After logging out into a different tty i discovered that there was still an rspec, ruby and firefox process running!
So I logged out of my user, logged into a new tty, killed all zombie processes using:
$ kill -9 process_id
I then rerun $ ps aux to ensure all processes are cleaned.
Result: Failed...
Gain insight into the problem.
Ran $ lsof -i TCP:7054 see what is holding that process.
Result: It was my firefox test, no suprise, no real insight gained.
Ensured parallel test databases were running correctly.
Dropped all databases, recreated databases, reloaded all schemas, reseeded (development), reprepared.
Result: Failed... I doubted this was the cause, but doing this certainly eliminated it.
Deleted firefox cache, all persisted setting, everything, for a clean start.
Result: Failed...
Try to eliminate any local environment variables obtained from the project.
Did this by copying the project directory from the working computer.
Then reran $ bundle exec rake parallel:spec.
Result: Failed...
Try to eliminate all local environment variables (project and linux).
Did this by creating a new linux user.
Then switched into the new user.
$ su new_user -l
Copied over the minimum zsh items needed.
Then ran $ bundle exec rake parallel:spec
Result: Failed...
Ensured that /etc/hosts contained:.
127.0.0.1 localhost
Result: Failed...
Running the tests in a single thread (not parallel).
$ rspec spec
Result: Successfully runs (does not hit the problem)
See Update 1
See Update 2
See Update 3
See Update 4
See Update 5
Partial Solution
See Update 6
Debugged Selenium & Parallel_tests gems
Result: Identified that the issue is NOT in Selenium
See Update 7
Result: Running tests in parallel worked. But why?
See Update 8
Result:
Discovered Selenium 3.1.0 changed the way files are automatically downloaded.
This caused tests to hang indefinitely whilst running parallel test.
Which caused the databases to be held open.
Things I am going to try (Updates)
Run tests with chromedriver in chrome browser and see if it passes after the fix.
Update 1
I replaced firefox for chrome.
When I run a single test, the test successfully completes with chrome.
It did so with firefox as well.
However running $ bundle exec rake parallel:spec
Result: Failed...
Selenium::WebDriver::Error::NoSuchDriverError:
no such session
(Driver info: chromedriver=2.27.440175 ,platform=Linux 3.16.0-0.bpo.4-amd64 x86_64)
Update 2
I updated selenium-webdriver gem to the latest gem (was v2.53.4 now 3.2.2)
Result: Failed...
Selenium::WebDriver::Error::NoSuchDriverError:
no such session
(Driver info: chromedriver=2.27.440175 ,platform=Linux 3.16.0-0.bpo.4-amd64 x86_64)
Update 3
Located lock file for parallel test (~.config/google-chrome).
Identified 3 persisting lock files.
Other users only had 1.
Deleted these and reran tests.
Result: Failed...
Selenium::WebDriver::Error::NoSuchDriverError:
no such session
(Driver info: chromedriver=2.27.440175 ,platform=Linux 3.16.0-0.bpo.4-amd64 x86_64)
Update 4
Upgraded selenium-webdriver to v3.1.0 (latest stable)
Upgraded parallel_tests to v2.13.0 (latest)
Installed Geckodriver v0.14.0 (latest)
Then ran $ bundle exec rake parallel:spec
Result: Failed...
Failure/Error: visit "#/login"
Net::ReadTimeout:
Net::ReadTimeout
Update 5
Whilst in the firefox (Geckodriver v0.14.0, Selenium-webdriver v3.1.0) branch.
I only realised when I had to drop all my parallel_test databases that some were still open.
#ltsp:~/ap$ bundle exec rake parallel:drop[32]
Couldn't drop ap_test_andre32 : #<ActiveRecord::StatementInvalid: PG::ObjectInUse: ERROR: database "ap_test_andre32" is being accessed by other users
DETAIL: There are 3 other sessions using the database.
: DROP DATABASE IF EXISTS "ap_test_andre32">
Couldn't drop ap_test_andre25 : #<ActiveRecord::StatementInvalid: PG::ObjectInUse: ERROR: database "ap_test_andre25" is being accessed by other users
DETAIL: There are 3 other sessions using the database.
: DROP DATABASE IF EXISTS "ap_test_andre25">
When rake parallel:spec does not complete (indefinetly hangs during ),
the process must be killed manually.
Doing so leaves databases locked to the parallel_tests that were using them at the time.
So they must be identified and cleaned up.
postgres 743 0.0 0.0 222364 33628 ? Ss 15:30 0:00 postgres: andre ap_test_andre32 [local] idle in transaction
andre 24581 0.0 0.0 7852 2028 pts/36 S+ 15:49 0:00 grep andre32
postgres 26822 0.0 0.0 220032 23400 ? Ss 15:35 0:00 postgres: andre ap_test_andre32 [local] ALTER TABLE waiting
postgres 29684 0.0 0.0 220032 24064 ? Ss 15:40 0:00 postgres: andre ap_test_andre32 [local] ALTER TABLE waiting
Update 5 Solution:
search for database processes & kill all of them
ps aux | grep test_andre
andre#ltsp:~/ap$ sudo kill -9 743 26822 29684
I was then able to drop my databases.
bundle exec rake parallel:drop[32]
Update 6
Whilst in the firefox (Geckodriver v0.14.0, Selenium-webdriver v3.1.0) branch.
Cloned parallel_tests & Selenium projects locally.
Replaced my gems with a path to the locally cloned projects.
Debugged starting with the error stack trace.
Results
Updated to selenium 3.1.0 and loaded geckodriver (marionette).
I discovered that my firefox profile was not setup correctly with Capybara.
This broke my local single thread tests.
Fixed this.
Discovered that geckodriver is not to be used for FF<48.
Also discovered that the capybara, selenium 3+ & FF48+ combo is not yet ready for use.
Some vital functions are not working. (Right clicking, window resizing...)
Refer here for full details
After investigating parallel_tests, was able to rule that out.
Continued to debug in the firefox test case.
Used the locking port error as my guide.
Ruled out Selenium as the cause of the error.
After debugging the stack trace, it was proving to be very likely that the error state was inherited.
This was just a strong hunch at the time.
It later proved to be correct...
So summary here was that firefox had processes that were being locked.
And they were not being locked by Selenium.
Update 7
Whilst in the firefox (Selenium-webdriver v2.53.4) branch.
Went back to the new linux user that was created.
In light of Update 5, I dropped cleaned up all running processes.
Dropped all databases.
$ bundle exec rake parallel:spec
Result: Parallel tests worked
But why?
The databases were not the cause of the issue.
There was something else.
Update 8
Whilst in the firefox (Geckodriver v0.14.0, Selenium-webdriver v3.1.0) branch.
Identified the reason why the tests were failing and idenfinitely hanging.
This caused the issues described in Update 5 & 6.
It was caused by a change in the way Selenium accepts firefox profile settings.
I identified that the integration tests that were failing were ones that launched a pdf download.
Previously, I had this automated so that the download modal would not appear.
Instead it would automatically download the file to a specified folder.
Updating to Selenium 3.1.0 broke this.
Tests hanged indefinitely.
Databases were held open.
The problems identified, in the updates were not the root cause.
The root cause was that firefox/chrome browser ports were not closed and held open.
After looking at htop, Polkitd was seen to be taking up 16.5gb of ram!
This was caused by a memory leak in Polkitd.
After checking the issues it was confirmed that Polkitd memory leak is a know issue.
The issue has been fixed but only in later distributions of linux debian and not for Wheezy.
After restarting Polkitd, and rerunning the tests in parallel they worked!
This explains why the first time I created a new linux user with a clean profile the parallel test issues were still occuring. - Memory leaks are unpredictable.
It also explains why another computer did not run into the issue.
And why the second time I created a new user the parallel tests worked!
Phew, that took a lot of effort!
Polkitd was uninstalled as it was not needed for any printers or other software that we run.
Overall, if anyone else has the locking issue, it would be helpful to follow some of the process detection that I have done as some of the issues are common to all OS.

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.

Resources