繁体   English   中英

Javascript 没有在使用 Selenium 的页面中执行

[英]Javascript not executing into a page using Selenium

我的 Javascript 没有使用 Selenium 执行到我的页面中。

我的代码:

    // Create a driver instance for chromedriver
    IWebDriver driver = new ChromeDriver();
    IJavaScriptExecutor js = (IJavaScriptExecutor)driver;

            driver.Manage().Window.Size = new Size(1100, 1100);
            driver.Navigate().GoToUrl("http://www.google.com/");
            js.ExecuteScript("function reloadScrollBars() { document.documentElement.style.overflow = 'auto';  document.body.scroll = 'yes';} function unloadScrollBars(){ document.documentElement.style.overflow = 'hidden'; document.body.scroll = 'no';}");

任何人都可以分享有关为什么它不执行的任何知识吗?

这有效

js.ExecuteScript("return document.body.style.overflow = 'hidden';");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM