Selenium testngxml+;Linux操作系统&x2B;詹金斯-->;什么也没发生
文件夹结构: 现在我的Jenkins托管在Linux机器上。因此,在我的基本文件中,将根据操作系统获取驱动程序。 代码如下:Selenium testngxml+;Linux操作系统&x2B;詹金斯-->;什么也没发生,selenium,jenkins,testng,Selenium,Jenkins,Testng,文件夹结构: 现在我的Jenkins托管在Linux机器上。因此,在我的基本文件中,将根据操作系统获取驱动程序。 代码如下: //Function to instantiate the WebDriver instance based on the Browser selected for Linux public WebDriver driverInsLinux(){ setbaseURL(); try { switch(getBrowser()){
//Function to instantiate the WebDriver instance based on the Browser selected for Linux
public WebDriver driverInsLinux(){
setbaseURL();
try {
switch(getBrowser()){
case "Chrome":
System.out.println("Inside Linux chrome driver function");
System.setProperty("webdriver.chrome.driver", "./Linux/Drivers/chromedriver");
System.out.println("driver launch successful");
driver=new ChromeDriver();
driver.get(baseurl);
break;
case "Internet Explorer":
System.setProperty("webdriver.internetexplorer.driver", "./Linux/Drivers/internetexplorerdriver.exe");
driver=new InternetExplorerDriver();
break;
case "Firefox":
driver=new FirefoxDriver();
break;
default:
//new PascalBaseClass();
}
} catch (IOException e) {
e.printStackTrace();
}
driver.get(baseurl);
driver.manage().timeouts().pageLoadTimeout(100, TimeUnit.SECONDS);
driver.manage().window().setSize(new Dimension(1366, 768));
driver.manage().window().maximize();
return driver;
}
//Function to instantiate the WebDriver based on the OS
public WebDriver driverIns(){
//driver =driverInsWindows();
switch (getOSName()) {
case "Windows": driver =driverInsWindows();
break;
case "Linux" : driver =driverInsLinux();
break;
case "MAC" : driver =driverInsMac();
break;
}
return driver;
}
//Function to get the OS Name
public String getOSName(){
oSName = System.getProperty("os.name");
if(oSName.contains("Windows"))
oSName= "Windows";
System.out.println(oSName);
return oSName;
}
现在是LoginPage.java
public class LoginPage extends Base{
/*Members of the current Test Class. The number varies from script
to script depending on the variables and verifications required*/
public WebDriver driver;
private String currentSitePath;
private String testCaseName=getClass().getName().substring(10);
ExtentTest parentTest;
//Function to Navigate to a particular URL inside CC
public void navigateToURL(WebDriver driver){
siteURL="";
this.driver.navigate().to(baseurl+siteURL);
}
@Test // Main Test Flow for the Script
public void executeScript() throws IOException{
System.out.println("*******************");
System.out.println("launching chrome browser");
parentTest= ReportGenerator.initializeParentTest(getClass().getName().substring(10),"Testing Login Page");
//Test Case Author assignment in Reports
ReportGenerator.assignAuthor(parentTest,"Garima");
//Setting up Browser Instance
this.driver=driverIns();
//Navigating to the required page in CC
navigateToURL(this.driver);
詹金斯控制台输出:
+ java -version
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-b10)
OpenJDK 64-Bit Server VM (build 25.171-b10, mixed mode)
+ uname -a
Linux jenkins2.spikes.eng 2.6.32-754.el6.x86_64 #1 SMP Tue Jun 19 21:26:04
UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
+ id
uid=498(jenkins) gid=498(jenkins) groups=498(jenkins)
context=system_u:system_r:unconfined_java_t:s0
+ cd CC_Regression
+ chmod -R 777 /var/lib/jenkins/workspace/testing/CC_Regression
+ pwd
/var/lib/jenkins/workspace/testing/CC_Regression
+ export
'CLASSPATH=/var/lib/jenkins/workspace/testing/CC_Regression/bin:
/var/lib/jenkins/workspace/testing/CC_Regression/lib/*'
+
CLASSPATH='/var/lib/jenkins/workspace/testing/CC_Regression/bin:
/var/lib/jenkins/workspace/testing/CC_Regression/lib/*'
+ java org.testng.TestNG testng.xml
[TestNG] Running:
/var/lib/jenkins/workspace/testing/CC_Regression/testng.xml
*******************
launching chrome browser
===============================================
Suite
Total tests run: 3, Failures: 3, Skips: 0
Configuration Failures: 1, Skips: 0
===============================================
Build step 'Execute shell' marked build as failure
Finished: FAILURE
注:
1) 对于Linux驱动程序:我已经从
下载完成后,提取文件并将其放置在Linx/Drivers文件夹中
2) 在上述函数中的不同步骤尝试了多文件syso。。但看起来像post System.out.println(“启动chrome浏览器”);破了 你的Linux机器上安装了chrome浏览器吗?它是物理机器还是虚拟机?它是哪个Linux发行版?您还可以附加给定错误的堆栈跟踪吗?如何获取错误的堆栈跟踪。。对不起,我是Jenkis的新手。在线路驱动器=新的ChromeDriver()之前;put system.out.println(“初始化驱动程序之前”);在线路put system.out.println(“初始化驱动程序之后”);然后再试一次。请回答我上面剩下的问题。System.out.println(“**********************”);System.out.println(“启动chrome浏览器”);parentTest=ReportGenerator.initializeParentTest(getClass().getName().substring(10),“测试登录页”);//Reports ReportGenerator.assignAuthor中的测试用例作者分配(parentTest,“Garima”);//设置浏览器实例System.out.println(“报表生成器完成”);this.driver=driverIns();甚至没有在控制台中获得“ReportGeneratorDone”文本。关于操作系统:它的CentOS。对于物理或虚拟机,我需要检查其他团队。因为我只有詹金斯的网址。将检查并恢复