Contents
- Introduction
- Window interactions
- Locating elements
- Locating a single element using find_element()
- Locating elements using find_elements()
- Locating elements around an element
- XPath
- Form elements
- Form interactions
- Input Text
- Dropdown
- Radio Buttons
- Checkboxes
- HTML Elements
- Any WebElement
- Links
- Paragraphs
- Headings
- Divs
- Images
- Action Chains
- Advanced Python Selenium Techniques
- JavaScript
- Problems – Solutions
Selenium Tutorials
In this we list out the Selenium Tutorial using Python, from setup and basics, to advanced learning.
Introduction
- Overview of what Selenium is and how it works with Python
- Setup Selenium for Python
- Writing your first Selenium script in Python
Interacting with webpage and related actions
- Selenium – Get title of current web page
- Selenium – Get URL of the current web page
- Selenium – Open URL
- Selenium – Check if page is loaded
- Selenium – Take screenshot of the webpage
- Selenium – Scroll down
- Selenium – Scroll to end of the page
- Selenium – Scroll to beginning of the page
- Selenium – Get HTML source of webpage
Window interactions
- Selenium – Press browser’s back button
- Selenium – Press browser’s refresh button
- Selenium – Press browser’s forward button
- Selenium – Set window size
- Selenium – Set window size to full screen
Locating elements
In the following tutorials, we will learn how to locate or find an element by id, class name, link text, name, partial link text, tag name, or XPath, in the given document, using find_element()
function.
- Overview of the different methods available for locating elements on a web page using Selenium in Python
- Best practices for identifying unique and stable locators for web elements
Locating a single element using find_element()
- Selenium – Find element by id
- Selenium – Find element by class name
- Selenium – Find element by CSS selector
- Selenium – Find element by link text
- Selenium – Find element by name
- Selenium – Find element by partial link text
- Selenium – Find element by tag name
- Selenium – Find element by XPath
Locating elements using find_elements()
- Selenium – Find all elements by name
- Selenium – Find all elements by class name
- Selenium – Find all elements by CSS selector
- Selenium – Find all elements by link text
- Selenium – Find all elements by partial link text
- Selenium – Find all elements by tag name
- Selenium – Find all elements by XPath
Locating elements around an element
- Selenium – Get parent element
- Selenium – Get all child elements
- Selenium – Get all sibling elements
- Selenium – Get the next sibling element
- Selenium – Get all the next sibling elements
- Selenium – Get the previous sibling element
- Selenium – Get all the previous sibling elements
XPath
- What is XPath
- Writing your first XPath expression
- XPath syntax
- Using regular expressions with XPath to match complex patterns.
- Selenium – XPath to find parent element
- Selenium – XPath to find child elements
- Selenium – XPath to find sibling elements
- Selenium – XPath for the next (sibling) element
- Selenium – XPath for all the next following (sibling) elements
- Selenium – XPath for the previous (sibling) element
- Selenium – XPath for all the previous (sibling) elements
Form elements
Form interactions
Input Text
- Selenium – Xpath for input text field
- Selenium – Get value in input text field
- Selenium – Clear input text field
- Selenium – Enter value in input text field
- Selenium – Enter value in input text without sendkeys()
- Selenium – Iterate over all the input text fields
- Selenium – Check if an input text field exists
- Selenium – Check if input text filed is empty
Dropdown
- Selenium – Xpath for dropdown element
- Selenium – Select a value from dropdown by index
- Selenium – Select a value from dropdown by value
- Selenium – Select a random value from dropdown
- Selenium – Check if dropdown exists
- Selenium – Iterate through dropdown list
Radio Buttons
- Selenium – Xpath for radio button
- Selenium – Check if radio button is selected
- Selenium – Check if radio button exists
- Selenium – Select a radio button
- Selenium – Select second radio button
- Selenium – Select radio button by value
- Selenium – Select random radio button
- Selenium – Get selected radio button
- Selenium – Deselect or uncheck of a radio button
Checkboxes
- Selenium – Xpath for checkbox
- Selenium – Check if checkbox is selected
- Selenium – Check if a checkbox exists
- Selenium – Select a checkbox
- Selenium – Unselect a checkbox
- Selenium – Iterate over all checkboxes
- Selenium – Select all checkboxes
- Selenium – Unselect all checkboxes
- Selenium – Get label text for a checkbox
HTML Elements
Any WebElement
Checks
- Selenium – Check if element exists
- Selenium – Check if element is visible
- Selenium – Check if element is hidden
- Selenium – Check if element is clickable
- Selenium – Check if element contains specific text
- Selenium – Check if element has specific class name
- Selenium – Check if element has an id
- Selenium – Check if element is enabled
- Selenium – Check if element is disabled
Attributes
- Selenium – Get style attribute of element
- Selenium – Get size of element
- Selenium – Get text content of an element
- Selenium – Get outer HTML of element
- Selenium – Get inner HTML of element
Actions
- Selenium – Scroll to element
- Selenium – Wait until element is visible
- Selenium – Take screenshot of element
Links
- Selenium – Click on a link
- Selenium – Get all links
Paragraphs
- Selenium – Get all paragraphs
- Selenium – Get first paragraph
- Selenium – Get last paragraph
- Selenium – Get hidden paragraphs
- Selenium – Get paragraph text
Headings
- Selenium – Get all the headings
- Selenium – Get first heading
- Selenium – Get heading text
Divs
- Selenium – Check if a div exists
- Selenium – Get all the divs
- Selenium – Get div elements with specific class name
- Selenium – Get div with specific id
- Selenium – Get hidden divs
- Selenium – Get div text
- Selenium – Get div outer HTML
- Selenium – Get div inner HTML
Images
- Selenium – Get all the images
- Selenium – Check if image is visible
- Selenium – Check if image is clickable
- Selenium – Click on an image
- Selenium – Get image alt text
- Selenium – Get image size
- Selenium – Get image src
Action Chains
We can simulate actions from input devices like keyboard, mouse, pen or touch devices, and wheel for scrolling.
- What is Action Chain in Selenium?
- Selenium – Click action
- Selenium – Click and hold action
- Selenium – Context click action
- Selenium – Double click action
- Selenium – Drag and drop action
- Selenium – Key down action
- Selenium – Key up action
- Selenium – Move by offset action
- Selenium – Move to element action
- Selenium – Move to element with offset action
- Selenium – Release action
- Selenium – Reset action
- Selenium – Send key action
Click
- Selenium – Random click
Advanced Python Selenium Techniques
- Using implicit and explicit waits to handle page loading and element visibility
- Handling pop-up windows
- Handling alerts