Running JUnit test by Ant throws Exception, but running by eclipse works fine

91 views
Skip to first unread message

Franz

unread,
Jul 25, 2011, 6:09:35 AM7/25/11
to webdriver
Hello,

I tried the Java-sample under http://seleniumhq.org/docs/03_webdriver.html
and saved it as a JUnit test.

When starting the test from eclipse as "Run As > JUnit test"
everything works fine. But when I start it from ant, a new window of
Firefox appears and after 45 seconds an Exception is thrown:

[junit] org.openqa.selenium.firefox.NotConnectedException: Unable
to connect to host 127.0.0.1 on port 7055 after 45000 ms
[junit] at
org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:
96)
[junit] at
org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:
142)
[junit] at
org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:
86)
[junit] at
org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:
121)
[junit] at
org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:
77)
[junit] at
de.test.samples.SimpleSampleTest.testSeleniumSample(SimpleSampleTest.java:
27)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
[junit] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
[junit] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
[junit] at java.lang.reflect.Method.invoke(Method.java:597)
[junit] at junit.framework.TestCase.runTest(TestCase.java:168)
[junit] at junit.framework.TestCase.runBare(TestCase.java:134)
[junit] at junit.framework.TestResult$1.protect(TestResult.java:
110)
[junit] at
junit.framework.TestResult.runProtected(TestResult.java:128)
[junit] at junit.framework.TestResult.run(TestResult.java:113)
[junit] at junit.framework.TestCase.run(TestCase.java:124)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:243)
[junit] at junit.framework.TestSuite.run(TestSuite.java:238)
[junit] at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:
518)
[junit] at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeInVM(JUnitTask.java:
1420)
[junit] at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:
848)
[junit] at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeOrQueue(JUnitTask.java:
1899)
[junit] at
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:
800)
[junit] at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
[junit] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
[junit] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
[junit] at java.lang.reflect.Method.invoke(Method.java:597)
[junit] at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:
106)
[junit] at org.apache.tools.ant.Task.perform(Task.java:348)
[junit] at org.apache.tools.ant.Target.execute(Target.java:390)
[junit] at org.apache.tools.ant.Target.performTasks(Target.java:
411)
[junit] at
org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
[junit] at
org.apache.tools.ant.Project.executeTarget(Project.java:1368)
[junit] at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:
41)
[junit] at
org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:
32)
[junit] at
org.apache.tools.ant.Project.executeTargets(Project.java:1251)
[junit] at
org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:
424)
[junit] at
org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:
138)
[junit] ------------- ---------------- ---------------
[junit] Testcase: testSeleniumSample took 48,921 sec
[junit] Caused an ERROR
[junit] Failed to connect to binary FirefoxBinary(C:\Program Files
\Mozilla Firefox\firefox.exe) on port 7055; process output follows:
[junit] System info: os.name: 'Windows 7', os.arch: 'x86',
os.version: '6.1', java.version: '1.6.0_17'
[junit] Driver info: driver.version: FirefoxDriver
[junit] org.openqa.selenium.WebDriverException: Failed to connect
to binary FirefoxBinary(C:\Program Files\Mozilla Firefox\firefox.exe)
on port 7055; process output follows:
[junit] System info: os.name: 'Windows 7', os.arch: 'x86',
os.version: '6.1', java.version: '1.6.0_17'
[junit] Driver info: driver.version: FirefoxDriver
[junit] at
org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:
108)
[junit] at
org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:
142)
[junit] at
org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:
86)
[junit] at
org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:
121)
[junit] at
org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:
77)
[junit] at
de.test.samples.SimpleSampleTest.testSeleniumSample(SimpleSampleTest.java:
27)
[junit] at
org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:
32)
[junit] at
org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:
424)
[junit] at
org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:
138)
[junit] Caused by:
org.openqa.selenium.firefox.NotConnectedException: Unable to connect
to host 127.0.0.1 on port 7055 after 45000 ms
[junit] at
org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:
96)


----- ANT_SNIPPET -----
<path id="build.classpath">
<pathelement location="${classes}" />
<pathelement location="C:\Program Files\eclipse\EclipseIndigo\plugins
\org.junit_4.8.2.v4_8_2_v20110321-1705\junit.jar" />
<pathelement location="C:\Program Files\eclipse\EclipseIndigo\plugins
\org.hamcrest.core_1.1.0.v20090501071000.jar" />
<fileset dir="../lib">
<include name="**/*.jar" />
<exclude name="**/junit.jar" />
</fileset>
</path>

<target name="allTest_formatter" description="runs all Unit tests">
<echo>Ant version: ${ant.version}</echo>
<junit fork="no" haltonfailure="no">
<test name="de.test.samples.SimpleSampleTest" />
<formatter type="plain" usefile="false" />
<classpath refid="build.classpath" />
</junit>
</target>
----- END OF ANT_SNIPPET -----

I am using Windows 7, Selenium 2.1, Ant 1.8.2 and Firefox 5.

Any ideas, why this exception occurs and how I can fix it?

Thnaks in advance,
Franz

Luke Inman-Semerau

unread,
Jul 25, 2011, 11:06:02 AM7/25/11
to webd...@googlegroups.com
It doesn't look like you have Se 2.1.0 in your classpath, but an older version. Check your jars in your classpath and make sure only 2.1.0 is there.

-Luke

> --
> You received this message because you are subscribed to the Google Groups "webdriver" group.
> To post to this group, send email to webd...@googlegroups.com.
> To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.
>

Franz

unread,
Jul 26, 2011, 1:45:22 AM7/26/11
to webdriver
Hi Luke,

that's it. I had older libraries of selenium in my lib-directory!

Now it works like a charm.

Thank you,
Franz
Reply all
Reply to author
Forward
0 new messages