Browser Maximize forward, rewind, Refresh
public static void Testbrowser (webdriver Driver) throws Exception { driver.get ("http://www.cnblogs.com/ Tankxiao "); Thread.Sleep (the); Browser maximizes driver.manage (). window (). maximize (); Driver.navigate (). to ("http://www.baidu.com"); Refreshes the browser driver.navigate (). Refresh (); Browser fallback driver.navigate (). back (); Browser forward driver.navigate (). forward (); Browser exits driver.quit (); }
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"));
Simulating 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 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"); }
Java Selenium (10) Operation browser