Can I reuse WebDriverWait in multiple sequential waits?

Cli*_* Ok 7 c# selenium selenium-webdriver webdriverwait

Given I need wait for one textbox appears, do something, and later I will need wait another Textbox. I want to know if this code is correct:

var waitForTextBox = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
waitForTextBox.Until(ExpectedConditions.ElementIsVisible(By.Id("txtFirstName"))).SendKeys("John");
waitForTextBox.Until(ExpectedConditions.ElementIsVisible(By.Id("txtLastName"))).SendKeys("Skeet");
Run Code Online (Sandbox Code Playgroud)

or if instead of reusing waitForTextBox, I will need do like this:

var waitForFirstName = new WebDriverWait(driver, TimeSpan.FromSeconds(30));
waitForFirstName.Until(ExpectedConditions.ElementIsVisible(By.Id("txtFirstName"))).SendKeys("John");

var waitForLastName = new WebDriverWait(driver, TimeSpan.FromSeconds(30));              
waitForLastName.Until(ExpectedConditions.ElementIsVisible(By.Id("txtLastName"))).SendKeys("Skeet");
Run Code Online (Sandbox Code Playgroud)

Gre*_*rdt 8

重用 WebDriverWait 对象进行多次“等待”是最好的。唯一需要不同 WebDriverWait 对象的情况是需要两个不同的超时时间。否则,WebDriverWait 保留的唯一状态是驱动程序、等待多长时间以及应忽略的异常类型列表。