Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean test()throws Exception {}
- 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"));
- FileUtils.copyFile(scrFile, new File("c:\tmp\screenshot.png"));
- import java.io.File;
- import org.openqa.selenium.OutputType;
- import org.openqa.selenium.TakesScreenshot;
- import org.apache.commons.io.FileUtils;
- public class Test {
- public void screenShot() {
- // driver is your WebDriver
- File screenshot = ((TakesScreenshot) driver)
- .getScreenshotAs(OutputType.FILE);
- FileUtils.copyFile(screenshot, new File(fileName));
- }
- 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"));
- 1. Use WebElement.getLocation() to get the coordinates of the element
- or page section.
- 2. Use WebElement.getSize() to get the dimensions of that element
- or page section.
- 3. Use WebElement.getText() to verify contents of that element or section.
- FirefoxDriver Driver = new FirefoxDriver();
- Driver.get("http://facebook.com/");
- File ScrFile=Driver.getScreenshotAs(OutputType.FILE);
- FileUtils.copyFile(ScrFile, new File("D://img.jpg"));
- public void takeSnapShot(String i) throws Exception {
- /* Function : This function is used to take snapshot. It will take snapshot of entire page.
- Function Call : takeSnapShot("Screen_name");*/
- Shutterbug.shootPage(browser, ScrollStrategy.BOTH_DIRECTIONS).save(Path + i);
- }
Add Comment
Please, Sign In to add comment