VS 2015 topluluğunun kullanıyorum. Selenium C# test durumum her zaman iki kez çalışır. Test Örneği Gezgini penceresi, 1 test vakasının yürütüldüğünü, ancak geçiş sonucunun aynı test durumlarından ikiisinin yürütüldüğünü gösterir. Test veya çerçeve ile ilgili sorun nedir? Projem altında testcase (NunitDemo.cs) içeren bir Test Dosyası oluşturdum.Selenium WebDriver C# sınama durumu yanlışlıkla iki kez çalışıyor
Çözüm Gezgini penceresine bir ekran görüntüsü ekledim.
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);
}
}
}
Diğer sınıftan/testten bir yöntem olarak 'tc_newAccount()' ı çağırıp çalıştırmadığınızı kontrol edin. – Guy
Başka bir sınıftan tc_newAccount çağırmıyorum. Anlatmak ve iki kez çalışıp çalışmadığını görmek için mi çalıştırıyorsunuz? Hala iyi bir fikir, deneyeceğim. – renG