私は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);
}
}
}
他のクラス/テストのメソッドとして 'tc_newAccount()'を呼び出すかどうか確認してください。 – Guy
私は別のクラスからtc_newAccountを呼び出していません。それをインスタンス化して実行して、2回実行するかどうかを確認していますか? まだ良いアイデアは、私は試してみます。 – renG