Tag: Port drive opens Baidu window utils. exe app ROM PAC
Package prictce;
Import Java.io.File;
Import java.io.IOException;
Import Org.junit.After;
Import Org.junit.Before;
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;
Import Org.openqa.selenium.firefox.FirefoxDriver;
Import org.openqa.selenium.support.ui.WebDriverWait;
Import Com.sun.jna.platform.FileUtils;
public class Baidu {
public static void Main (string[] args) {
System.setproperty ("Webdriver.chrome.driver", "C:\\Program Files" (x86) \\Google\\Chrome\\Application\\ Chromedriver.exe "); Start-Up Drive
Webdriver driver= new Chromedriver (); Google's Drive
Driver.manage (). window (). Maximize (); Speaking window maximization
Driver.get ("http://www.baidu.com"); Open Baidu
File srcfile = ((takesscreenshot) driver). Getscreenshotas (Outputtype.file); The picture of the interception is returned as a file
try {
Org.apache.commons.io.FileUtils.copyFile (Srcfile, New File ("D:\\screenshot.png")); Save the obtained file using the CopyFile () method
} catch (IOException e) {
E.printstacktrace ();
}
Driver.quit ();
}
}
About Webdriver operations in selenium