硒C#的webdriver:等到元素是present [英] Selenium c# Webdriver: Wait Until Element is Present

查看:199
本文介绍了硒C#的webdriver:等到元素是present的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要确保一个元素是present的webdriver的开始做的东西了。

我试图得到这样的工作:

  WebDriverWait等待=新WebDriverWait(驱动程序,时间跨度新(0,0,5));
wait.Until(By.Id(登录));

我主要挣扎如何设置了anynomous功能。


解决方案

另外,您可以使用隐式的等待:

  driver.Manage()超时()ImplicitlyWait(TimeSpan.FromSeconds(10));


  

这是隐含的等待是要告诉的webdriver轮询DOM一定
  试图找到一个元件,或者如果它们是元素时的时间量
  不能立即获得。默认设置为0。一旦设定,
  隐等待被设置为webdriver的对象实例的生命。


I want to make sure that an element is present before the webdriver starts doing stuff.

I'm trying to get something like this to work:

WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0,0,5));
wait.Until(By.Id("login"));

I'm mainly struggling how to setup up the anynomous function..

解决方案

Alternatively you can use implicit wait:

driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));

An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available. The default setting is 0. Once set, the implicit wait is set for the life of the WebDriver object instance.

这篇关于硒C#的webdriver:等到元素是present的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆