C# Selenium - 在不断增长的页面上查找元素 [英] C# Selenium - Finding Element On Continuously Growing Page

查看:17
本文介绍了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 - 在不断增长的页面上查找元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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