我在C#上使用selenium,我使用的是页面对象模块。现在我需要在显式等待中使用一个语法,因为我已经掌握了webelement。
[FindsBy(How = How.Id, Using = "Passwd")]
public IWebElement Password {get;set;}
[FindsBy(How = How.Id, Using = "signIn")]
public IWebElement Signin { get; set; }我需要等到找到元素密码。
在使用此模块之前,我使用的是:
WebDriverWait wait = new WebDriverWait(driver.driver, TimeSpan.FromSeconds(Time));
wait.Until(ExpectedConditions.ElementExists(by));现在我需要使用手头的元素。
发布于 2016-10-11 13:02:26
您应该尝试使用ExpectedConditions.ElementToBeClickable,它将接受IWebElement以及输入,并等待元素可见并启用如下:
WebDriverWait wait = new WebDriverWait(driver.driver, TimeSpan.FromSeconds(Time));
wait.Until(ExpectedConditions.ElementToBeClickable(Password));发布于 2018-09-09 23:23:33
请检查一下这个是否有帮助
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until(driver => Password.Displayed);发布于 2016-10-11 10:34:28
添加显式等待并等待Password.Displayed变为真:
[FindsBy(How = How.Id, Using = "Passwd")]
public IWebElement Password {get;set;}
[FindsBy(How = How.Id, Using = "signIn")]
public IWebElement Signin { get; set; }
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
wait.Until(Password.Displayed);坦白地说,我在这里找到了答案:https://groups.google.com/forum/#!topic/webdriver/xdFsocNMSNc
https://stackoverflow.com/questions/39975256
复制相似问题