C# Selenium - Finding Element On Continuously Growing Page(C# Selenium - 在不断增长的页面上查找元素)
问题描述
我正在尝试找到比使用更好的方法:
I am trying to find a better way to do this than using:
js.ExecuteScript("scroll(0, 1300)");
我有一个页面,其中的数据可以更改,从而使页面高度的大小向上或向下变化.所以当我今天去点击一个位于 1500px 的元素时,明天它可能是 800px 并且找不到该元素并且测试用例失败.
I have a page where the data can change making the page height change up or down in size. So when I go to click on an element today that is located at 1500px, tomorrow it may be 800px and the element will not be found and the test case fails.
那么你们用什么来定位页面上大小发生变化的元素?
So what have you guys used to locate elements on a page where the size changes?
推荐答案
我开始使用下面的,似乎运行良好.感谢大家的帮助.
I started using the below which seems to be working nicely. Thanks for the help all.
IWebElement bio = SeleniumDriver.FindElement(By.XPath("path"));
Actions actions = new Actions(SeleniumDriver);
actions.MoveToElement(bio);
actions.Perform();
这篇关于C# Selenium - 在不断增长的页面上查找元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:C# Selenium - 在不断增长的页面上查找元素
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- 输入按键事件处理程序 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- C# 中多线程网络服务器的模式 2022-01-01
