The interface WebDriver represents the main interface for testing a web browser instance. If you are using Selenium 2 then it is highly recommended to use the WebDriver instance because of the benefits suggested in my previous posts.
This interface provides most of the basic requirements for testing a web application. Normally the testing of a web application requires either one or all of the following three functions:
Controling The browser
Selecting the WebElement
Debugging aids
The methods in this class provide solutions to the requirements in all the three categories mentioned above:
· Control of the browser:
get(): Loads the web page rendered by the URL string passed to this method. Similar results can be obtained by using WebDriver.Navigation.to(String)
navigate():Loads the web page rendered by the URL and access browser history
close(): Closes the ‘Current’ browser window
quite(): Closes ‘All’ browser windows associated with the webDriver instance
switchTo(): Changes current window and redirects all commands to the new ‘current’ window (example: switchTo().window(String))
manage(): Enables access to browser menu items, such as add cookies, logs etc
· Selection of WebElement:
findElement(): Returns the first ‘Webelement’ found
findElements(): Returns all the ‘WebElements’ found in the current web page
· Debugging aids:
getCurrentUrl(): Returns the current URL loaded in the browser session
getPageSource(): Returns HTML source of the current page loaded in the browser
getTitle(): Returns the title of current page
getWindowHandle(): Return unique string identifier of the current window in the driver instance
getWindowHandles(): Return identifiers of all the windows in the driver instance
0 Comments