21 Aralık 2017 Perşembe

Selenium TakesScreenshot Arayüzü

getScreenShotAs metodu
Örnek
Şöyle yaparız.
WebDriver driver = new FirefoxDriver();

driver.get("http://www.google.com/");

File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

// Now you can do whatever you need to do with it, for example copy somewhere
FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));
Örnek
Şöyle yaparız.
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
driver.manage().window().maximize();

TakesScreenshot scrShot =((TakesScreenshot)driver);

//Call getScreenshotAs method to create image file
File srcFile = scrShot.getScreenshotAs(OutputType.FILE);

//Move image file to new destination
File destFile = new File("C:\\shot.png");

//Copy file at destination
FileUtils.copyFile(srcFile,destFile);

Hiç yorum yok:

Yorum Gönder