1.
Browser Management Methods
These methods are used to control browser actions such as opening,
navigating, and closing.
Method Description Example
get(String Opens the specified URL in [Link]("https://
URL) the browser. [Link]");
Returns the title of the
getTitle() String title = [Link]();
current page as a String.
getCurrentUr Returns the URL of the String url =
l() current page. [Link]();
getPageSour Returns the HTML source of String pageSource =
ce() the current page. [Link]();
Closes the current browser
close() [Link]();
window.
Closes all the browser
quit() windows opened by the [Link]();
WebDriver instance.
2. Navigation Methods
Used for navigating through browser history or to a specific URL.
Method Description Example
navigate().to(Strin Navigates to a specified [Link]().to("https://
g URL) URL. [Link]");
Moves to the previous
navigate().back() page in the browser [Link]().back();
history.
navigate().forward Moves to the next page in
[Link]().forward();
() the browser history.
navigate().refresh( Refreshes the current
[Link]().refresh();
) page.
7. Cookies Management Methods
Manage browser cookies.
Descriptio
Method Example
n
Retrieves all
cookies in Set<Cookie> cookies =
manage().getCookies()
the current [Link]().getCookies();
session.
Adds a new
manage().addCookie(Cookie [Link]().addCookie(new
cookie to
cookie) Cookie("key", "value"));
the browser.
Deletes a
manage().deleteCookieNamed(S specific [Link]().deleteCookieNamed("
tring name) cookie by key");
name.
Deletes all
manage().deleteAllCookies() [Link]().deleteAllCookies();
cookies.
4. Window and Frame Management Methods
Control browser windows, tabs, and frames.
Method Description Example
Returns the handle
String handle =
getWindowHandle() (ID) of the current
[Link]();
window.
Returns a set of
Set<String> handles =
getWindowHandles() handles for all open
[Link]();
browser windows.
Switches to a specific
switchTo().window(String
browser window [Link]().window(handle);
handle)
using its handle.
switchTo().frame(int Switches to a frame
[Link]().frame(0);
index) using its index.
switchTo().frame(String Switches to a frame [Link]().frame("frameNam
nameOrId) using its name or ID. e");
Switches back to the
switchTo().defaultConten
main document from [Link]().defaultContent();
t()
a frame.
5. Wait and Synchronization Methods
Used to handle dynamic content or delays in page loading.
Descri
Method Example
ption
Sets a
global
wait
time
manage().timeouts( [Link]().timeouts().implicitlyWait(10,
for
).implicitlyWait() [Link]);
locatin
g
eleme
nts.
Waits
for
specifi
c
new WebDriverWait(driver,
Explicit Wait (via conditi
[Link](10)).until([Link]
WebDriverWait) ons to
lityOfElementLocated([Link]("elementId")));
be met
before
procee
ding.
6. Alerts Management Methods
Used for handling browser alerts or pop-ups.
Method Description Example
Alert alert =
switchTo().alert() Switches the context to the alert.
[Link]().alert();
accept() Accepts the alert (OK button). [Link]();
Dismisses the alert (Cancel
dismiss() [Link]();
button).
Retrieves the text displayed in the String alertText =
getText()
alert. [Link]();
sendKeys(String Sends text to the alert (if input is [Link]("Sample
text) allowed). input");
3. Element Interaction Methods
Used to locate and interact with web elements like clicking, typing, or retrieving
attributes.
Method Description Example
WebElement element =
findElement(By Locates a single web
[Link]([Link]("username"))
locator) element on the page.
;
Locates multiple web
findElements(By List<WebElement> elements =
elements on the page
locator) [Link]([Link]("a"));
and returns a list.
sendKeys(String Types the specified value
[Link]("Hello");
value) into an input field.
Clicks on a web element,
click() [Link]();
such as a button or link.
Retrieves the visible text
getText() String text = [Link]();
of a web element.
Retrieves the value of a
getAttribute(String String value =
specified attribute from a
attributeName) [Link]("href");
web element.
Retrieves the CSS
getCssValue(String String color =
property value of a web
propertyName) [Link]("color");
element.
Checks if the web
boolean visible =
isDisplayed() element is visible on the
[Link]();
page.
Checks if the web
boolean enabled =
isEnabled() element is enabled for
[Link]();
interaction.
Checks if the web
element is selected boolean selected =
isSelected()
(useful for [Link]();
checkboxes/radios).
Clears the content of an
clear() [Link]();
input field.