What is a cookie and what are they used for? Cookies are key-value pairs followed by zero or more attribute-value pairs stored on the client-side. It is a small piece of data sent from the web application and stored in the web browser, while the user is browsing that web page. They usually store information about users, their preferences, and past activities. …
There are two methods for the…
If you are a person who likes to send new year message cards to your friends or family, maybe you want to do it by programming this time. Let’s start…
We need to create a virtual environment before starting to isolate dependencies from the rest of the system.
python -m venv env
pip install yagmail
pipenv install yagmail
yagmail is a Python package created to interact with Gmail accounts to make sending emails easier.
The program will have both command line parameters and interactive mode support.
In the previous post, we looked at working with cookies. We will explore the handling of alert dialogs in this post.
An alert is a pop-up window. It gets triggered due to some action performed by the user or automatically due to some system settings. Their purpose is to give some information to the user, take permission, or take some input from the user.
Selenium WebDriver Alert API provides methods to handle interactions with these pop-up message boxes.
We can categorize the alerts into the following three types:
A simple alert shows a custom…
In the previous post, we explored how to pass options to the Selenium WebDriver instance to set the various preferences for the browser.
EventFiringWebDriver class is a wrapper for a WebDriver instance that supports firing events.
You can use this to take some actions before or after certain events like finding an element, navigating to a url, clicking an element, or quitting the browser.
It takes driver, and event_listener as arguments. event_listener is an instance of a class that subclasses the
Following methods of the
AbstractEventListener class should be implemented fully or partially.
* before_navigate_to(self, url, driver) *…
In the previous post, we explored how to control the keyboard actions with Selenium. We will see how we can configure the WebDriver instance by passing options/capabilities to it.
You can pass the options to WebDriver instance such as headless to run the browser without a GUI.
Capabilities are options that you can use to customize and configure a WebDriver session. A client can use capabilities to specify required features while creating a new session.
List of Capabilities
In the previous post, we looked at the different navigation strategies. We will see how to control the keyboard actions in this post.
Selenium allows us to emulate actions on the keyboard such as pressing keys, or clearing the content written. Also, we can use modifier keys like CTRL or SHIFT to perform some compound/combined keypresses with the help of
Action chains allow interactions such as mouse movements, mouse button actions, keypress, and drag-and-drop. When you call methods for actions on the
ActionChains object, the actions are stored in a queue in the
ActionChains object. When you call…
In the previous post, we looked at different wait strategies. I will try to explain navigation among URLs, windows, frames, and alerts in this post.
Opening a website is the first thing after starting a web browser. In Selenium this is done with the
get method call on WebDriver instance like below.
In the previous post, we looked at how to locate elements before interacting with them. We will explore how waits work in Selenium to make sure that elements are presented in the DOM before interacting with them in this post.
document.readyState property of an HTML
document describes the loading state of the current document. By default, a
driver.get request returns to the caller when the ready state becomes
There are 3 kinds of page loading strategies for Selenium WebDriver.
Wait for the entire page is loaded that is determined with the
In the previous post, we looked at the high-level architecture of Selenium applications. This post will be about locating elements on a web page to interact with them.
We should first locate elements on a page to perform some operations on them. We can locate elements by id attribute, name attribute, css selector, class name, tag name, xpath, and full or partial link text.
Python api provides the following methods to find elements on a page.
These methods return an object in
WebElement (represents a particular DOM node) type or raise