Problem

In Eclipse, when I run Selenium tests using TestNG, I get following exception

org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(/home/user/apps/firefox/firefox) on port 7055; process output follows: 
Error: no display specified

Build info: version: '2.46.0', revision: '61506a4624b13675f24581e453592342b7485d71', time: '2015-06-04 10:22:50'
System info: host: 'rupadhyay-kc', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.2.0-4-amd64', java.version: '1.7.0_80'
Driver info: driver.version: FirefoxDriver
	at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:132)
	at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:275)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:116)
	at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:220)
	at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:215)
	at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
	at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:124)
	at com.kuracloud.test.BasicTest.setUp(BasicTest.java:111)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
	at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:517)
	at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:213)
	at org.testng.internal.Invoker.invokeMethod(Invoker.java:601)
	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:845)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1153)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)
Caused by: 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

	at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:120)
	... 22 more

Solution-1

If you are using TestNG and the tests are failing to run in Eclipse, then try downgrading the Eclipse plugin for TestNG to older version from here: http://beust.com/eclipse-old/

In below example, downgrading Eclipse testng plugin from 6.9.10.20151181 to 6.9.5.201506120235 works.

Failed configurations

  • Eclipse: Luna Service Release 1 (4.4.1)
  • Eclipse TestNG plugin: 6.9.10.20151181
  • TestNG 6.9.9
  • Selenium 4.48.2
  • Firefox 42

Working configuration

  • Eclipse: Luna Service Release 1 (4.4.1)
  • Eclipse testng plugin: 6.9.5.201506120235
  • TestNG 6.9.9
  • Selenium 4.48.2
  • Firefox 42

How to downgrade Eclipse TestNG plugin

  1. Eclipse > Help > Installed softwares
  2. Select TestNG and click Uninstall
  3. Restart Eclipse
  4. Eclipse > Help > Install new software
  5. Choose a version of TestNG plugin from here: http://beust.com/eclipse-old/

Solution-2

Alternatively, if you are using maven, then run the project with mvn test. You can supply which .xml file (test) you want to run in pom.xml file as below.

         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.18.1</version>
            <configuration>
               <systemPropertyVariables>
               </systemPropertyVariables>
               <suiteXmlFiles>
                  <suiteXmlFile>testng.xml</suiteXmlFile>
               </suiteXmlFiles>
            </configuration>
         </plugin>