下面是代码片段并出现错误,如下所示:
The method executeScript(String, Object[]) in the type JavascriptExecutor is not applicable for the arguments (String)
代码片段:
public class ScrollPage {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\SeleniumWorkSpace\\chromeDriver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
System.out.println(driver);
driver.get("https://en.wikipedia.org/wiki/Main_Page");
driver.manage().window().maximize();
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("scroll(0,2500)");
}
}
我该如何解决这个问题?
最佳答案
尝试在不进行强制转换的情况下使用它
driver.executeScript("scroll(0,2500)");
关于尝试向下滚动页面时 JavascriptExecutor 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47810455/