Selenium grid2 plugin --display switch - selenium-webdriver

I am trying to run a firefox node on ubuntu 12.04. I have 5 x sessions running. If I run the command firefox --display=:1 everything works and I can vnc on to the desktop and see firefox running. Next I have created a plugin for selenium grid2 where I set the capability moz.switches to --display=:1. When I run a test I can see on the node logs that the capability is present however it appears the switch is not getting sent to the firefox command:
11:46:38.603 INFO - Creating a new session for Capabilities [{platform=ANY, webdriver_assume_untrusted_issuer=false, noVNCPort=5901, browserName=firefox, moz.switches=[--display=:1], webdriver_accept_untrusted_certs=true, version=, x=1}]
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Error: no display specified
I got the moz.switches code from https://github.com/freynaud/grid-spine-selenium/blob/master/src/main/java/com/ebay/spine/LinuxWebDriverVNCProxy.java#L325 but it doesn't seem to be working. Does anyone have any experience writing this type of plugin? I'm a bit stuck really and looking at the selenium code can't see this moz.switches flag nor how I could debug the problem...

Related

OperaDriver for Selenium remains stuck when launching tests

I am using TestNG to run automated tests using a Selenium Java client. The tests are running fine on chrome and firefox but when I try to run the same on opera, I end up seeing tests timing out on the following console message:
Starting OperaDriver 2.35 (ee0117ea0f7f76009fd2aa3dd6b6164205de32b5) on port 27234
Only local connections are allowed.
org.openqa.selenium.WebDriverException:
unknown error: Opera failed to start: exited abnormally
(Driver info: OperaDriver=2.35 (ee0117ea0f7f76009fd2aa3dd6b6164205de32b5),platform=Linux 4.13.0-38-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Environment
Ubuntu 16.04LTS
JDK 10
Selenium 3.11.0
OperaDriver 2.35(downloaded from here)
Code
OperaOptions options = new OperaOptions();
options.setBinary("operadriver");
testDriver = new OperaDriver(options);
I am trying to understand what went wrong here.
Many in the community seem to get the same error when trying to get opera running with selenium and opera driver. I also tested this with your versions and get the same output, although the other browsers are working just fine.
Opera does not seem to put a lot of resources in making this work. Check out this link for some more information, it is actually a slightly different issue, but still there are some background informations there.
The suggested hack is to run opera through an appropriate version of the chromedriver. I also got opera running with selenium that way some time ago (therefore other versions), but I did not yet test this with your configuration.
Update
I managed to get the following configuration work:
Ubuntu 16.04
Java 1.8
Selenium 3.11.0
Operadriver 2.30
Opera 48.0.2685.52
by using the chrome hack and passing the operadriver as the "chrome"driver

Firefox Webdriver fails with UnreachableBrowserException and blank Screen

I am running webdriver 2.53.1 against firefox 45.9.0ESR on Redhat Linux 6.6. FirefoxDriver object gets created successfully and firefox launches with blank page (about:blank) as expected. But when I do the 'get' to open the url, it fails with UnreachableBrowserException with underlying cause as org.apache.http.NoHttpResponseException: localhost:7055 failed to respond.
Preferences set for FirefoxProfile
app.update.auto = false
app.update.enabled = false
app.update.silent = false
media.gmp-provider.enabled = false
webdriver.log.file = webdriver_debug.log
webdriver.firefox.logfile = firefox_browser.log
My observations
Browser is running and is not killed
Browser has webdriver addon added.
By 'netstat' I see webdriver listening on port 7055
Though I configured to dump firefox and webdriver logs, nothing gets dumped.
What I tried so far
Handling the exception and retrying does not help
The firefox is a tar ball extract. I tried removing the folder and extracting again, but that did not help either.
Used navigate().to(url) instead of get(url) but result is same.
NOTE: The JRE 7 is used for running
Upgrading Selenium
We cannot upgrade the selenium or firefox as there are many other dependent layers to be upgraded for selenium/firefox to upgrade.
You need to update your jars files of selenium both server and client.
Download the latest jars from below link :-
http://www.seleniumhq.org/download/
You also need to update your gecko driver from below URL :-
https://github.com/mozilla/geckodriver/releases
Additionality update your firefox
Help -> About

FirefoxWebdriver on remote machines

Is it required to install the Firefox web driver on the remote machines acting as node or hub?
I tested the hub and nodes locally? I think, it is necessary to install the web driver on the hub and node. Any comments or suggestions?
Update:
Selenium jars are running (i.e. Java is installed and web driver also exists within the selenium jar as per the documentation). Why am I getting this error
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Unable to connect to
host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Also,
(process:13023): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed
Error: no display specified
Thanks in advance!
You don't need anything on the machine that runs the hub except the selenium jar.
On the machine that runs the node you only need firefox itself to be installed, and the selenium jar running.
Firefox doesn't need a webdriver, only chrome.
from documentation
Firefox driver is included in the selenium-server-stanalone.jar
Yesterday, I was able to find the root cause, I was running these on the headless machines and needed those to be configured in order to launch ff. Thanks for your help!

End To End Testing on Headless Server

I am trying to set up an environment for end-to-end testing on a droplet running Ubuntu server 12.04.3 on digital ocean.
What I am trying to achieve in the end is for my jenkins (installed on the one droplet) to be able to run my end-to-end tests. Now, the server is ofcourse headless and the end-to-end tests need to run through a browser (I am using protractor with the selenium standalone server with chromedriver).
My question is: how do I spawn a browser on that machine? I have installed xorg and if I do startx on the server, log out and ssh -X to it, I can manually run the end-to-end tests (a browser pops up on my local machine). But I can get it to work without ssh -X to it, and since jenkins is on the same droplet where the tests are to be run. Well I dont get a browser to spawn.
NOTE: I know I might be missing something really trivial here since I don't fully understand the configuration nor the xorg.
Any hints or a complete answer is very much appreciated, this is giving me gray hair.
Edit: After a little digging I think i got the xorg stuff a bit wrong, i am guessing the purpose of X is to be able to spawn a window on a remote machine ( ie my local machine). And what i am after is more along the lines of a virtual frame buffer such as Xvfb...
There is PhantomJS but with Protractor is buggy and a dead-end.
You can still use Chrome & Firefox headless through docker-selenium or, if you don't like Docker you can do it yourself with ubuntu-headless sample. Both solutions provide Chrome & Firefox by using Xvfb even though there is no real DISPLAY.
UPDATE 2 Seems to be possible to run Xvfb in OSX: http://xquartz.macosforge.org/landing/
UPDATE 1 Mac OSX selenium headless solution:
Enable multi-user remote desktop access to OSX machine
So can test selenium headless on mac. Not headless really but as another user so it doesn't interfere with your current user display.
To do this you need kickstart: http://support.apple.com/en-us/HT201710
Begin using the kickstart utility
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -restart -agent
Activate Remote Desktop Sharing, enable access privileges for all users and restart ARD Agent:
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -restart -agent -privs -all
Apple Remote Desktop 3.2 or later only
Allow access for all users and give all users full access
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -allowAccessFor -allUsers -privs -all
Kickstart help command
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -help
A lot of angular apps use Travis CI to perform Protractor based end-to-end integration tests on headless vms all the time. I do not know the details of exactly how they do it but I do know that they use a linux service called xvfb which is a headless x windows implementation. Looking at a typical Travis configuration file, it appears that all they do before firing up their web server, selenium server and kicking off Protractor is to call sh -e /etc/init.d/xvfb start to start this service.

Anyone Else Having Trouble Registering Ghostdriver with Selenium Grid?

I know that there is documentation on the ghostdriver wiki on how to attach it to a selenium grid. For those that don't know you can find it here
I've compiled the special phantomjs twice, tried to attach it to selenium servers local, and remote using both Selenium versions 2.24 and 2.25 to no avail. It starts up Ghostdriver locally just like you expect, but there's certainly no registering going on.
I tried both ip/localhost:4444 and ip/localhost:4444/grid/register with no results. I also thought perhaps it just didn't show up on the grid console and tried to run tests against it anyway, which failed stating there was nothing populating the grid.
I've tried this on both CentOS 6 and Ubuntu 12.04 with no luck.
I'm out of ideas. Has anyone else had problems like this?
I had exactly the same problem and fixed it with using the lastest version of selenium-grid.
The good website: https://code.google.com/p/selenium/wiki/Grid2 (this is no longer http://selenium-grid.seleniumhq.org/).
Here the steps (version 2.31.0):
Download the selenium-server:
wget https://selenium.googlecode.com/files/selenium-server-standalone-2.31.0.jar
Launch selenium grid server:
java -jar selenium-server-standalone-2.31.0.jar -role hub
In a new terminal, launch GhostDriver:
phantomjs --webdriver=5555 --webdriver-selenium-grid-hub=http://localhost:4444
Check out available remote control on http://localhost:4444/grid/console.
You should see something like that:
listening on http://127.0.0.1:5555
test session time out after 300 sec.
Supports up to 1 concurrent tests from:
phantomjs
I was testing this commands on CentOS 6.3, I hope it works for you!

Resources