Created
August 9, 2022 23:39
-
-
Save bharathmuddada/0c76679f0c8855a587553d78369c6131 to your computer and use it in GitHub Desktop.
C# Selenium Fluent Wait Example
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
public class SeleniumFluentWait { | |
public static void Main(string[] args) | |
{ | |
new DriverManager().SetUpDriver(new ChromeConfig()); | |
var driver = new ChromeDriver(); | |
driver.Manage().Window.Maximize(); | |
driver.Navigate().GoToUrl("https://the-internet.herokuapp.com/dynamic_controls"); | |
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5)) | |
{ | |
PollingInterval = TimeSpan.FromSeconds(1), | |
}; | |
driver.FindElement(By.XPath("//button[contains(text(),'Remove')]")).Click(); | |
wait.Until(e => e.FindElement(By.XPath("//button[contains(text(),'Add')]"))); | |
Console.WriteLine(driver.FindElement(By.XPath("//p[@id='message']")).Text); | |
driver.FindElement(By.XPath("//button[contains(text(),'Add')]")).Click(); | |
driver.FindElement(By.XPath("//button[contains(text(),'Enable')]")).Click(); | |
var disable_button = wait.Until(e => e.FindElement(By.XPath("//button[contains(text(),'Disable')]"))); | |
disable_button.Click(); | |
driver.Quit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment