2017-12-06 13 views
0

私はJenkinsを使用してTestNGテストを実行しようとしています。それは私に構成の失敗とスキップを与えています。私はここでも同様の質問を他のウェブサイトでも読んだことがあるが、役に立たない。 これはenter link description hereを読んでalwaysRun = trueを試しましたが、これでも私の問題は解決しません。設定の失敗:1、スキップ:1

私はこのようなエラーを取得しています:

合計テストが実行さ:4、失敗:0、スキップ:2つの 設定エラー:1、スキップ:1つの

私のテストは、以下のようなものです:

を公開TestNGの結果の
import java.util.concurrent.TimeUnit; 

import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.WebElement; 
import org.openqa.selenium.chrome.ChromeDriver; 
import org.openqa.selenium.firefox.FirefoxDriver; 
import org.testng.Assert; 
import org.testng.annotations.AfterTest; 
import org.testng.annotations.BeforeTest; 
import org.testng.annotations.Parameters; 
import org.testng.annotations.Test; 

public class Search { 

    WebDriver driver; 

    @BeforeTest 
    @Parameters("browser") 

    public void crossBrowsers(String browser) throws InterruptedException { 

     if (browser.equalsIgnoreCase("Firefox")) { 

      driver = new FirefoxDriver(); 

     } 

     else if (browser.equalsIgnoreCase("Chrome")) { 

      System.setProperty("webdriver.chrome.driver", "C:\\mypath\\chromedriver.exe"); 

      driver = new ChromeDriver(); 

     } 

     driver.navigate().to("myaddress"); 
     driver.manage().window().maximize(); 
     driver.manage().timeouts().implicitlyWait(45, TimeUnit.SECONDS); 

    } 

@Test 
    public void methodA() throws InterruptedException { 
} 

@Test 
    public void methodB() throws InterruptedException { 
} 

@AfterTest 
    public void quitBrowsers() { 
     driver.quit(); 
    } 

スタックトレース:

<?xml version="1.0" encoding="UTF-8"?> 
<testng-results skipped="3" failed="0" total="6" passed="3"> 
    <reporter-output> 
    </reporter-output> 
    <suite name="Suite" duration-ms="28498" started-at="2017-12-07T09:51:27Z" finished-at="2017-12-07T09:51:55Z"> 
    <groups> 
    </groups> 
    <test name="FirefoxTest" duration-ms="11724" started-at="2017-12-07T09:51:27Z" finished-at="2017-12-07T09:51:38Z"> 
     <class name="scripts.CloseEachError"> 
     <test-method status="FAIL" signature="crossBrowsers(java.lang.String)[pri:0, instance:[email protected]]" name="crossBrowsers" is-config="true" duration-ms="0" started-at="2017-12-07T10:51:27Z" finished-at="2017-12-07T10:51:27Z"> 
      <params> 
      <param index="0"> 
       <value> 
       <![CDATA[Firefox]]> 
       </value> 
      </param> 
      </params> 
      <exception class="org.openqa.selenium.WebDriverException"> 
      <message> 
       <![CDATA[Process unexpectedly closed with status: 0 
Build info: version: '3.7.0', revision: '2321c73', time: '2017-11-02T22:12:07.291Z' 
System info: host: 'BC_LT35', ip: '192.168.26.71', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_151' 
Driver info: driver.version: FirefoxDriver 
remote stacktrace: stack backtrace: 
    0:   0x47e934 - <no info> 
    1:   0x47f0a3 - <no info> 
    2:   0x442649 - <no info> 
    3:   0x449cc3 - <no info> 
    4:   0x42a890 - <no info> 
    5:   0x406f5e - <no info> 
    6:   0x40cfc9 - <no info> 
    7:   0x6bef19 - <no info> 
    8:   0x420756 - <no info> 
    9:   0x6b96e0 - <no info> 
    10:  0x7ffdf4d01fe4 - BaseThreadInitThunk]]> 
      </message> 
      <full-stacktrace> 
       <![CDATA[org.openqa.selenium.WebDriverException: Process unexpectedly closed with status: 0 
Build info: version: '3.7.0', revision: '2321c73', time: '2017-11-02T22:12:07.291Z' 
System info: host: 'BC_LT35', ip: '192.168.26.71', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_151' 
Driver info: driver.version: FirefoxDriver 
remote stacktrace: stack backtrace: 
    0:   0x47e934 - <no info> 
    1:   0x47f0a3 - <no info> 
    2:   0x442649 - <no info> 
    3:   0x449cc3 - <no info> 
    4:   0x42a890 - <no info> 
    5:   0x406f5e - <no info> 
    6:   0x40cfc9 - <no info> 
    7:   0x6bef19 - <no info> 
    8:   0x420756 - <no info> 
    9:   0x6b96e0 - <no info> 
    10:  0x7ffdf4d01fe4 - BaseThreadInitThunk 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
    at java.lang.reflect.Constructor.newInstance(Unknown Source) 
    at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$new$0(W3CHandshakeResponse.java:57) 
    at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$getResponseFunction$2(W3CHandshakeResponse.java:104) 
    at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123) 
    at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) 
    at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source) 
    at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source) 
    at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source) 
    at java.util.stream.AbstractPipeline.copyInto(Unknown Source) 
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) 
    at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source) 
    at java.util.stream.AbstractPipeline.evaluate(Unknown Source) 
    at java.util.stream.ReferencePipeline.findFirst(Unknown Source) 
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126) 
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73) 
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142) 
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600) 
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219) 
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142) 
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120) 
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:98) 
    at scripts.CloseEachError.crossBrowsers(CloseEachError.java:29) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
    at java.lang.reflect.Method.invoke(Unknown Source) 
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85) 
    at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:510) 
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211) 
    at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138) 
    at org.testng.TestRunner.beforeRun(TestRunner.java:648) 
    at org.testng.TestRunner.run(TestRunner.java:616) 
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:359) 
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354) 
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312) 
    at org.testng.SuiteRunner.run(SuiteRunner.java:261) 
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) 
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) 
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215) 
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1140) 
    at org.testng.TestNG.run(TestNG.java:1048) 
    at org.testng.TestNG.privateMain(TestNG.java:1355) 
    at org.testng.TestNG.main(TestNG.java:1324) 
]]> 
      </full-stacktrace> 
      </exception> <!-- org.openqa.selenium.WebDriverException --> 
      <reporter-output> 
      </reporter-output> 
     </test-method> <!-- crossBrowsers --> 
     <test-method status="SKIP" signature="clkDropDownBtn()[pri:0, instance:[email protected]]" name="clkDropDownBtn" duration-ms="0" started-at="2017-12-07T10:51:38Z" finished-at="2017-12-07T10:51:38Z"> 
      <reporter-output> 
      </reporter-output> 
     </test-method> <!-- clkDropDownBtn --> 
     <test-method status="SKIP" signature="closeEachErr()[pri:0, instance:[email protected]]" name="closeEachErr" duration-ms="0" started-at="2017-12-07T10:51:38Z" finished-at="2017-12-07T10:51:38Z"> 
      <reporter-output> 
      </reporter-output> 
     </test-method> <!-- closeEachErr --> 
     <test-method status="SKIP" signature="VerifyErrList()[pri:0, instance:[email protected]]" name="VerifyErrList" duration-ms="0" started-at="2017-12-07T10:51:38Z" finished-at="2017-12-07T10:51:38Z"> 
      <reporter-output> 
      </reporter-output> 
     </test-method> <!-- VerifyErrList --> 
     <test-method status="SKIP" signature="quitBrowsers()[pri:0, instance:[email protected]]" name="quitBrowsers" is-config="true" duration-ms="0" started-at="2017-12-07T10:51:38Z" finished-at="2017-12-07T10:51:38Z"> 
      <reporter-output> 
      </reporter-output> 
     </test-method> <!-- quitBrowsers --> 
     </class> <!-- scripts.CloseEachError --> 
    </test> <!-- FirefoxTest --> 
    <test name="ChromeTest" duration-ms="16743" started-at="2017-12-07T09:51:38Z" finished-at="2017-12-07T09:51:55Z"> 
     <class name="scripts.CloseEachError"> 
     <test-method status="PASS" signature="crossBrowsers(java.lang.String)[pri:0, instance:[email protected]]" name="crossBrowsers" is-config="true" duration-ms="3587" started-at="2017-12-07T10:51:38Z" finished-at="2017-12-07T10:51:42Z"> 
      <params> 
      <param index="0"> 
       <value> 
       <![CDATA[Chrome]]> 
       </value> 
      </param> 
      </params> 
      <reporter-output> 
      </reporter-output> 
     </test-method> <!-- crossBrowsers --> 
     <test-method status="PASS" signature="VerifyErrList()[pri:0, instance:[email protected]]" name="VerifyErrList" duration-ms="41" started-at="2017-12-07T10:51:42Z" finished-at="2017-12-07T10:51:42Z"> 
      <reporter-output> 
      </reporter-output> 
     </test-method> <!-- VerifyErrList --> 
     <test-method status="PASS" signature="clkDropDownBtn()[pri:0, instance:[email protected]]" name="clkDropDownBtn" duration-ms="12242" started-at="2017-12-07T10:51:42Z" finished-at="2017-12-07T10:51:54Z"> 
      <reporter-output> 
      </reporter-output> 
     </test-method> <!-- clkDropDownBtn --> 
     <test-method status="PASS" signature="closeEachErr()[pri:0, instance:[email protected]]" name="closeEachErr" duration-ms="295" started-at="2017-12-07T10:51:54Z" finished-at="2017-12-07T10:51:54Z"> 
      <reporter-output> 
      </reporter-output> 
     </test-method> <!-- closeEachErr --> 
     <test-method status="PASS" signature="quitBrowsers()[pri:0, instance:[email protected]]" name="quitBrowsers" is-config="true" duration-ms="577" started-at="2017-12-07T10:51:54Z" finished-at="2017-12-07T10:51:55Z"> 
      <reporter-output> 
      </reporter-output> 
     </test-method> <!-- quitBrowsers --> 
     </class> <!-- scripts.CloseEachError --> 
    </test> <!-- ChromeTest --> 
    </suite> <!-- Suite --> 
</testng-results> 

XMLファイル:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> 
<suite name="Suite"> 

    <test name="FirefoxTest"> 
    <parameter name="browser" value="Firefox"></parameter> 
    <classes> 
     <class name="scripts.testJenkins"/> 
    </classes> 
    </test> <!-- SearchTest --> 

     <test name="ChromeTest"> 
    <parameter name="browser" value="Chrome"></parameter> 
    <classes> 
     <class name="scripts.testJenkins"/> 
    </classes> 
    </test> 


</suite> <!-- Suite --> 
+0

Jenkinsで使用しているコマンドは何ですか?また、エラースタックトレースを添付してください。 –

+0

Execute Windows Batch Commandにバットファイル名を与えています。 –

+0

publish TestNGの結果を使用してスタックトレースを追加しています。 –

答えて

0

あなたは、次のコードを実行してみここ

driver.navigate().to("www.example.net"); 

をURLを渡す必要があります。

import java.util.concurrent.TimeUnit; 
import org.openqa.selenium.By; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.WebElement; 
import org.openqa.selenium.chrome.ChromeDriver; 
import org.openqa.selenium.firefox.FirefoxDriver; 
import org.testng.Assert; 
import org.testng.annotations.AfterTest; 
import org.testng.annotations.BeforeTest; 
import org.testng.annotations.Parameters; 
import org.testng.annotations.Test; 

public class Search { 

    WebDriver driver; 

    @BeforeTest 
    @Parameters("browser") 

    public void crossBrowsers(String browser) throws InterruptedException { 

     if (browser.equalsIgnoreCase("Firefox")) { 

      System.setProperty("webdriver.gecko.driver", "C:\\mypath\\chromedriver.exe"); 

      driver = new FirefoxDriver(); 

     } 

     else if (browser.equalsIgnoreCase("Chrome")) { 

      System.setProperty("webdriver.chrome.driver", "C:\\mypath\\chromedriver.exe"); 

      driver = new ChromeDriver(); 

     } 

     driver.navigate().to("www.example.net"); 
     driver.manage().window().maximize(); 
     driver.manage().timeouts().implicitlyWait(45, TimeUnit.SECONDS); 

    } 

@Test 
    public void methodA() throws InterruptedException { 
} 

@Test 
    public void methodB() throws InterruptedException { 
} 

@AfterTest 
    public void quitBrowsers() { 
     driver.quit(); 
    } 
} 
+6

あなたの(関連のない)ホームページのアドレスを投稿することはスパムとみなされます。住所に関連する資料が含まれている場合は、そのサイトにリンクすることができますが、それがあなたのサイトであることを明示的に述べる必要があります。 – BDL

+0

ええ、関連情報があります – SoftwareTestingMaterial

0

私はジェンキンをアンインストールして、戦争で再びインストールしましたが、うまくいきました。

関連する問題