In next steps BufferedImage image = screenshot.getImage() code is used to get the merged image from all screenshots and ImageIO.write(image, "PNG", new File("write here path of location to save image" + "AShot_BBC_WebElement.png")) code used to save the screenshot at defined location with provided name.Īt last driver.quit() method to quit the Webdriver. ((JavascriptExecutor) driver).executeScript("$('#wrap header').hide() ") is used to hide the fixed header from webpage so it would not affect the view port while taking screenshot.Īfter that final Screenshot screenshot = new AShot().shootingStrategy(new ViewportPastingStrategy(1500)).takeScreenshot(driver, element) code is initialization of AShot utility to capture entire webpage where new ViewportPastingStrategy(1500) is for scrolling to next view port and takeScreenshot(driver, element) method is used to capture the screenshot for particular view port of webelement. WebElement element = driver.findElement(By.cssSelector("#hp_block_2")) is used to define a webelement from the webpage which we have to capture. automation import import java.io.File import import import import import .ChromeDriver import .ui.ExpectedCondition import .ui.WebDriverWait import ru. import ru. import ru.ViewportPastingStrategy public class AShotTestEntirePage )
0 Comments
Leave a Reply. |