-
Notifications
You must be signed in to change notification settings - Fork 0
/
Screenshot4.java
30 lines (26 loc) · 1.06 KB
/
Screenshot4.java
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
package VINDVG1.Vinay27;
import java.io.File;
import java.util.Date;
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.chrome.ChromeDriver;
import io.github.bonigarcia.wdm.WebDriverManager;
public class Screenshot4 {
public static void main(String[] args) throws IOException {
Date currentdate =new Date();
System.out.println(currentdate);
String screenshotfilename=currentdate.toString().replace(" ","-").replace(":","-");
System.out.println(screenshotfilename);
WebDriverManager.chromedriver().setup();
WebDriver driver=new ChromeDriver();
driver.get("https://www.qatraininghub.com");
driver.manage().window().maximize();
File screenshotFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshotFile, new File(".//screenshot/"+screenshotfilename+".png"));
driver.close();
System.out.println("ScreenShotSuccess....!!");
}
}