Skip to content

Instantly share code, notes, and snippets.

@muditlambda
Created February 8, 2021 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muditlambda/d70b1b5c7b963066446f270db88a5bcc to your computer and use it in GitHub Desktop.
Save muditlambda/d70b1b5c7b963066446f270db88a5bcc to your computer and use it in GitHub Desktop.
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.IE;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using OpenQA.Selenium.Support.UI;
namespace Assert_Demo
{
class Assert_Demo_1
{
String test_url = "https://lambdatest.github.io/sample-todo-app/";
IWebDriver driver;
[SetUp]
public void start_Browser()
{
driver = new ChromeDriver();
driver.Manage().Window.Maximize();
}
[Test]
public void test_assert()
{
driver.Url = test_url;
String itemName = "Adding item to the list";
String url_title = "Sample page - lambdatest.com";
System.Threading.Thread.Sleep(4000);
Assert.That(url_title, Is.EqualTo(driver.Title));
// Click on First Check box
IWebElement firstCheckBox = driver.FindElement(By.Name("li1"));
firstCheckBox.Click();
// Click on Second Check box
IWebElement secondCheckBox = driver.FindElement(By.Name("li2"));
secondCheckBox.Click();
// Enter Item name
IWebElement textfield = driver.FindElement(By.Id("sampletodotext"));
textfield.SendKeys(itemName);
// Click on Add button
IWebElement addButton = driver.FindElement(By.Id("addbutton"));
addButton.Click();
// Verified Added Item name
IWebElement itemtext = driver.FindElement(By.XPath("/html/body/div/div/div/ul/li[6]/span"));
String getText = itemtext.Text;
// Check if the newly added item is present or not using
// Condition constraint (Boolean)
Assert.That((itemName.Contains(getText)), Is.True);
/* Perform wait to check the output */
System.Threading.Thread.Sleep(2000);
}
[TearDown]
public void close_Browser()
{
driver.Quit();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment