Java Selenium-Browser actions

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.