C# Selenium 'ExpectedConditions 已过时'

编程入门 行业动态 更新时间:2024-10-23 08:26:56
本文介绍了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 已过时'

本文发布于:2023-11-14 10:12:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1586937.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Selenium   ExpectedConditions

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!