';OpenQA.Senium.IWebDriver';不包含';ExecuteScript';

本文关键字:包含 ExecuteScript Senium OpenQA IWebDriver | 更新日期: 2023-09-27 17:58:42

在此处输入图像描述运行代码时在(ExecuteScript)中出错,请解决

for (int second = 0; ; second++)
{
     if (second >= 60)
     {
        break;
     }
     river.ExecuteScript("window.scrollBy(0,150)", "");
     Thread.Sleep(1000);
}

';OpenQA.Senium.IWebDriver';不包含';ExecuteScript';

假设您想要执行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);
                }

here元素-->IwebElement

希望这能帮助