c# - 为什么我的登录一直失败使用流畅的等待,尝试显式但没有奏效?
问题描述
我正在尝试登录我的浏览器,我尝试了显式等待,即 expectedconditions.elementisvisible 但这没有用,所以我走上了 fluentwaits 的路线。起初 fluent1 工作,然后第二次运行 fuentwait 没有工作。在第三次运行时,两者现在都不起作用
public void loginVT(IWebDriver driver)
{
_regRep = new UserRegRep(driver);
driver.Navigate().GoToUrl(_regRep.AppURL);
DefaultWait<IWebDriver> fluentWait = new DefaultWait<IWebDriver>(driver);
fluentWait.Timeout = TimeSpan.FromSeconds(30);
fluentWait.PollingInterval = TimeSpan.FromMilliseconds(3000);
fluentWait.IgnoreExceptionTypes(typeof(NoSuchElementException));
IWebElement searchResult = fluentWait.Until(x => x.FindElement(By.Id("Email")));
_regRep.Email.SendKeys("test@hotmail.com");
String strFile = System.IO.File.ReadAllText("password.csv");
_regRep.Password.SendKeys(strFile);
_regRep.LogInButton.Click();
//when the user icon is displayed, we have successfully logged in
DefaultWait<IWebDriver> fluentWait1 = new DefaultWait<IWebDriver>(driver);
fluentWait1.Timeout = TimeSpan.FromSeconds(30);
fluentWait1.PollingInterval = TimeSpan.FromMilliseconds(3000);
fluentWait1.IgnoreExceptionTypes(typeof(NoSuchElementException));
IWebElement searchResult1 = fluentWait1.Until(x => x.FindElement(By.XPath("//span[text()='User']")));
}
解决方案
推荐阅读
- node.js - 如何将数据从节点服务器传递到 ejs 标头
- html - CSS/HTML 响应式设计
- matplotlib - 如何控制databricks图形大小
- python - 如何从 configparser config.ini 文件中获取带有重音的特殊字符的字符串?
- javascript - 如果选中组合单选按钮,如何显示不同的图像?
- import - 从 Mysql DB 导入 Sqoop 需要大量时间才能完成
- php - XAMPP Virtualhost 不路由
- php - 我可以引用之前创建的函数吗?
- c - 使用递归函数将十进制转换为二进制
- css - 网格列响应宽度,但不大于不小于