enter image description here运行代码时在(ExecuteScript)中出错,请解决它
for (int second = 0; ; second++)
{
if (second >= 60)
{
break;
}
river.ExecuteScript("window.scrollBy(0,150)", "");
Thread.Sleep(1000);
}
答案 0 :(得分:0)
假设您要执行Javascript执行和您的" river"类型是WebDriver
使用此代码:
IJavaScriptExecutor jsExecutor = (IJavaScriptExecutor)river;
for (int second = 0; ; second++)
{
if (second >= 60)
{
break;
}
jsExecutor.ExecuteScript("window.scrollBy(0,150)", new object[] { element });
Thread.sleep(1000);
}
此处元素 - > IwebElement
希望这有帮助