This article describes the selenium Operation browser
Reading Table of Contents
- Browser maximize forward, back, refresh
- Screenshot operation
- 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 maximization
driver.manage (). window (). Maximize ();
Driver.navigate () to ("http://www.baidu.com");
Refresh Browser
driver.navigate (). Refresh ();
Browser backward
driver.navigate (). back ();
Browser forward
Driver.navigate (). Forward ();
Browser exit
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 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");
}
Above is the Java Selenium Data collation, follow-up continue to add, thank you for your support of this site!