我有一个运行jenkins服务器的Linux机器,并从git中提取脚本并开始执行
我有一台Windows pc,从中打开jenkins网址说xyz:8080并尝试从Windows框中执行脚本,但是它给出了以下错误。
使用phantomjs运行时也会发生同样的情况。
我现在正在尝试在Firefox中运行
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
1516800459520 geckodriver INFO geckodriver 0.19.1
1516800459526 geckodriver INFO Listening on 127.0.0.1:15327
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 32.526 s
[INFO] Finished at: 2018-01-24T08:28:00-05:00
[INFO] Final Memory: 28M/241M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project com.perfect.wp: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: There was an error in the forked process
[ERROR] org.testng.TestNGException:
[ERROR]
[ERROR] An error occurred while instantiating class buyer.testcases.solicitation.CreateSolicitation: null
[ERROR] at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:422)
[ERROR] at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:323)
[ERROR] at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:126)
[ERROR] at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:191)
[ERROR] at org.testng.TestClass.getInstances(TestClass.java:99)
[ERROR] at org.testng.TestClass.initTestClassesAndInstances(TestClass.java:85)
[ERROR] at org.testng.TestClass.init(TestClass.java:77)
[ERROR] at org.testng.TestClass.<init>(TestClass.java:42)
[ERROR] at org.testng.TestRunner.initMethods(TestRunner.java:423)
[ERROR] at org.testng.TestRunner.init(TestRunner.java:250)
[ERROR] at org.testng.TestRunner.init(TestRunner.java:220)
[ERROR] at org.testng.TestRunner.<init>(TestRunner.java:161)
[ERROR] at org.testng.SuiteRunner$DefaultTestRunnerFactory.newTestRunner(SuiteRunner.java:578)
[ERROR] at org.testng.SuiteRunner.init(SuiteRunner.java:185)
[ERROR] at org.testng.SuiteRunner.<init>(SuiteRunner.java:131)
[ERROR] at org.testng.TestNG.createSuiteRunner(TestNG.java:1383)
[ERROR] at org.testng.TestNG.createSuiteRunners(TestNG.java:1363)
[ERROR] at org.testng.TestNG.runSuitesLocally(TestNG.java:1217)
[ERROR] at org.testng.TestNG.runSuites(TestNG.java:1144)
[ERROR] at org.testng.TestNG.run(TestNG.java:1115)
[ERROR] at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:281)
[ERROR] at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75)
[ERROR] at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:121)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)
[ERROR] at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)
[ERROR] Caused by: java.lang.ExceptionInInitializerError
[ERROR] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[ERROR] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[ERROR] at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
[ERROR] at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:23)
[ERROR] at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:410)
[ERROR] ... 25 more
[ERROR] Caused by: org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:15327 [localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)
[ERROR] Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
[ERROR] System info: host: 'phfqwptestauto', ip: '10.5.1.175', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-504.30.3.el6.x86_64', java.version: '1.8.0_152'
[ERROR] Driver info: driver.version: PCDriver
[ERROR] at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:92)
[ERROR] at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
[ERROR] at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
[ERROR] at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
[ERROR] at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
[ERROR] at commonutils.pageobjects.utils.PCDriver.invokeBrowser(PCDriver.java:71)
[ERROR] at commonutils.pageobjects.utils.PCDriver.<clinit>(PCDriver.java:52)
[ERROR] ... 31 more
[ERROR] Caused by: org.apache.http.conn.HttpHostConnectException: Connect to localhost:15327 [localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)
[ERROR] at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159)
[ERROR] at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359)
[ERROR] at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
[ERROR] at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
[ERROR] at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
[ERROR] at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
[ERROR] at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
[ERROR] at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
[ERROR] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
[ERROR] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
[ERROR] at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:138)
[ERROR] at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:86)
[ERROR] at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:101)
[ERROR] at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
[ERROR] at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
[ERROR] at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
[ERROR] ... 37 more
[ERROR] Caused by: java.net.ConnectException: Connection refused (Connection refused)
[ERROR] at java.net.PlainSocketImpl.socketConnect(Native Method)
[ERROR] at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
[ERROR] at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
[ERROR] at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
[ERROR] at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
[ERROR] at java.net.Socket.connect(Socket.java:589)
[ERROR] at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75)
[ERROR] at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
[ERROR] ... 52 more
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
Build step 'Execute shell' marked build as failure
Sending e-mails to: wp.qa@perfect.com
Finished: FAILURE
PCDriver类别:
public class PCDriver implements WebDriver {
public static WebDriver driver;
// static log4jClass log = new log4jClass();
static {
PCDriver.invokeBrowser(ReadConfig.getInstance().getBrowser());
}
public static synchronized WebDriver invokeBrowser(String browser) {
switch (browser) {
case "firefox":
File pathBinary = new File("//home//chiefs//firefox//firefox");
FirefoxBinary firefoxBinary = new FirefoxBinary(pathBinary);
//DesiredCapabilities desired = DesiredCapabilities.firefox();
DesiredCapabilities cap = new DesiredCapabilities();
FirefoxOptions options = new FirefoxOptions();
cap.setCapability(FirefoxOptions.FIREFOX_OPTIONS, options.setBinary(firefoxBinary));
cap.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
System.setProperty("webdriver.gecko.driver",
ReadConfig.getInstance().getDriverPath().toString() + "geckodriver");
driver = new FirefoxDriver(options);
driver.get(ReadConfig.getInstance().getApplicationUrl());
// log.info("Browser Invoked");
break;
case "htmlunit":
DesiredCapabilities capHtml = DesiredCapabilities.htmlUnit();
capHtml.acceptInsecureCerts();
capHtml.setJavascriptEnabled(true);
/*
* System.setProperty("webdriver.gecko.driver",
* ReadConfig.getInstance().getDriverPath().toString() + "geckodriver.exe");
*/
driver = new HtmlUnitDriver(capHtml);
driver.get(ReadConfig.getInstance().getApplicationUrl());
// log.info("Browser Invoked");
break;
case "chrome":
DesiredCapabilities capChrome = DesiredCapabilities.chrome();
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("headless");
capChrome.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
capChrome.setJavascriptEnabled(true);
capChrome.acceptInsecureCerts();
System.setProperty("webdriver.chrome.driver",
ReadConfig.getInstance().getDriverPath().toString() + "chromedriver.exe");
driver = new ChromeDriver(capChrome);
driver.get(ReadConfig.getInstance().getApplicationUrl());
driver.manage().window().setSize(new Dimension(1440, 900));
break;
case "ie":
DesiredCapabilities capIE = new DesiredCapabilities();
capIE.setPlatform(Platform.WINDOWS);
capIE.acceptInsecureCerts();
capIE.setJavascriptEnabled(true);
capIE.setCapability("ignoreZoomSetting", true);
capIE.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
capIE.setCapability(InternetExplorerDriver.REQUIRE_WINDOW_FOCUS, false);
System.setProperty("webdriver.ie.driver",
ReadConfig.getInstance().getDriverPath().toString() + "IEDriverServer.exe");
driver = new InternetExplorerDriver(capIE);
driver.get(ReadConfig.getInstance().getApplicationUrl());
/*
* case "edge": DesiredCapabilities capEdge = DesiredCapabilities.edge();
* capEdge.setPlatform(Platform.WIN10); capEdge.acceptInsecureCerts();
* capEdge.setJavascriptEnabled(true); EdgeOptions options = new EdgeOptions();
* options.setPageLoadStrategy("eager");
* System.setProperty("webdriver.edge.driver",
* ReadConfig.getInstance().getDriverPath().toString() +
* "MicrosoftWebDriver.exe"); driver = new EdgeDriver(options);
*/
case "phantomjs":
DesiredCapabilities capPhantom =new DesiredCapabilities();
ArrayList<String> cliArgsCap = new ArrayList<String>();
cliArgsCap.add("--web-security=false");
cliArgsCap.add("--proxy=10.5.1.175:1024");
cliArgsCap.add("--ssl-protocol=any");
cliArgsCap.add("--ignore-ssl-errors=true");
cliArgsCap.add("--webdriver-loglevel=NONE");
cliArgsCap.add("--load-images=true"); //
capPhantom.setBrowserName("PhantomJs");
capPhantom.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
// capPhantom.setCapability("trustAllSSLCertificates", true);
capPhantom.setCapability("screen-resolution", "1280x1024");
capPhantom.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS,cliArgsCap);
capPhantom.setPlatform(Platform.LINUX);
capPhantom.setCapability("proxy", "10.5.1.175:1024");
capPhantom.setJavascriptEnabled(true);
capPhantom.setCapability("takesScreenshot", true);
capPhantom.setCapability("phantomjs.binary.path",ReadConfig.getInstance().getDriverPath().toString() + "phantomjs");
driver = new PhantomJSDriver(capPhantom);
driver.manage().timeouts()
.pageLoadTimeout(60, TimeUnit.SECONDS)
.implicitlyWait(60, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get(ReadConfig.getInstance().getApplicationUrl());
}
return driver;
}
public void close() {
driver.close();
}
public static WebDriver getDriver() {
return driver;
}
public static void acceptAlert() {
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.alertIsPresent());
driver.switchTo().alert().accept();
}
public static void dismissAlert() {
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.alertIsPresent());
driver.switchTo().alert().dismiss();
}
public static void waitForPageLoad() {
ExpectedCondition<Boolean> pageLoadCondition = new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver driver) {
return ((JavascriptExecutor) driver).executeScript("return document.readyState").equals("complete");
}
};
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(pageLoadCondition);
}
Pom.xml
project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.perfect</groupId>
<artifactId>com.perfect.wp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>webprocure</sourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<packaging>jar</packaging>
<name>com.perfect.wp</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.8.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>2.52.0</version>
</dependency>
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.2</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>com.codeborne</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.4.4</version>
</dependency>
</dependencies>
</project>
Jenkins Maven配置屏幕快照链接:
http://prntscr.com/i4wn8h
http://prntscr.com/i4wnj4
根据错误跟踪日志Maven
未能执行目标,如下所示:
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test (default-test) on project com.perfect.wp: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed: There was an error in the forked process
其结果org.testng.TestNGException
如下:
[ERROR] org.testng.TestNGException:
[ERROR]
[ERROR] An error occurred while instantiating class buyer.testcases.solicitation.CreateSolicitation: null
其结果org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException
如下:
org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connect to localhost:15327 [localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)
这是driver.version:
您的WebDriver
实例未被检测到的结果,如下所示:
[ERROR] Driver info: driver.version: PCDriver
造成这种情况的唯一原因是,按您的 开关(浏览器) ,你没有带设置的 系统属性 通过 System.setProperty()
一旦使用 switch (browser)
并定义 case "firefox"
等等,您需要进行System Property
如下设置:
case "firefox":
System.setProperty("webdriver.gecko.driver", "C:\\path\\to\\geckodriver.exe");
//configuration starts here
case "chrome":
System.setProperty("webdriver.chrome.driver", "C:\\path\\to\\chromedriver.exe");
//configuration starts here
case "ie":
System.setProperty("webdriver.ie.driver", "C:\\Utility\\BrowserDrivers\\IEDriverServer.exe");
//configuration starts here
case "phantomjs":
File path=new File("C:\\Utility\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe");
System.setProperty(“phantomjs.binary.path”,path.getAbsolutePath());
//configuration starts here
确保 /etc/hosts
您的 Linux Box
包含以下条目:
127.0.0.1 localhost.localdomain localhost
主要类别 JettyWebsocketServelet实现: 依赖性: 错误: JAVAnio。频道。组织上的ClosedChannel异常。日食码头。websocket。果心内部的WebSocketSessionState。org上的其中一个(WebSocketSessionState.java:174)。日食码头。websocket。果心内部的WebSocketCoreSession。org上
问题内容: 有时候(并非总是如此) “无法连接:sPort:0” 使用ServiceStack.Redis尝试从Redis获取值时出错。有人知道这意味着什么吗?我正在使用PooledRedisClientManager来获取客户端。 问题答案: 我相信您可以通过增加池的来解决此问题。我将其设置为非常低的时间(10毫秒),因此,在创建池时,某些客户端在短时间内无法连接。如果池返回了这些客户机之一,它
我得到的错误是: 线程“main”org . open QA . selenium . web drive异常:Java . net . connect异常:未能连接到localhost/0:0:0:0:0:0:1:14170生成信息:版本:“3.14.0”,修订版:“aacccce0”,时间:“2018-08-02T20:05:20.749Z”系统信息:主机:“D790-18”,IP:“192
问题内容: 我正在尝试使用android中的异步任务下载和存储图像,当单击下载按钮时出现以下错误。 WallpaperActivity.java Android目标Api 7.1.1 清单中添加的权限 android.permission.READ_EXTERNAL_STORAGE android.permission.WRITE_EXTERNAL_STORAGE 问题答案: 您需要为OS Mar
我正试图在android中使用异步任务下载和存储图像,当点击下载按钮时得到以下错误。 null Android.permission.write_external_storage
问题内容: 事实证明,计算结果为,尽管和是 不同的 实体。那么,您如何与? 有一个hack: 我可以做得更好吗? 问题答案: 在ECMAScript6中,除了区分正零和负零并计算为之外,其行为类似于。 Chrome 24支持。