Learning Resources
 

WebDriver API Commands and Operations


Selenium-WebDriver API Commands and Operations

Fetching a Page
The first thing you’re likely to want to do with WebDriver is navigate to a page. The normal way to do this is by calling “get”:
driver.get("https://www.google.com");


Locating UI Elements (WebElements)
Locating elements in WebDriver can be done on the WebDriver instance itself or on a WebElement. Each of the language bindings expose a “Find Element” and “Find Elements” method. The first returns a WebElement object otherwise it throws an exception. The latter returns a list of WebElements, it can return an empty list if no DOM elements match the query.


Moving Between Windows and Frames
Some web applications have many frames or multiple windows. WebDriver supports moving between named windows using the “switchTo” method:
driver.switchTo().window("windowName");

Popup Dialogs
Starting with Selenium 2.0 beta 1, there is built in support for handling popup dialog boxes. After you’ve triggered an action that opens a popup, you can access the alert with the following:
Alert alert = driver.switchTo().alert();