【发布时间】:2015-08-29 11:15:18
【问题描述】:
我对 Selenium 完全陌生,昨天开始使用它,我已经完成了我项目的第一部分,我真的很喜欢它的方式。
尽管我遇到了一个问题,目前我正在使用 Thread.Sleep 进行暂停,直到元素出现。有时会出现一些动画或者只是加载缓慢,我怎样才能让它等到元素出现然后与之交互?
例如:
LoginPageElements loginPage = new LoginPageElements();
loginPage.continueLink.Click();
Thread.Sleep(5000); //here it has to wait until the next page loads
ClickDailyBonusPopUp();
Driver.driver.Navigate().GoToUrl(.....);
Thread.Sleep(2000); //here it has to wait until a login form pops up
LoginFormElements loginForm = new LoginFormElements();
loginForm.userPasswordLogin.Click();
Thread.Sleep(2000); //here it has to wait until a different login form pops up
【问题讨论】: