-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractClass.java
More file actions
43 lines (29 loc) · 985 Bytes
/
AbstractClass.java
File metadata and controls
43 lines (29 loc) · 985 Bytes
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
39
40
41
42
43
package com.cucumber;
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 AbstractClass {
protected static WebDriver driver;
protected WebDriver getDriver() {
if (driver == null) {
System.setProperty("webdriver.gecko.driver", "C:\\WebDrivers\\geckodriver.exe");
driver = new FirefoxDriver();
}
return driver;
}
public static void captureScreenShot(WebDriver ldriver) {
// Take screenshot and store as a file format
File src = ((TakesScreenshot) ldriver).getScreenshotAs(OutputType.FILE);
try {
FileUtils.copyFile(src, new File("C:/workspace/VehicleDetailsCSV/" + System.currentTimeMillis() + ".png"));
}
catch (IOException e)
{
System.out.println(e.getMessage());
}
}
}