For conditions 2 and 3 getting error Class cast exception Any solution

0 votes
public class ScrollingPage {

public static void main(String[] args) throws InterruptedException {

System.setProperty("webdriver.chrome.driver","C:\\Drivers\\chromedriver_win32\\chromedriver.exe");

WebDriver driver=new ChromeDriver();

driver.get("https://www.countries-ofthe-world.com/flags-of-the-world.html");

driver.manage().window().maximize();

JavascriptExecutor js=(JavascriptExecutor)driver;

//1. Scroll down page by pixel

// js.executeScript("window.scrollBy(0,1500)","");

// Long value=(Long)js.executeScript("return window.pageYOffset;");

// System.out.println("Number of pixels scrolled:"+value);

   //2. Scroll down page till element is visible

// WebElement flag=driver.findElement(By.xpath("//tbody/tr[91]/td[1]/img[1]"));

//

//  

//     js.executeScript("arguments[0].scrollIntoView();",flag);

// Long value=(Long)js.executeScript("return window.pageYOffset;");

// System.out.println("Number of pixels scrolled:"+value);

//

//3.End of the page

js.executeScript("window.scrollBy(0,document.body.scrollHeight)");

Long value=(Long)js.executeScript("return window.pageYOffset;");

    System.out.println("Number of pixels scrolled:"+value);

      Thread.sleep(5000);

      js.executeScript("window.scrollBy(0,-document.body.scrollHeight)");  //move to initial point

_________CONSOLE WINDOW______

Exception in thread "main" java.lang.ClassCastException: class java.lang.Double cannot be cast to class java.lang.Long (java.lang.Double and java.lang.Long are in module java.base of loader 'bootstrap') at .ScrollingPage.main(ScrollingPage.java:39)
Dec 25, 2020 in Selenium by faha
• 380 points
1,258 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Selenium

0 votes
1 answer

Error showing up, Unable to click the second page and get title. Any Solution?

Hi, @Faha, As you access the URL http://demo.automationtesting.in/Windows.html there ...READ MORE

answered Nov 25, 2020 in Selenium by Gitika
• 65,770 points
4,079 views
0 votes
1 answer

Sikuli file upload, even after writing the correct script getting error. Any solution?

Hey, @Faha, This error message... JavaScript error: resource://gre/modules/XULStore.jsm, line ...READ MORE

answered Dec 15, 2020 in Selenium by Gitika
• 65,770 points
2,543 views
0 votes
1 answer
0 votes
1 answer

Selecting xpath for with multiple conditions using Selenium and Python

Use the XPath in either of the following ways ...READ MORE

answered Jul 13, 2018 in Selenium by Samarpit
• 5,910 points
29,830 views
0 votes
1 answer
0 votes
1 answer

Getting runtime.cucumberexception for error parsing feature file

First check if there is any extra ...READ MORE

answered May 17, 2019 in Selenium by Frankie
• 9,830 points
28,999 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,763 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,184 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,258 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,896 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP