Snippet for taking screenshot and saving it in specified path,
import java.io.File;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.apache.commons.io.FileUtils;
@Test
public void myTest() throws
Exception {
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
import java.io.File;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.apache.commons.io.FileUtils;
driver.get("http://www.google.com");
driver.findElement(By.name("q")).sendKeys("Selenium");File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("F:\\Screenshots\\webscreen1.png"));
}
No comments:
Post a Comment