Created
March 6, 2023 16:21
-
-
Save Baneeishaque/b1245578c944dbbe0a8cb516c09b93fa to your computer and use it in GitHub Desktop.
C# Selenium Demo
This file contains 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 OpenQA.Selenium.Chrome; | |
using OpenQA.Selenium; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
IWebDriver driver = new ChromeDriver(); | |
driver.Navigate().GoToUrl("https://www.selenium.dev/selenium/web/web-form.html"); | |
var title = driver.Title; | |
Assert.AreEqual("Web form", title); | |
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500); | |
var textBox = driver.FindElement(By.Name("my-text")); | |
var submitButton = driver.FindElement(By.TagName("button")); | |
textBox.SendKeys("Selenium"); | |
submitButton.Click(); | |
var message = driver.FindElement(By.Id("message")); | |
var value = message.Text; | |
Assert.AreEqual("Received!", value); | |
driver.Quit(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment