2014-02-13 49 views
0

目前我有一个包含4个Selenium/Maven测试的GitHub回购。我能够通过MVN测试,以我的本地计算机上单独运行各个测试如何让詹金斯运行我的Maven/Selenium GitHub测试

我有詹金斯也是我的本地机器上运行,并且创建了一个Maven项目来拉我的GitHub库,在的一个选择的pom.xml测试(P_ProfileChangeMavenTest),然后执行测试作为我的maven目标。

当詹金斯运行我的测试时,它开始通过我的maven项目,但不拉起Firefox浏览器与我的测试进行交互。

的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.test.profilechange</groupId> 
    <artifactId>Profile</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <name>Profile</name> 
    <description>PRofile</description> 
    <dependencies> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>4.11</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.seleniumhq.selenium</groupId> 
      <artifactId>selenium-java</artifactId> 
      <version>2.39.0</version> 
     </dependency> 
     <dependency> 
      <groupId>org.slf4j</groupId> 
      <artifactId>slf4j-api</artifactId> 
      <version>1.7.5</version> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.maven.surefire</groupId> 
      <artifactId>surefire</artifactId> 
      <version>2.16</version> 
      <type>pom</type> 
     </dependency> 
    </dependencies> 
</project> 

我是相当新的自动化,我试图确认一切正常,我的本地机器上的第一个发送这些测试与硒网格中的服务器上运行了。

所有的帮助将不胜感激,因为我需要尽快得到这个工作。

感谢先进!

+0

根据你的错误,它说“元素不可见异常”。让我们来谈谈谷歌。 – sircapsalot

回答

0

我发现我们的作品是使用testNg来运行测试。我们创建了一个我们要运行不同的测试XML文件,我们使用

MVN测试-D TestNG的= testname.xml

TestNG的是集成式的测试,一个伟大的框架,而歼单元测试框架更为单元测试而设计。

xml文件的示例将是这样的。

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> 
<suite name=" Report - Create New Report and Add Fields By Double Click and Filter by Right Clicking" parallel="none" verbose="1"> 
    <test verbose="1" name="is site available" preserve-order="true"> 
    <classes> 
     <class name="com.somecompany.qa.seleniumautomation.PucDD"> 
     <methods> 
      <include name="siteAvailable" /> 
     </methods> 
     </class> 
    </classes> 
    </test> 
    <test verbose="1" name="Login as 'admin' 'password'" preserve-order="true"> 
    <classes> 
     <class name="com.somecompany.qa.seleniumautomation.PucDD"> 
     <methods> 
      <parameter name="login.user" value="admin" /> 
      <parameter name="login.password" value="password" /> 
      <include name="login" /> 
     </methods> 
     </class> 
    </classes> 
    </test> 
    <test verbose="1" name="Create a new Report based on the provided data source" preserve-order="true"> 
    <classes> 
     <class name="com.somecompany.qa.seleniumautomation.Reports"> 
     <methods> 
      <parameter name="data.source.name" value="Orders" />  
      <include name="createNewReport"/> 
     </methods> 
     </class> 
    </classes> 
    </test> 
    <test verbose="1" name="Add the passed fields to the report by double clicking and add the passed filters by right clicking the field." preserve-order="true"> 
    <classes> 
     <class name="com.company.qa.seleniumautomation.Reports"> 
     <methods> 
      <parameter name="login.user" value="admin" /> 
      <parameter name="login.password" value="password" /> 
      <parameter name="fields" value="Customer Number,Customer Name,Order Date,Status,Shipped Date" /> 
      <parameter name="filterCriteria" value="Customer Number:lte=300,Customer Number:gte=150,Product Lines:contains=a" /> 
      <include name="addFilters"/> 
     </methods> 
     </class> 
    </classes> 
    </test> 
    <test verbose="1" name="Close the report" preserve-order="true"> 
    <classes> 
     <class name="com.company.qa.seleniumautomation.Reports"> 
     <methods> 
      <include name="close"/> 
     </methods> 
     </class> 
    </classes> 
    </test> 
</suite> 
+0

这需要我完全改变我的项目(我可能会考虑但不愿意这样做)。我认为我的主要问题是Jenkins未启动Web浏览器来运行其测试 – user2683183

+0

@ user2683183您是使用Selenium RC还是Web Driver? –

0

jenkins工作正在运行在它自己的客户端上。它没有可见的用户界面,这就是为什么你测试失败。

你应该改变你的测试代码使用远程的webdriver或硒电网

//need to start a selenium standalone server 
DesiredCapabilities capability = DesiredCapabilities.firefox(); 
WebDriver driver = new RemoteWebDriver(new URL("http://SERVER_ADDRESS:4444/wd/hub"), capability); 

Selenium Grid Wiki更多detaisl

0

如果你开始詹金斯使用命令行,如果你运行测试,然后就可以看到在浏览器上运行测试。

命令使用命令行启动詹金斯: Java的罐子jenkins.war

希望这有助于。

0

尝试从命令提示符以管理员身份运行它,为我工作。

0

如果您使用的是Windows:

1)。去命令提示符: 输入 “cmd”

2)。按CTL + Shift + Enter键(开作为管理员)

3).Type“Services.msc”

4)。它将打开Windows服务,选择“Jenkins”服务,右键点击&打开的属性,并转到“登录”选项卡并选择“本地系统帐户”并选择“允许服务与桌面交互”。

enter image description here

5)。按OK。

6)。将打开一个对话框。单击窗口中的“查看消息”“在此计算机上运行的程序试图显示消息”。

enter image description here

现在你可以看到在同一台机器上运行的测试...享受!