Skip to content

Instantly share code, notes, and snippets.

@SarahElson
Last active September 15, 2022 10:55
Show Gist options
  • Save SarahElson/40b7f87a73a3652d7b87820a2bb1ff85 to your computer and use it in GitHub Desktop.
Save SarahElson/40b7f87a73a3652d7b87820a2bb1ff85 to your computer and use it in GitHub Desktop.
Selenium C# test
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace SeleniumTutorial
{
public class SeleniumTests
{
private IWebDriver driver;
[SetUp]
public void Setup()
{
driver = new ChromeDriver();
}
[Test]
public void ValidateTheMessageIsDisplayed()
{
driver.Navigate().GoToUrl("https://www.lambdatest.com/selenium-playground/simple-form-demo");
driver.FindElement(By.Id("user-message")).SendKeys("LambdaTest rules");
driver.FindElement(By.Id("showInput")).Click();
Assert.IsTrue(driver.FindElement(By.Id("message")).Text.Equals("LambdaTest rules"), "The expected message was not displayed.");
}
[TearDown]
public void TearDown()
{
driver.Quit();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment