【发布时间】:2020-08-05 09:01:50
【问题描述】:
我们可以看到只有 18 行 当我滚动条时(在图 1 中用蓝色箭头显示)html 源代码 显示另外 18 行,因为对话框中只能容纳 18 行。 现在我想将栏滚动到最后并选择框的最后一行。 我该怎么做??
我尝试过使用
public void waitForElement()
{
//IJavaScriptExecutor je = (IJavaScriptExecutor)StaticDriver.driver;
//IWebElement element = StaticDriver.driver.FindElement(By.XPath("(//*[@class= 'slick-cell l0 r0 row_62 cid_col_0']//div)//following-sibling::div"));
//je.ExecuteScript("arguments[0].scrollIntoView(true);", element);
var element = StaticDriver.driver.FindElement(By.XPath("(//*[@class= 'slick-cell l0 r0 row_62 cid_col_0']//div)//following-sibling::div"));
Actions actions = new Actions(StaticDriver.driver);
actions.MoveToElement(element);
actions.Perform();
}
// that xpath is the element of last row.
但我收到错误Element count be found
如何滚动到最后一个元素并找到该元素?
最后一个元素的视图和html源代码是:
【问题讨论】:
-
对于滚动看看here,这是一个python示例,但我很支持有一个c#挂件。如果您仍然无法访问该项目,那么看看您的身边是否使用
iframe元素,而不是switch the context。
标签: c# selenium selenium-webdriver selenium-chromedriver