Read the catalog

Browser Maximize Forward, Back, Refresh Simulate mouse operation Kill windows browser process

Browser Maximize Forward, Back, Refresh

public static void testbrowser (webdriver driver) throws exception
    driver.get ("http://www.cnblogs.com/tankxiao");
    thread.sleep (5000);
    //Browser is maximized
    driver.manage (). window (). maximize ();
    driver.navigate (). to ("http://www.google.com");
    //refresh the browser
    driver.navigate (). refresh ();
    //browser back
    driver.navigate (). back ();
    //browser goes forward
    driver.navigate (). forward ();
    //browser exits
    driver.quit ();
public static void testscreenshot (webdriver driver) throws exception
    driver.get ("http://www.google.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.google.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");
  • Previous Analysis of TouchID fingerprint unlocking function developed by IOS
  • Next How to avoid creating unnecessary objects in Android