Implicit & Explicit Wait

Implicit wait is to inform IWebDriver to wait for certain amount of time for certain action in general.

driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);

SetScriptTimeout(), as well as ImplicitlyWait() and SetPageLoadTimeout() will be removed in future Selenium versions. In the source code you can see it has Obsolete annotation

[Obsolete("This method will be removed in a future version. Please set the AsynchronousJavaScript property instead.")]

Therefore you can change SetScriptTimeOut and PageLoadTimeout into following:

driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromMilliseconds(10);

Sleep Command
Rarely used, not recommended.


In explicit wait, system waits for certain amount of time when condition requirement is met.

var driver = new FirefoxDriver();
var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
Assert.AreEqual(true, wait.Until(d => d.ElementIsPresent(By.ClassName("c2"))));
Assert.AreEqual(true, wait.Until(d => !d.ElementIsPresent(By.ClassName("c2"))));

No comments:

Post a Comment

Setup VNC on Ubuntu 20.04

  sudo apt update sudo apt install xfce4 xfce4-goodies sudo apt install tigervnc-standalone-server sudo apt install tightvncserver vncserver...