Chrome browser does not open when running TestNG test suite file using maven command on Ubuntu 14.04 Terminal

maven command to run tests
what does mvn test command do
maven run all tests
run testng from command line maven
mvn test not running tests
chrome browser is not opening through jenkins
how to run maven project in eclipse using command prompt
how to run maven jar file from command line

Machine: Ubuntu Linux 14.04 LTS

Maven: 3.0.5

When I execute my TestNG test suite file from Eclipse, it opens the Chrome browser and executes the tests properly. But when I execute the following command on terminal,

$ sudo mvn clean install -DsuiteXmlFile=testng.xml

Since there is already some access issue with my machine, I have to use sudo with the command.

Chrome browser just won't open and the maven log just keep on printing the following log infinitely,

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running TestSuite
Starting webdriver on OS: Linux
Starting ChromeDriver 2.37.543619 (a237acd3116cac3b3f0da42a000502ce3fafcb23) on port 14536
Only local connections are allowed.
Starting webdriver on OS: Linux
Starting ChromeDriver 2.37.543619 (a237acd3116cac3b3f0da42a000502ce3fafcb23) on port 6694
Only local connections are allowed.
Starting webdriver on OS: Linux
Starting ChromeDriver 2.37.543619 (a237acd3116cac3b3f0da42a000502ce3fafcb23) on port 4991
Only local connections are allowed.
Starting webdriver on OS: Linux
Starting ChromeDriver 2.37.543619 (a237acd3116cac3b3f0da42a000502ce3fafcb23) on port 19892
Only local connections are allowed.
Starting webdriver on OS: Linux
Starting ChromeDriver 2.37.543619 (a237acd3116cac3b3f0da42a000502ce3fafcb23) on port 21613
Only local connections are allowed.

However, this is working perfectly fine on Windows 10.

Does anyone have a solution for this as I am not able to find any solution for this.

Set your system display value as given below and try running again the test.

You can write at the end of your .bashrc file:

export DISPLAY=:0.0

Running test from the command line using maven mvn compile test , Chrome browser does not open when running TestNG test suite file using maven command on Ubuntu 14.04 Terminal - maven. Learn how to configure and run testNG using Maven build, we can run testNG Scripts and also testNG XML suite from Maven by using surefire plugin and configuring path in POM XML file.

I had this issue before while running on Jenkins by Maven command, I installed xvfb on Ubuntu then perfectly worked.

Install xvfb on Ubuntu:

sudo apt-get update
sudo apt-get install xvfb

Then you need to add these configurations to start it well:

Xvfb :1 -screen 0 800x600x16
DISPLAY=:1.0

And you can install it as Jenkins plugin: Follow this

venkateshwarant/UAT: Automation of User Acceptance , Chrome browser does not open when running TestNG test suite file using maven command on Ubuntu 14.04 Terminal. how to run maven test from command  Chrome browser does not open when running TestNG test suite file using maven command on Ubuntu 14.04 Terminal. When I execute my TestNG test suite file from Eclipse, it opens the Chrome browser and executes the tests properly. Since there is already some access issue with my machine, I have to use sudo with the command.

Finally solved my issue by dockerizing my tests.

I set the DISPLAY from the Dockerfile using ENV like,

ENV DISPLAY :99

Then I executed my run.sh file from Docker container using ENTRYPOINT to start Xvfb display:

Xvfb :99 -ac &

And executed my tests after the above line in same run.sh file:

mvn clean install -DsuiteXmlFile=testng.xml

And the output of the run is:

[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
Starting ChromeDriver 2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb) on port 13506
Only local connections are allowed.
May 31, 2018 5:44:12 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
31/05/2018 05:44:16 copy_tiles: allocating first_line at size 41

[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 17.688 s - in TestSuite
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0

Edit:

The Docker image can be found here.

Jenkins fails to start Chrome, WARNING] File encoding has not been set, using platform encoding Running test from the command line using maven mvn compile test # when we run our tests in parallel it does not work using the cmd line. Is running selenium tests in parallel not a bit dangerous as multiple browser instances has to  In this testng maven example, we will lean how to execute testng tests using maven build file pom.xml. This knowledge is important if you are planning to automate testng tests and making them part of project build process itself. Below are two tests which we have already written in two previous tutorials. System.out.println ("Before test

How To Build Headless Browser Testing and Integrate With Jenkins, The easiest way to install Oracle Java JDK 8 on Ubuntu is via a third party PPA… To add that your browser may automatically open the ".dmg" file which was just downloaded. To run automation via maven, you should install maven in your terminal. Suite testng xml file to consider for test execution --> <suiteXmlFiles>​  BrowserStack gives you instant access to our Selenium Grid of 2000+ real devices and desktop browsers. Running your Selenium tests with TestNG on BrowserStack is simple. This guide will help you: Run a sample Selenium Webdriver test with TestNG on BrowserStack; Setup your TestNG test suite to be able to test URLs in your internal network

Selenium Grid Tutorial: Hub & Node (with Example), I was able to resolve this error by doing the following steps :- 1.Stop the jenkins service with the command - sudo /etc/init.d/jenkins start. 2.Run Jenkins manually​  Get more done with the new Google Chrome. A more simple, secure, and faster web browser than ever, with Google’s smarts built-in. Download now. Google Chrome - Download the Fast, Secure Browser

How to Run Selenium Webdriver in chrome browser using drivers, How to implement headless browser testing and integration with Jenkins. This article will demonstrate the use of the new headless mode on Chrome and I will start a project using Maven and list the dependencies and plugins To build and run the test from the terminal we can type: (2017, April 14). Testing framework using Maven, TestNG and Webdriver We have set a goal to create a flexible and extendable automated testing framework, which should expand test coverage for as many LeaseWeb applications functionalities as possible.

Comments
  • just use "sudo mvn clean install" and run the test suite. It will run whole test suite.
  • That's what I had done. See the command in the question. The problem here is that browser doesn't open in order for selenium tests to execute.
  • I'll try this out and revert to you.
  • are you connected with multiple monitor or display to the machine. the possible values for display varies from 0 to 4. check with different value like export DISPLAY=:1 or export DISPLAY=:2, so on.
  • No, I'm working with my Dell Laptop with Ubuntu. Other values also not working.
  • I'll try it out and let you know if it works for me.
  • Can you please elaborate where to put this configuration? Currently I'm not looking to use Jenkins on my local.
  • The configurations should be executed using Terminal on Ubuntu. About the link of Jenkins plugin you can find the instructions when you scroll down, you have to install the plugin first then you will get the fields in the job configure part and build tab. Did I answer your question?