-
-
Save up1/d925783ea8e5f706f3bb58c3ce1ef7eb to your computer and use it in GitHub Desktop.
Selenium with C# (Waiting)
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
| webdriver.FindElement(By.Id("search_button")).Click(); | |
| Thread.Sleep(5000); | |
| IWebElement searchResult = webdriver.FindElement(By.Id("search_result")); |
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
| IWebDriver webdriver = new ChromeDriver(); | |
| webdriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); | |
| webdriver.FindElement(By.Id("search_button")).Click(); | |
| IWebElement searchResult = webdriver.FindElement(By.Id("search_result")); |
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
| WebDriverWait webdriverWait = new WebDriverWait(webdriver, TimeSpan.FromSeconds(5)); | |
| IWebElement searchResult = webdriverWait.Until(x=>x.FindElement(By.Id("search_result"))); |
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
| DefaultWait<IWebDriver> fluentWait = new DefaultWait<IWebDriver>(webdriver); | |
| fluentWait.Timeout = TimeSpan.FromSeconds(5); | |
| fluentWait.PollingInterval = TimeSpan.FromMilliseconds(250); | |
| fluentWait.IgnoreExceptionTypes(typeof(NoSuchElementException)); | |
| IWebElement searchResult = fluentWait.Until(x=>x.FindElement(By.Id("search_result"))); |
Thank you :)
Thank you :) that was useful
Thank you. It's really helpful
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great code here, thanks for sharing!