2014-02-13 5 views
0

현재 4 개의 Selenium/Maven 테스트가 포함 된 GitHub Repo가 있습니다. 나는 MVN 테스트를 통해 내 로컬 컴퓨터에 개별적으로 테스트를 실행할 수 있어요Jenkins가 Maven/Selenium GitHub 테스트를 실행하는 방법

나는 중 하나에 pom.xml 파일을 선택, 내 GitHub의 저장소를 당길 수있는 받는다는 프로젝트를 젠킨스 내 로컬 컴퓨터에 또한 실행 가지고 만든 test (P_ProfileChangeMavenTest)를 수행 한 다음 테스트를 내 목표로 실행하십시오.

젠킨스가 내 테스트를 실행하면 내 메이븐 프로젝트로 이동하기 시작하지만 파이어 폭스 브라우저를 사용하여 테스트와 상호 작용하지 않습니다.

의 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

오류에 따르면 "요소 보이지 않는 예외"라고 표시됩니다. google에서 이야기합시다. – sircapsalot

답변

0

우리가 발견 한 것은 testNg를 사용하여 테스트를 실행하는 것입니다. 우리는 우리가 실행하고자하는 다른 테스트와 XML 파일을 작성하고 우리는

가 MVN 테스트 -D TestNG를 = testname.xml

은 J 단위 테스트 프레임 워크가 더 통합 스타일의 테스트를위한 훌륭한 프레임 워크입니다 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

이것은 내 프로젝트를 완전히 바꾸는 것을 요구할 것이다. 내 주요 문제는 젠킨스가 웹 브라우저를 실행하지 않는다고 생각합니다. – user2683183

+0

@ user2683183 Selenium RC 또는 웹 드라이버를 사용하고 있습니까? –

0

jenkins 작업이 자체 클라이언트에서 실행 중입니다. 눈에 보이는 UI가 없으므로 테스트가 실패한 것입니다.

당신은 당신이

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

더 detaisl에 대한 Selenium Grid Wiki를 참조 원격 Webdriver 또는 셀레늄 그리드를 사용하는 코드를 테스트 변경해야

0

당신은 명령 줄을 사용하여 젠킨스를 시작하고 테스트를 실행하면 당신은 볼 수 있다면 브라우저에서 테스트 실행 중.

명령

는 명령 줄을 사용 젠킨스를 시작합니다 :이 도움이

희망을 jenkins.war -jar 자바.

0

관리자 권한으로 명령 프롬프트에서 실행 해보십시오. 나를 위해 일했습니다.

0

당신은 Windows의 경우 : 유형 "cmd를"

2) .Press는 Ctl + SHFT + 입력 (관리자로 엽니 다)

:

1) .Go 프롬프트를 명령하는 3). "Services.msc"를 입력하십시오.

4).Windows 서비스를 열고 "Jenkins"서비스를 선택하고 & 속성을 마우스 오른쪽 단추로 클릭 한 다음 "로그온"탭으로 이동하여 "로컬 시스템 계정"을 선택하고 "서비스와 데스크톱 상호 작용 허용"을 선택하십시오.

enter image description here

5) .Press OK.

6). 대화 상자가 열립니다. "이 컴퓨터에서 실행중인 프로그램이 메시지를 표시하려고합니다."창에서 "메시지보기"를 클릭하십시오.

enter image description here

이제 즐길 ... 동일한 시스템에서 실행되는 테스트를 볼 수 있습니다!

관련 문제