Browser main operation method from interface Org.openqa.selenium.WebDriver, Implemented in the Org.openqa.selenium.remote.RemoteWebDriver class, and then the driver of different browsers inherit from Remotewebdriver
Webdriver diver = new Firefoxdriver (); Initializes a Firefox browser webdriver diver = new Internetexplorerdriver (); Initializes an IE browser webdriver diver = new Chromedriver (); Initialize a Chrome browser
Specify the path.
System.setproperty ("Webdriver.firefox.bin", "D:\\Program Files\\mozilla Firefox\\firefox.ex
-Specified browser
Firefoxprofile profile = new Firefoxprofile (New File ("\\firefox\\profiles\\*******.default")) Driver = new Firefoxdriver (profile);
-Open Close
String url = "Http://www.baidu.com"; Define Urldriver.get (URL);d river.navigate (). to (URL);d river.navigate (). Back ();d river.navigate (). Forward (); Driver.navigate (). Refresh ();d river.manage (). window (). Maximize ();//browser window maximizes driver.close ();//close Current page driver.quit () ;//Close all pages launched by selenium
--Returns the current page information
String title = Driver.gettitle (); Returns the ttilestring Currenturl = Driver.getcurrenturl () of the current page; Returns the current page of Urlgetwindowhandle ()//Returns the window handle of the current browser getwindowhandles ()//Returns all the window handles of the current browser getpagesource ()//returns the source of the current page
Java Selenium-Browser actions