简体   繁体   中英

Running Selenium tests from Jenkins by invoking Ant

I have an ant script that runs some Selenium tests. This works perfectly when run from Windows and also in a Putty bash terminal as Jenkins user, because the necessary vncserver is started up by the jenkins user previously and the DISPLAY variable is set to :43 . I am invoking the same ant script in Jenkins CI server. The DISPLAY environment variable is configured in Jenkins web interface to :43 too. The error message that I received is as below:

[junit] Setting selenium logging level to: FINE
[junit] org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7056 after 45000 ms. Firefox console output:
[junit] Xlib: connection to ":43.0" refused by server
[junit] Xlib: No protocol specified
[junit]
[junit] Error: cannot open display: :43
[junit]
[junit] at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:95)
[junit] at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:157) 
[junit] at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:93)
[junit] at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:136) [junit] at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:78)
[junit] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [junit] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) [junit] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) [junit] at java.lang.reflect.Constructor.newInstance(Constructor.java:513) [junit] at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)

This message is very similar to the one I received when vncserver was started with a different user then the one who started the tests. However this is not the case now as I have double checked that both the testrunner and the VNC started is jenkins .

This is a Solaris server, if any details are required to help me please ask.

I did not do anything differently but it got fixed a while ago, so it was a good approach. Magic just happens.. :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM