0% found this document useful (0 votes)
4 views12 pages

Selenium WebDriver Course Overview

The document provides a comprehensive guide on initializing browser drivers and using Selenium for web automation. It covers various locators, methods for switching between frames and windows, handling alerts, and different types of waits in Selenium. Additionally, it includes code snippets for practical implementation of these concepts.

Uploaded by

suresh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views12 pages

Selenium WebDriver Course Overview

The document provides a comprehensive guide on initializing browser drivers and using Selenium for web automation. It covers various locators, methods for switching between frames and windows, handling alerts, and different types of waits in Selenium. Additionally, it includes code snippets for practical implementation of these concepts.

Uploaded by

suresh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Initialize

Browser Drivers
Browser Syntax
Chrome WebDriver driver = new ChromeDriver();

Edge WebDriver driver = new EdgeDriver();

Firefox WebDriver driver = new FirefoxDriver();

Safari WebDriver driver = new SafariDriver();

[Link]/Courses
Selenium
Locators
Locator Syntax
className [Link]([Link] (“value”))

cssSelector [Link]([Link](“value"))
id [Link]([Link](“value"))
linkText [Link]([Link](“value"))
name [Link]([Link](“value"))
partialLinkText [Link]([Link](“value"))
tagName [Link]([Link] (“value”))

xpath [Link]([Link](“value"))

[Link]/Courses
Switch Method
Types For Frames
Method Description
frame(WebElement element) Selects a frame by WebElement

frame(String nameOrId) Selects a frame by its name or ID

frame(int index) Selects a frame by its (zero-based) index

defaultContent() Selects either first frame or main document

parentFrame() Change focus to the parent context

[Link]/Courses
Frame
Example

[Link]/Courses
Alerts/Pop-Ups

Method Description
accept() Accepts the alert

dismiss() Dismisses / cancels the alert

getText() Gets text from the alert

sendKeys() Types text into the alert

[Link]/Courses
Alert
Example
Log Into
Application
Menu
Company Username

Logo Password

Submit
Button

Pop-Up / Alert
Box

OK CANCEL

[Link]/Courses
Switch Method
Types For Windows
Method Description
getWindowHandle() Gets the window handle of the current window

getWindowHandles() Gets the window handle of all current windows

switchTo().window() Switch focus between windows

[Link]/Courses
Switch Windows
Example

[Link]/Courses
Explicit Wait
Example

[Link]/Courses
Selenium
Waits
Selenium Wait Description
[Link]() (Not a Selenium Wait Method) Causes execution to
sleep for a certain number of milliseconds
Page Load Timeout Sets the wait time for a page to load before throwing
an error
Script Timeout Sets the wait time for JavaScript to execute before
throwing an error
Implicit Wait Determines the wait time to search for an element
before throwing an exception
Explicit Wait Pauses execution until time has expired or an
expected condition is met via WebDriverWait class
Fluent Wait A specialization of Explicit Wait that’s extended by
the WebDriverWait class
[Link]/Courses
Explicit Wait
Expected Conditions
1. alertIsPresent() 9. textToBePresentInElementLocated()

2. elementSelectionStateToBe() 10. textToBePresentInElementValue()

3. elementToBeClickable() 11. titleIs()

4. invisibilityOfTheElementLocated() 12. titleContains()

5. invisibilityOfElementWithText() 13. visibilityOf()

6. presenceOfAllElementsLocatedBy() 14. visibilityOfAllElements()

7. presenceOfElementLocated() 15. visibilityOfAllElementsLocatedBy()

8. textToBePresentInElement() 16. visibilityOfElementLocated()

[Link]/Courses
Select From
Drop Down Code Snippet

[Link]/Courses

You might also like