PhantomJS register with Selenium Grid - selenium-webdriver

I need assistance on registering PhantomJS with Selenium Grid. Based on some approaches I've seen online I implemented it this way:
Grid register
java -jar selenium-server-standalone-3.0.0-beta2.jar -role hub -port 4444
PhantomJS
phantomjs.exe --webdriver=5555--webdriver-selenium-grid-hub=http://127.0.0.1:4444
both cmd started fine but phantomjs is not registered to the grid

As far as I know, you don't need Selenium to run the test against phantomjs in webdriver mode.
I don't know wich language and framework are you using. But In behat/mink/phantomjs:
Console:
phantomjs --webdriver=8643
And in your behat.yml:
sessions:
"Name_of _your_session":
selenium2:
wd_host: "http://localhost:8643/wd/hub"
The important part here is: wd_host: "http://localhost:8643/wd/hub"
That I'm sure that you can adapt to whatever your system is. You can run the phantomjs from another server and use it only by modifying the IP: "http://XXX.XXX.XXX.XXX:8643/wd/hub"
But you don't need to run the selenium server.

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

How to specify "binary" path for remote chromedriver in codeception?

I'm trying to use a remote chromedriver with codeception. I'm currently able to connect to the chromedriver, because if I don't start it, I get a different error (after a long timeout). However, the chromedriver isn't able to start chrome on that windows VM because it's not installed in the path it's searching it for. I tried to override it but can't find the way to setup codeception for that options.
Here's what I tried in my acceptance.suite.yml:
WebDriver:
host: 10.0.15.15
port: 9515
url: 'http://www.box.dev'
browser: 'chrome'
capabilities:
binary: "C:\\\\Program Files (x86)\\\\Google\\\\Chrome\\\\Application\\\\chrome.exe"
I tried a couple variations over the binary format with \ \ \\ \\ and /. Chrome just don't show up... There isn't much "output" from the chromedriver so I'm going a little bit blind on that...
The chromedriver should run on the host system. You have to start selenium with an option, which says selenium where the chromedriver.exe is located.
java -jar selenium-server-standalone-2.41.0.jar -role node -hub http://www.box.dev:9515/register/grid Dwebdriver.chrome.driver="C:/Users/me/Downloads/chromedriver.exe"
Then you only need to say in your codeception configuration, that you want to use the browser chrome (it should be installed there).
The acceptance.suite.yml that works for me on Windows looks like.
capabilities:
chromeOptions:
args: ["disable-infobars", "headless","disable-gpu", "window-size=1920x1080"]
binary: "C:/Users/***/chrome.exe"

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.

Selenium grid2 plugin --display switch

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

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