0

Below is the code:

JavascriptExecutor jse = (JavascriptExecutor)driver;
WebElement blueray = driver.findElement(By.xpath("Xpath ID")]"));
jse.executeScript("scroll(0,250)", blueray);

Below is the error:

The method executeScript(String, Object[]) in the type JavascriptExecutor is not applicable for the arguments (String, WebElement)
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

2 Answers2

0

It is unclear for us exactly what you are trying to scroll but if your trying to scroll the window then use below code

jse.executeScript("window.scrollBy(0,250)");

If you want to view the blueRay web element in the page the you need to use below code

jse.executeScript("arguments[0].scrollIntoView()", blueRay);

If this does not help then please update your question with the exact issue that your facing and elaborate that issue so that we can assist you to resolve this issue quickly my friend :)

UnknownBeast
  • 979
  • 1
  • 6
  • 13
0

A bit of more details about your usecase would have helped us to construct a canonical answer.

If your usecase is to scroll() the window containing the DOM document, there is no better way other then using the either of the following Window Methods:

If your usecase is to scroll() an Element there is no better way other then using the Element Method:

  • Element.scrollIntoView()

    JavascriptExecutor jse = (JavascriptExecutor)driver;
    WebElement blueray = new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("Xpath ID")));
    jse.executeScript("arguments[0].scrollIntoView();", blueray);
    

You can find a relevant detailed discussion in scrollIntoView() method implementation


Reference

You can find a couple of relevant discussions in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352