Download Maven Dependency
<dependency>
<groupId>ru.yandex.qatools.ashot</groupId>
<artifactId>ashot</artifactId>
<version>1.4.12</version>
</dependency>
package com.neeraj.test.neeraj;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
import ru.yandex.qatools.ashot.AShot;
import ru.yandex.qatools.ashot.Screenshot;
import ru.yandex.qatools.ashot.coordinates.WebDriverCoordsProvider;
public class ok {
public static WebDriver driver = new ChromeDriver();
@Test
public void add1() throws InterruptedException, IOException{
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
driver.get("http://www.vpl.ca");
Screenshot totalviews = new AShot()
.coordsProvider(new WebDriverCoordsProvider()) //find coordinates with WebDriver API
.takeScreenshot(driver, driver.findElement(By.xpath("(//img[@title='Poet Laureate'])[2]")));
ImageIO.write(totalviews.getImage(), "PNG", new File("c:\\screenshots\\home21313.png"));
}
}
<dependency>
<groupId>ru.yandex.qatools.ashot</groupId>
<artifactId>ashot</artifactId>
<version>1.4.12</version>
</dependency>
package com.neeraj.test.neeraj;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
import ru.yandex.qatools.ashot.AShot;
import ru.yandex.qatools.ashot.Screenshot;
import ru.yandex.qatools.ashot.coordinates.WebDriverCoordsProvider;
public class ok {
public static WebDriver driver = new ChromeDriver();
@Test
public void add1() throws InterruptedException, IOException{
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
driver.get("http://www.vpl.ca");
Screenshot totalviews = new AShot()
.coordsProvider(new WebDriverCoordsProvider()) //find coordinates with WebDriver API
.takeScreenshot(driver, driver.findElement(By.xpath("(//img[@title='Poet Laureate'])[2]")));
ImageIO.write(totalviews.getImage(), "PNG", new File("c:\\screenshots\\home21313.png"));
}
}
No comments:
Post a Comment