-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScreenshot.java
More file actions
38 lines (26 loc) · 1.32 KB
/
Screenshot.java
File metadata and controls
38 lines (26 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Screenshot {
public static void main(String[] args) throws IOException, Throwable {
// TODO Auto-generated method stub
System.setProperty("webdriver.gecko.driver", "D:\\Quastech\\Software\\geckodriver-v0.30.0-win64\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://orchidrepublic.com/blogs/news/types-yellow-flowers-meanings");
driver.manage().window().maximize();
TakesScreenshot scr = (TakesScreenshot)driver;
File scrfile = scr.getScreenshotAs(OutputType.FILE);
//for fileutil error you have to download "https://commons.apache.org/proper/commons-io/"
//click-> download_io.get
//unzip it and open eclipse, right click on project-> build path-> configure buildpath-> add external jars
//select all the available jars in commons io file and click apply
//enter file location to save screenshot and also give screenshot name
FileUtils.copyFile(scrfile, new File("D:\\Quastech\\Screenshot\\SS1.png"));
Thread.sleep(2000);
driver.close();
}
}