首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >显式等待

显式等待
EN

Stack Overflow用户
提问于 2016-10-11 10:26:04
回答 4查看 19.9K关注 0票数 1

我在C#上使用selenium,我使用的是页面对象模块。现在我需要在显式等待中使用一个语法,因为我已经掌握了webelement。

代码语言:javascript
复制
[FindsBy(How = How.Id, Using = "Passwd")]
public IWebElement Password {get;set;}

[FindsBy(How = How.Id, Using = "signIn")]
public IWebElement Signin { get; set; }

我需要等到找到元素密码。

在使用此模块之前,我使用的是:

代码语言:javascript
复制
WebDriverWait wait = new WebDriverWait(driver.driver, TimeSpan.FromSeconds(Time));
wait.Until(ExpectedConditions.ElementExists(by));

现在我需要使用手头的元素。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2016-10-11 13:02:26

您应该尝试使用ExpectedConditions.ElementToBeClickable,它将接受IWebElement以及输入,并等待元素可见并启用如下:

代码语言:javascript
复制
WebDriverWait wait = new WebDriverWait(driver.driver, TimeSpan.FromSeconds(Time));
wait.Until(ExpectedConditions.ElementToBeClickable(Password));
票数 5
EN

Stack Overflow用户

发布于 2018-09-09 23:23:33

请检查一下这个是否有帮助

代码语言:javascript
复制
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

wait.Until(driver => Password.Displayed);
票数 1
EN

Stack Overflow用户

发布于 2016-10-11 10:34:28

添加显式等待并等待Password.Displayed变为真:

代码语言:javascript
复制
[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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39975256

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档