【发布时间】:2017-05-01 00:06:32
【问题描述】:
我想使用 Jenkins 运行在 TestNG 框架中编写的 Selenium 测试。
jenkins job(Freestyle项目)中配置的命令:
java -cp J:\taf\testng\*;J:\taf\workspace\TestNGExamples\bin;J:\automation\* org.testng.TestNG J:\taf\workspace\TestNGExamples\testng1.xml
注意:对于-cp argument,给出testng jar, test classes, and selenium jar的目录路径
当我运行作业(Build Now 选项)时,它在创建 Selenium 的会话活动时受到打击并给出错误。
注意:
从命令行运行时,相同的命令成功运行。
来自控制台输出的错误日志: (jenkins)
Started by user Naveen
Building in workspace C:\Program Files (x86)\Jenkins\workspace\TestNG Example
[TestNG Example] $ cmd /c call C:\Windows\TEMP\hudson2261889395366550414.bat
C:\Program Files (x86)\Jenkins\workspace\TestNG Example>java -cp J:\taf\testng\*;J:\taf\workspace\TestNGExamples\bin;J:\automation\* org.testng.TestNG J:\taf\workspace\TestNGExamples\testng1.xml
[TestNG] Running:
J:\taf\workspace\TestNGExamples\testng1.xml
1481801204206 geckodriver INFO Listening on 127.0.0.1:1387
Dec 15, 2016 4:56:44 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
1481801204827 mozprofile::profile INFO Using profile path C:\Windows\TEMP\rust_mozprofile.KDz9DWYpWQAM
1481801204829 geckodriver::marionette INFO Starting browser C:\Program Files\Mozilla Firefox\firefox.exe
1481801204831 geckodriver::marionette INFO Connecting to Marionette on localhost:7795
1481801206090 Marionette INFO Listening on port 7795
###!!! [Parent][MessageChannel] Error: (msgtype=0x2E007D,name=PBrowser::Msg_Destroy) Channel error: cannot send/recv
JavaScript error: resource://app/modules/ContentCrashHandlers.jsm, line 75: TypeError: browser.permanentKey is not a non-null object
###!!! [Parent][MessageChannel] Error: (msgtype=0x2E007D,name=PBrowser::Msg_Destroy) Channel error: cannot send/recv
Dec 15, 2016 4:56:47 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
###!!! [Parent][MessageChannel] Error: (msgtype=0x2E007D,name=PBrowser::Msg_Destroy) Channel error: cannot send/recv
下面是测试类:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class SeleniumTests {
@Test
public void test1(){
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.co.in");
driver.quit();
}
}
下面是testng1.xml:
<?xml version="1.0" encoding="UTF-8"?>
<suite name="Default suite">
<test verbose="2" name="Default test">
<classes>
<class name="SeleniumTests"/>
</classes>
</test> <!-- Default test -->
</suite> <!-- Default suite -->
环境详情:
- Jenkins - 2.19.4(作为 Windows 服务)
- Java - 1.8
- TestNG - 6.8.5
- 硒 - 3.0.1
- 火狐 - 51
- geckodriver - 0.11.1
- 操作系统 - Windows 7 - 64 位
【问题讨论】:
-
您使用哪种操作系统? Linux?窗户?
-
Windows 操作系统 - 7 - 64 位
-
对于 ChromDriver,没有观察到问题。但是对于 IEDriver,得到了
org.openqa.selenium.NoSuchWindowException: Unable to get browser (WARNING: The server did not provide any stacktrace information) -
您将 Jenkins 安装为 Windows 服务还是 servlet 容器?
-
Jenkins 作为 Windows 服务
标签: java selenium jenkins selenium-webdriver testng