четвер, 29 січня 2015 р.

Selenium WebDriver: як просто і швидко зробити скріншот

Selenium WebDriver: як просто і швидко зробити скріншот




public class TestScreenShots {

protected WebDriver webDriver;

@Before
public void setup() {

webDriver = new FirefoxDriver();
}

@After
public void tearDown() {
webDriver.quit();
}

@Test
// Screenshot example
public void simpleWebDriverTest() throws IOException, InterruptedException {
webDriver.get("http://www.castle-way.com.ua");
File scrFile = ((TakesScreenshot) webDriver)
.getScreenshotAs(OutputType.FILE);
// Now you can do whatever you need to do with it, for example copy
// somewhere
FileUtils.copyFile(scrFile, new File("D:/screenshot.png"));
}

}

Немає коментарів:

Дописати коментар