2016-04-08 12 views
3

私はVS 2015コミュニティを使用しています。私のセレンC#テストケースは常に2回実行されます。テストケースエクスプローラウィンドウには、1つのテストケースが実行されたことが示されていますが、パス結果には、同じテストケースの2つが実行されたことが示されています。 私のテストやフレームワークに何が問題なのですか? プロジェクトの下にテストケース(NunitDemo.cs)でテストファイルを作成しました。Selenium WebDriver C#テストケースが誤って2回実行されています

私はSolutions Explorerウィンドウにもスクリーンショットを添付しました。

using NUnit.Framework; 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using OpenQA.Selenium; 
using OpenQA.Selenium.Firefox; 


namespace DemoNunit 
{ 

    [TestFixture] 
    public class NunitDemo 
    { 
     private IWebDriver driver; 

     [Test] 
     public void tc_newAccount() 
     { 
      //open browser and navigate to aut 
      driver = new FirefoxDriver(); 
      driver.Navigate().GoToUrl("http://www.trainingrite.net"); 

      //click on signup button 
      driver.FindElement(By.CssSelector("input.submitbtn")).Click(); 


      //enter firstname, lastname, email, password 
      driver.FindElement(By.Id("ctl00_MainContent_txtFirstName")).Clear(); 
      driver.FindElement(By.Id("ctl00_MainContent_txtFirstName")).SendKeys("Ren"); 
      driver.FindElement(By.Id("ctl00_MainContent_txtLastName")).Clear(); 
      driver.FindElement(By.Id("ctl00_MainContent_txtLastName")).SendKeys("G"); 
      driver.FindElement(By.Id("ctl00_MainContent_txtEmail")).Clear(); 
      driver.FindElement(By.Id("ctl00_MainContent_txtEmail")).SendKeys("[email protected]"); 
      driver.FindElement(By.Id("ctl00_MainContent_txtPassword")).Clear(); 
      driver.FindElement(By.Id("ctl00_MainContent_txtPassword")).SendKeys("12345"); 
      driver.FindElement(By.Id("ctl00_MainContent_txtVerifyPassword")).Clear(); 
      driver.FindElement(By.Id("ctl00_MainContent_txtVerifyPassword")).SendKeys("12345"); 
      driver.FindElement(By.Id("ctl00_MainContent_txtHomePhone")).Clear(); 
      driver.FindElement(By.Id("ctl00_MainContent_txtHomePhone")).SendKeys("951-265-1234"); 
      driver.FindElement(By.Id("ctl00_MainContent_txtCellPhone")).Clear(); 
      driver.FindElement(By.Id("ctl00_MainContent_txtCellPhone")).SendKeys("760-855-1234"); 
      driver.FindElement(By.Id("ctl00_MainContent_txtInstructions")).Clear(); 
      driver.FindElement(By.Id("ctl00_MainContent_txtInstructions")).SendKeys("Running first selenium automation scripts in C#!"); 

      //click on submit button 
      driver.FindElement(By.Id("ctl00_MainContent_btnSubmit")).Click(); 


      //verify new customer is added successfully 
      Assert.AreEqual("Customer information added successfully", driver.FindElement(By.Id("ctl00_MainContent_lblTransactionResult")).Text); 

     } 
    } 
} 
+0

他のクラス/テストのメソッドとして 'tc_newAccount()'を呼び出すかどうか確認してください。 – Guy

+0

私は別のクラスからtc_newAccountを呼び出していません。それをインスタンス化して実行して、2回実行するかどうかを確認していますか? まだ良いアイデアは、私は試してみます。 – renG

答えて

1

VSにNunit 2.xおよび3.xテストアダプタがインストールされていますか。もしそうなら、それらの1つを取り外してテストを実行してみてください。

+0

私は2つのアダプターを持っていましたので、nunitテストアダプターを取り除き、frameworkinstalledでアダプターを残し、別のビルドを行いましたが、それでも2回実行されました。 – renG

+0

oops私は3つのアダプタを持っていましたので、nunit.testadaptorを削除し、**フレームワークをインストールした**アダプタを残しました。また、nUnitConsoleを削除して別のビルドを行いましたが、どうもありがとうございました。 – renG

+0

問題が解決した場合は、質問に回答としてマークしてください。 –

2

ドミトリーの答えに加えて、NUnitTestAdapterが拡張機能とNuGetパッケージを介してインストールされている場合、テストは2回実行されます。これは既知の問題です。

関連する問題