Guest User

Untitled

a guest
Mar 24th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. public boolean test()throws Exception {}
  2.  
  3. WebDriver driver = new FirefoxDriver();
  4. driver.get("http://www.google.com/");
  5. File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
  6. // Now you can do whatever you need to do with it, for example copy somewhere
  7. FileUtils.copyFile(scrFile, new File("c:\tmp\screenshot.png"));
  8.  
  9. FileUtils.copyFile(scrFile, new File("c:\tmp\screenshot.png"));
  10.  
  11. import java.io.File;
  12. import org.openqa.selenium.OutputType;
  13. import org.openqa.selenium.TakesScreenshot;
  14. import org.apache.commons.io.FileUtils;
  15.  
  16.  
  17. public class Test {
  18. public void screenShot() {
  19. // driver is your WebDriver
  20. File screenshot = ((TakesScreenshot) driver)
  21. .getScreenshotAs(OutputType.FILE);
  22. FileUtils.copyFile(screenshot, new File(fileName));
  23.  
  24. }
  25.  
  26. WebDriver driver = new FirefoxDriver();
  27. driver.get("http://www.google.com/");
  28. File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
  29. // Now you can do whatever you need to do with it, for example copy somewhere
  30. FileUtils.copyFile(scrFile, new File("c:\tmp\screenshot.png"));
  31.  
  32. 1. Use WebElement.getLocation() to get the coordinates of the element
  33. or page section.
  34. 2. Use WebElement.getSize() to get the dimensions of that element
  35. or page section.
  36. 3. Use WebElement.getText() to verify contents of that element or section.
  37.  
  38. FirefoxDriver Driver = new FirefoxDriver();
  39. Driver.get("http://facebook.com/");
  40. File ScrFile=Driver.getScreenshotAs(OutputType.FILE);
  41. FileUtils.copyFile(ScrFile, new File("D://img.jpg"));
  42.  
  43. public void takeSnapShot(String i) throws Exception {
  44. /* Function : This function is used to take snapshot. It will take snapshot of entire page.
  45. Function Call : takeSnapShot("Screen_name");*/
  46. Shutterbug.shootPage(browser, ScrollStrategy.BOTH_DIRECTIONS).save(Path + i);
  47. }
Add Comment
Please, Sign In to add comment