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)

2 Answers 2

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 :)

Sign up to request clarification or add additional context in comments.

Comments

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:

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.