This article introduces selenium to operate the browser
Reading Contents
Browser maximizes forward, backward, refresh
public static void testBrowser(WebDriver driver) throws Exception { driver.get("http://www.cnblogs.com/tankxiao"); Thread.sleep(5000); // Browser maximization driver.manage().window().maximize(); driver.navigate().to("http://www.baidu.com"); // Refresh the browser driver.navigate().refresh(); // Browser back driver.navigate().back(); // Browser forward driver.navigate().forward(); // The browser exits driver.quit(); } Screenshot operation
public static void testScreenShot(WebDriver driver) throws Exception { driver.get("http://www.baidu.com"); File srcFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(srcFile, new File("c://1.png")); }Simulate mouse operation
public static void rightClickMouse(WebDriver driver) { driver.get("http://www.baidu.com"); Actions action = new Actions(driver); action.contextClick(driver.findElement(By.id("kw"))).perform(); }Kill the Windows browser process
public static void killProcess() { // kill firefox WindowsUtils.tryToKillByName("firefox.exe"); // kill IE WindowsUtils.tryToKillByName("iexplore.exe"); // kill chrome WindowsUtils.tryToKillByName("chrome.exe"); }The above is the information on java selenium. We will continue to add it later. Thank you for your support for this site!