我尝试滚动每次到达滚动条底部时加载行的div。现在,我正在通过"滚动"使用PgUp和PgDn的div的滚动条但我遇到了一个特定div不接受pgup / pgdown / home / end的问题。如何使用C#和Selenium拖放滚动条?
这是我的pgup和pgdn代码:
private void ScrollTable(int scrollcount, string pageDirection, string delay)
{
Actions actions = new Actions(DlkEnvironment.AutoDriver);
actions.MoveToElement(mTableElement);
for (int i = 1; i <= scrollcount; i++)
{
//if loading is not displayed/visible,
IsLoadingScreenIsDisplayed(delay);
//execute after waiting
switch (pageDirection.ToLower())
{
case "up":
actions.Click().SendKeys(Keys.PageUp).Perform();
break;
case "down":
actions.Click().SendKeys(Keys.PageDown).Perform();
break;
default:
throw new Exception("Invalid direction");
}
}
Thread.Sleep(1000);
}
答案 0 :(得分:0)
您可以使用SendKeys
而不将其发送到特定元素
private void ScrollTable(int scrollcount, string pageDirection, string delay)
{
Actions actions = new Actions(DlkEnvironment.AutoDriver);
for (int i = 1; i <= scrollcount; i++)
{
//if loading is not displayed/visible,
IsLoadingScreenIsDisplayed(delay);
//execute after waiting
switch (pageDirection.ToLower())
{
case "up":
actions.SendKeys(Keys.PageUp).Perform();
break;
case "down":
actions.SendKeys(Keys.PageDown).Perform();
break;
default:
throw new Exception("Invalid direction");
}
}
Thread.Sleep(1000);
}
答案 1 :(得分:0)
修复了使用JavaScript,scrollTop函数的问题。将scrollTop函数用于元素