Let’s go way back to basics for a second: Java naming conventions. I wrote a post a while back regarding how to compose the name for various Java items, like classes or variables. In this post i want to emphasize the naming conventions, which relate to the use of upper/lower/camel cases when naming things.
Using HashMaps in automated tests
HashMaps are one of those Java concepts that can be very useful in automation testing, but are not widely used, because they seem to be too complicated. A HashMap is nothing more than a collection of key/value pairs, where you can store test related data to access later in the tests. In this post i… Read More
Removing duplicates from a List
When working with lists, sometimes you only want them to contain distinct elements. There are two options to create lists without duplicates: either to not add these from the start, or, if that is not possible or too difficult, to remove the duplicates from the list later on. Let’s see how you can do both… Read More
Checkout the first article i wrote for TestProject’s blog
Checkout the first article i wrote for TestProject’s blog: https://blog.testproject.io/2019/10/24/using-java-objects-for-comparing-api-db-test-data/. It is about how to easily compare test data gathered from an API to the test data gathered from the DB, using Java Objects.
Useful type conversions
Some of our test data needs to be transformed from its original type to something else. For example, we might need to convert a String to a numeric value, or vice versa. Or we might need to generate date values in a certain format. Examples for all of these can be found below.
thewaiter: clicking on an element by using waits with Selenium
One of the most common ways of interacting with a page displayed in a browser, in Selenium tests, is clicking on a WebElement. But many times, due to the timing when the click happens, it will fail, since the WebElement that needs to be clicked is not yet available. This might be because some Javascript… Read More
Better Test Code Principles #5: Mind your try/catches
Using try/catches to handle exceptions has become quite fashionable when writing tests with Java. However, this approach is also a frequent source of having false positives while running tests. Many times when writing the tests people forget to consider both sections of this code block: they forget to write the appropriate code in both sections… Read More
Using Lists to get UI elements with nearly impossible selectors
Where does this approach apply? One of the following: if you have a list of elements with identical selectors. The element you are interested in is an element of that list. But it does not always appear in the same place in the list. Sometimes it might be the third element in the list, other… Read More
@FindBy, Lists and using them to check for similar UI elements
This is going to be a rather complex post, that will show how to easily check for values of similar UI elements. By similar i mean elements that share some kind of properties: whether they have the same CSS selector, or are part of the same group of elements. Some examples will be shown below.… Read More
Better Test Code Principles: #1 Don’t copy/paste the code. Reuse it.
When starting to learn Java, one of the first things you are taught is that a class consists of several things, among which are the ‘methods’. A method is nothing more than grouping of several code lines. Since tests are code, the same principle applies to writing your Java based tests. Especially if you are… Read More