Hi all, I am using aShot to take my webpage screenshot. My webpage is cropped into 2 images, instead of a whole page.
Below is my code:
WebDriver driver = DriverFactory.getWebDriver()
In test case:
CustomKeywords.‘conditionChecking.ValidationChecking.takeScreenshotwithVariable’(‘Invalid’, filepath,driver, ‘Cards - Card Profile Management - Add - Invalid Email’,data.internallyGetValue(‘Email’, count1) )
Keyword:
@Keyword
def takeScreenshotwithVariable(String message, Path filepath, WebDriver driver, String filename, def variable){
if(WebUI.verifyTextPresent(message, false, FailureHandling.OPTIONAL)){
Screenshot screenshot = new AShot().
coordsProvider(new WebDriverCoordsProvider()).
shootingStrategy(ShootingStrategies.viewportPasting(100)).
takeScreenshot(driver)
Path filepath2 =filepath.resolve(filename+' for '+variable+'.png')
ImageIO.write(screenshot.getImage(), "PNG", filepath2.toFile())
}else if(WebUI.verifyAlertPresent(1, FailureHandling.CONTINUE_ON_FAILURE)){
WebUI.acceptAlert()
Screenshot screenshot = new AShot().
coordsProvider(new WebDriverCoordsProvider()).
shootingStrategy(ShootingStrategies.viewportPasting(100)).
takeScreenshot(driver)
Path filepath2 =filepath.resolve(filename+' for '+variable+' Pop Up.png')
ImageIO.write(screenshot.getImage(), "PNG", filepath2.toFile())
}else{
Screenshot screenshot = new AShot().
coordsProvider(new WebDriverCoordsProvider()).
shootingStrategy(ShootingStrategies.viewportPasting(100)).
takeScreenshot(driver)
Path filepath2 =filepath.resolve(filename+' for '+variable+' No Validation.png')
ImageIO.write(screenshot.getImage(), "PNG", filepath2.toFile())
}
}
I also tried with Screenshot screenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(100))
.takeScreenshot(driver);
but it is not working too.
No error is prompt during execution.
Hoping for replies soon.