Working with user prompts in Selenium

In your tests you might encounter specialized popups, which are generated via Javascript, and which are called ‘user prompts’. These are very basic in functionality, and they come in three variants: an ‘alert’ which only displays an informational message and an ‘OK’ button; a ‘confirm’ which displays an informational message, together with an ‘OK’ and… Read More

Iframes, switchTo() and default content with Selenium

So, now that you are an expert in writing CSS selectors to identify your WebElements (possible because of my older webinar on this topic), you want to write some new tests. You are inspecting the page you will test, identifying what WebElements you will need, and start writing the selectors. Once you have them, and… Read More

Browser unaware Selenium tests. STEP 1: Identify OSs on which to run tests + choose browsers to support

In this blog post series, i want to show how i normally set up my browsers and my Selenium code, in order to enable writing ‘cross-OS’, ‘cross-browser’, ‘browser-unaware’ tests. What this means: my tests can run on any OS i set up seamlessly; each test can be run on multiple browsers seamlessly; the tests do… Read More

thewaiter: wait for WebElement attribute. To equal, contain a String, with variations.

An attribute of an HTML tag (or WebElement as you might know it from Selenium) stores valuable information about the state of that element. If we are thinking of checkboxes, a “checked” attribute will signal whether the checkbox is selected or not. For a link, the “href” attribute will tell us what location on the… Read More

How WebDriverWait works differently for WebElements defined by driver.findElement versus PageFactory initialization

When it comes to using WebDriverWait to wait for WebElement properties,like text or attributes, when sending WebElements as properties generated via PageFactory, that will work properly. However when using ‘driver.findElement()’ to identify the WebElements required as parameters in the WebDriverWaits, that will fail. Here is the reason why.

Use waits as assertions for your Selenium tests

Selenium tests tend to make a lot of use of assertions, to check that some actions have been performed on the front-end or that some WebElement properties are the expected ones. And by assertions, I mean, mostly: assertEquals or assertTrue, as these are the most commonly used ones. Assertions fail too often due to the… Read More

thewaiter: wait for WebElement text. To equal, contain a String with variations.

Element text is something you will often check for when writing Selenium tests. Whether it equals a given String, or contains a given String. But you can extend your checks to whether: the element text equals/contains a String ignoring the case of the two, or whether the element text equals/contains a String ignoring any whitespace… Read More