Hi all,
I’m having an program that open ChromeBrowser on android device. If height of website is higher than window size then my program will take screenshot as each time screen is scroll.
Here is my code:
driver.get(“https://www.google.com”);
System.out.println(“Load done”);
Thread.sleep(3000);
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("Screenshot.jpg"));
Dimension size = driver.manage().window().getSize();
//x position set to mid-screen horizontally
int width = size.width/2;
//Starting y location set to 80% of the height (near bottom)
int startPoint = (int) (size.getHeight() * 0.95);
//Ending y location set to 20% of the height (near top)
int endPoint = (int) (size.getHeight() * 0.15);
new TouchAction(driver).press(PointOption.point(width, startPoint))
.waitAction(WaitOptions.waitOptions(Duration.ofMillis(1000))).moveTo(PointOption.point(width, endPoint)).release().perform();
File scrFile1 = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile1, new File("Screenshot1.jpg"));
Now I want to use a for loop to control time to scroll and take screenshot but I don’t know what is the condition for the loop to stop
My idea is get the page height / window height = total time to scroll. Problem here is how to get total webpage height in ChromeBrowser.
Anyone know an idea about this?
P/s sorry for my bad English