Last active
September 15, 2022 10:55
-
-
Save SarahElson/0686913f8a854a8341fe5861a9cb4692 to your computer and use it in GitHub Desktop.
Implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using NUnit.Framework; | |
using OpenQA.Selenium; | |
using OpenQA.Selenium.Remote; | |
using System; | |
using System.Threading; | |
namespace SeleniumTutorial | |
{ | |
public class SeleniumTests | |
{ | |
private static IWebDriver driver; | |
public static string gridURL = "@hub.lambdatest.com/wd/hub"; | |
public static string LT_USERNAME = "LT_USERNAME"; // Add your LambdaTest username here | |
public static string LT_ACCESS_KEY = "LT_ACCESS_KEY"; // Add your LambdaTest access key here | |
[SetUp] | |
public void Setup() | |
{ | |
var desiredCapabilities = new DesiredCapabilities(); | |
desiredCapabilities.SetCapability("browserName", "Chrome"); | |
desiredCapabilities.SetCapability("platform", "Windows 11"); | |
desiredCapabilities.SetCapability("version", "101.0"); | |
desiredCapabilities.SetCapability("screenResolution", "1280x800"); | |
desiredCapabilities.SetCapability("user", LT_USERNAME); | |
desiredCapabilities.SetCapability("accessKey", LT_ACCESS_KEY); | |
desiredCapabilities.SetCapability("build", "Selenium C-Sharp"); | |
desiredCapabilities.SetCapability("name", "Selenium Test"); | |
driver = new RemoteWebDriver(new Uri("https://" + LT_USERNAME + ":" + LT_ACCESS_KEY + gridURL), desiredCapabilities, TimeSpan.FromSeconds(600)); | |
} | |
[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() | |
{ | |
Thread.Sleep(3000); | |
driver.Quit(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment