forked from vikramvi/Selenium-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestDriver.java
More file actions
34 lines (25 loc) · 788 Bytes
/
testDriver.java
File metadata and controls
34 lines (25 loc) · 788 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
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.junit.Test;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class testDriver {
@Test
public void startSite(){
String url = "https://lovemusic.se";
WebDriver driver = new ChromeDriver();
driver.get(url);
String title = driver.getTitle();
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
try {
FileUtils.copyFile(scrFile, new File("screenshot.png"));
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("The title of " + url + " is: " + title);
driver.quit();
}
}