[Vagrant][Jenkins][Behat][Selenium] How to combine them? - selenium

I have a project with some requirements: install jenkins, selenium, behat on a Vagrant box with ubuntu 12.04. I installed jenkins, selenium, behat on this box. When i run selenium, jenkins and run some behat test, the error display :
- Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
Error: no display specified
Error: no display specified
I installed firefox and use selenium-server-standalone-2.35.0.
firefox -v
Mozilla Firefox 24.0
What should i do?
Thanks

Its most likely that your Jenkins user does not have an X session to run firefox in.
You can use something like Xvfb which is a virtual frame buffer How do I run Selenium in Xvfb?
Alternatively you could use phantomjs/ghostdriver which is a totally headless webdriver for selenium https://github.com/detro/ghostdriver - so you don't need any X at all.
I personally run a selenium hub and connect various drivers to it for different browsers. These drivers can be on different machines and platforms so you can fully test different configurations

Related

Do we need to have the Browser installed on GUI less RedHat Linux m/c when we are running headless tests using XVFB?

Since we are facing problems with running headless Serenity tests using the installed Firefox browser on a Jenkins Server running on RedHat Linux machine, we installed XVFB to run the tests.
Our preferred browser to test is with Chrome, not Firefox. But Chrome is not available for RedHat Linux (Jenkins) Server.
Question, is do we need to have the Chrome browser installed on the Linux machine in order to run headless tests using XVFB ?
Yes, you need to have both the chrome browser and chrome driver to run tests. You can find the chrome driver [here][http://chromedriver.chromium.org/downloads]. If Chrome is not available for Red Hat Edition, you can install open source chromium.

Browser is not launching even test is running through Jenkins on ubuntu

I am trying to launch browser for automation testing(selenium) using jenkins on ubuntu OS. Test are running properly but browser is not launching seems like it is running headlessly.
I am able to fix this using this solution -
Added Xvfb plugin and added DISPLAY variable.
Running jenkins.war
from console using java -jar jenkins.war
As I know in Windows OS by checking "Allow service to interact with desktop" while jenkins installation we can fix this. So Is there any way we can do this on ubuntu by updating some configuration so we don't have run jenkins.war from console everytime.
There are two ways to facilitate the launch of browser on ubuntu OS.
1.First way - Configure your Jenkins nodes and add the ubuntu machine. Add the sshing details(username-password OR RSA key) of the target machine. This configuration is recommended if you are in cloud.
2.Second way(not recommended on cloud environments) -You have to run a Selenium standalone-Server (a standalone node), and register your remote WebDriver to it.
WebDriver driver = new RemoteWebDriver(new URL("http://ipOfUbuntuMachine:port/wd/hub"), capability);

Firefox 49.0 + Selenium 2.9.1

I'm trying to do testing with Selenium 2 and phpunit. I'm using selenium-server-standalone-2.53.1.jar and launch the test firefox opens blank and does nothing.
phpunit gives this message:
PHPUnit_Extensions_Selenium2TestCase_WebDriverException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output
Can anyone tell me what happens? Thmks.
Use geckodriver.
You need geckodriver for running tests in latest Firefox browsers. Firefox doesn't support Firefox driver anymore.
Download geckodriver and place it in PATH
Use Selenium 3.0 for running tests
Or use Firefox 47.* or 45 ESR with the old driver.
Background
Firefox release 48.0 states the following:
Add-ons that have not been verified and signed by Mozilla will not load
Firefox driver fell under this category, and it had no chances of passing verification without being re-written. Geckodriver, though, is built in the same way as Chromedriver and IEdriver are, and kinda works.
Some more info is available here

WebDriverException: Element is not clickable at point

Complete error
org.openqa.selenium.WebDriverException: Element is not clickable at
point (931, 23). Other element would receive the click:
Running selenium tests using Jenkins in headless browser
In following environment
OS- CentOS 6 and Xvfb installed in same machine
Xvfb screen resolution - Xvfb :1 -screen 0 1280x1024x16 &
Driver - Firefox driver
Selenium webdriver version - 2.52.0
The same test case working fine in windows os with firefox
Try this. Install Xvfb plugin on Jenkins.
After that install Xvfb in "Global Tool Configuration"
Then under your project configuration, setup xvfb
Try Using resolution given in image
Now run your build :)
This is the reason it is important to test on different browsers and on different platforms. Sometimes what works on one browser/os does not work on the same browser but a different platform.
I would update your setup so that you make a screenshot when you run into this type (and most other types) of error. In my experience this is the single best thing you can do to reduce the time spent to debug these issues.
In my setup I do the following:
Create a screenshot
Capture the coordinates from the Selenium error message
Use an image manipulation program to automatically create a red dot where the click happened
Usually I just have to take one look at such an image to see exactly what is happening.

How To Run UI Test Classes Using Selenium Webdriver in Jenkins?

I have test classes written in java for UI testing using Maven using Selenium Web-Driver. I want to run them using mvn test command in Jenkins.
It is not able to launch the browser for the testing.
The error stack shown is something like this:
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
Error: no display specified
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:106)
Any help on this will be appreciated.
Firefox needs a X display to run, e.g. Xvfb
You will need to
install xvfb on your server. Doing this depends on your server operating system (and package management)
start xvfb before the build. You can do this using the xfvb plugin, or by running Xvfb as a daemon. I personally like to use the plugin.