How to set up an assertion to verify value of an element using Specflow?
Hi Noah Smith,
To set up an assertion to verify the value of an element using Specflow, please refer to the following code:
{
{
Console.WriteLine("Navigating to todos app.");
driver.Value.Navigate().GoToUrl("https://lambdatest.github.io/sample-todo-app/");
driver.Value.FindElement(By.Name("li4")).Click();
Console.WriteLine("Clicking Checkbox");
driver.Value.FindElement(By.Name("li5")).Click();
IList<IWebElement> elems = driver.Value.FindElements(By.ClassName("done-true"));
Assert.AreEqual(2, elems.Count);
Console.WriteLine("Entering Text");
driver.Value.FindElement(By.Id("sampletodotext")).SendKeys("Yey, Let's add it to list");
driver.Value.FindElement(By.Id("addbutton")).Click();
string spanText = driver.Value.FindElement(By.XPath("/html/body/div/div/div/ul/li[6]/span")).Text;
Assert.AreEqual("Yey, Let's add it to list", spanText);
}
}