Links to all posts in the series
In the previous post, we looked at the usage of Selenium with the unittest module. We will see how to use WebDriver remotely in this last post of the series.
Until now, we executed our automation scripts locally. You can also use WebDriver remotely the same way you would use it locally. With this type of work, you can keep your scripts on your machine and set up a remote machine to run your scripts.
A remote WebDriver is composed of two pieces: a client and a server. The client is your code and the server is a Java servlet.
In the previous post, we explored the page object model for writing a more maintainable and reusable code. We will see the usage of Selenium with Python’s unittest module in this post.
Unit tests are used to test the smallest testable parts of a program. Python’s unit testing framework provides test management features like setting pre/postconditions, checking the result with the expected output, and generating a report of test executions.
unittest module consists of five functionality
In the previous post, we explored managing window position and dimensions and also taking screenshots with Selenium. We will see Page Object Model(POM) to create more structured and maintainable code in this post.
Until now, we have used mostly functions and single modules for our examples. If you try to manage a web page with lots of pages or components with a wide range of interactions among them, things might get complicated with this approach.
This is a general problem and as always there is a common solution for this common problem with a design pattern called “Page Object Model”.
In the previous post, we looked at controlling mouse actions. We will see how to manage window position and dimensions and also take screenshots in this post.
In part 6 of this series, we explored window handles and switching between windows. This post will complete the window related discussion mostly.
Screen resolution can impact how web applications render, so Selenium WebDriver provides mechanisms for moving and resizing the browser window.
get_window_size retrieves the size of the browser window in pixels as a dictionary with width and height keys.
width = driver.get_window_size().get("width")
height = driver.get_window_size().get("height")
set_window_size restores the window and sets…
In the previous post, we looked at working with select elements. We will look at controlling the mouse actions in this post.
We had briefly looked at some mouse actions in the Keyboard and Action Chains post. We will use action chains in the examples throughout this post too.
Selenium enables us to emulate all kinds of mouse actions like a double-click, right-click, mouse over, drag&drop, etc. These actions performed with the help of ActionChains class.
Every action called on the
ActionChains object is stored in a queue and executed in order with the
perform call. …
In the previous post, we looked at how to manage different kinds of alert dialogs. This post will be about working with
select elements on a web page.
<select> tag is used to create a drop-down list of options. It is usually used in a form to collect user input.
In order to start, we need to create a
Select instance with a select element. If you don’t give an element with the
UnexpectedTagNameException is raised.
from selenium.webdriver.support.select import Select# ...element…
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…
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…