C# Selenium 'ExpectedConditions 已过时' [英] C# Selenium 'ExpectedConditions is obsolete'

查看:53
本文介绍了C# Selenium 'ExpectedConditions 已过时'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试使用 ExpectedConditions 显式等待元素变为可见时,Visual Studio 警告我它现在已经过时并且很快将从 Selenium 中删除.

When trying to explicitly wait for an element to become visible using ExpectedConditions, Visual Studio warns me that it is now obsolete and will be removed from Selenium soon.

达到相同结果的当前/新方法是什么?

What is the current/new method to achieve the same result?

var wait = new WebDriverWait(driver, new TimeSpan(0, 0, 30));
var element = wait.Until(ExpectedConditions.ElementIsVisible(By.Id("content-section")));

推荐答案

如何使用最新版本的 Selenium 解决这个问题.

使用 NuGet,搜索 DotNetSeleniumExtras.WaitHelpers,然后将该命名空间导入到您的类中.现在你可以这样做:

How to resolve this with the latest version of Selenium.

Using NuGet, search for DotNetSeleniumExtras.WaitHelpers, and import that namespace into your class. Now you can do this:

var wait = new WebDriverWait(driver, new TimeSpan(0, 0, 30));
var element = wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.Id("content-section")));

IDE 中的警告将消失.

And the warning in the IDE will be gone.

这篇关于C# Selenium 'ExpectedConditions 已过时'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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