Category Archives: automation

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. Continue reading How WebDriverWait works differently for WebElements defined by driver.findElement versus PageFactory initialization

Find files inside a folder in your automated test

Context: you have a folder containing some files. You need to find all the files whose name contains some expected value in this folder and all its’ sub-folders. Or you need to find all files with a specified extension in the folder. Maybe you need to count how many files with a specified size are found in the folder. How can you do these tasks easily? Continue reading Find files inside a folder in your automated test

Better Test Code Principles: Use proper naming, for everything

Naming is one of those underrated things when it comes to test automation code. Many times, when you look at variable or even test method names, they are not very suggestive and you have a hard time figuring out what their purpose is. In this post you will find a few reasons why it is important to name things properly, and some tips about how to find the good names your code deserves. Continue reading Better Test Code Principles: Use proper naming, for everything

The Automated Regression Suite. Part 3 of 3. How to run the suite

Once you have a regression suite set up, you will need to run it. When you have a smaller number of tests that need to be run on a specified day, that won’t be a problem, and the tests will successfully finish running within the allocated time period. However, as the suite becomes larger and larger, so does the amount of time required to run all the tests. In some cases, you can even get beyond a 24-hour test run. So, what can you do to optimize the test run time? You can use two strategies: parallelize and split. Continue reading The Automated Regression Suite. Part 3 of 3. How to run the suite

The Automated Regression Suite. Part 2 of 3. When to run the tests.

Once you have your automated regression suite in place, you can create a scheduler to run them periodically, without any manual intervention. Mostly you will use Jenkins jobs (or some similar CI tool) to trigger them and have them running on an environment of your choice. Just because they are called “regression tests” it does not mean they are only meant to be run once before a release. They are in place to help validate your system, so you can run them as often as you want. Continue reading The Automated Regression Suite. Part 2 of 3. When to run the tests.

The Automated Regression Suite. Part 1 of 3. When to create the tests for regression

What do I mean by “automated regression testing”? I am not one for debating for hours what this means, so let me give you my interpretation (not definition), so that we are on the same page: whenever you are performing a new release, you need to make sure the features you released some time ago still work properly. For that, you will need to run some kind of tests, to ensure the features are still working as expected. You could do that manually, but running the same manual test cases repeatedly, for each release, takes a lot of time and quite frankly, becomes boring or even frustrating at one point. Hence, the suite of automated tests comes in handy. Having these in place will allow to verify plenty of scenarios while you can do something more enjoyable during the test run. Continue reading The Automated Regression Suite. Part 1 of 3. When to create the tests for regression

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 condition they are checking not being fulfilled by the time the assertion code executes. Had the assertion run a few seconds later, in many cases, it would have passed. It’s all about timing. In my previous posts I described some of the WebDriverWait based methods you can find in my ‘thewaiter’ library. In this post I want to highlight how you can use these methods to replace your assertions. Continue reading Use waits as assertions for your Selenium tests