所以在我编译了我的selenium代码并运行file.class之后我得到了以下错误
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:112)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:119)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:218)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:207)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
at ClusterReloadAut.<clinit>(ClusterReloadAut.java:11)
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(/bin/firefox) on port 7055; process output follows:
Error: no display specified
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'
System info: host: 'bijenkins-ngwb.svl.ibm.com', ip: '9.30.4.102', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-327.10.1.el7.x86_64', java.version: '1.8.0_92'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:124)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:119)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:218)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:207)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
at ClusterReloadAut.<clinit>(ClusterReloadAut.java:11)
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:112)
... 7 more
Build step 'Execute shell' marked build as failure
Finished: FAILURE
我使用以下命令在Jenkins master上运行代码
javac -cp selenium-java-2.53.0.jar:selenium-java-2.53.0-srcs.jar:selenium-server-standalone-2.53.0.jar myfile.java
echo $USERNAME
echo $PASSWORD
echo $CLUSTERNUM
echo $IPADD
java -cp .:selenium-java-2.53.0.jar:selenium-java-2.53.0-srcs.jar:selenium-server-standalone-2.53.0.jar myfile $USERNAME $PASSWORD $CLUSTERNUM $IPADD
如果需要更多详细信息,请与我们联系
答案 0 :(得分:1)
使用此代码块启动Firefox驱动程序
System.setProperty("webdriver.gecko.driver", "C:\\your_directory\\geckodriver.exe");
DesiredCapabilities capabilities=DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver(capabilities);
driver.get("http://www.google.com");
driver.quit();