In some tests it is not enough to just wait for a page to fully load, but instead you need to make sure that the URL corresponding to that page is the expected one. Maybe you clicked on a button and need to make sure an expected page/URL opened, or maybe you are opening a page but a redirect changes the URL to something else than the initial page had. For such tests you can use the URL related wait methods from ‘thewaiter’ library, to wait until the URL is the correct one, before performing the rest of the test. Continue reading thewaiter: waiting for a URL in the browser to equal or contain a String, with Selenium
In this post i will discuss the methods you can find in thewaiter library, for waiting for a page to load completely. I will show the methods you can use from thewaiter that can help you with these waits, and some test examples for each, that you can also find in GitHub. Continue reading thewaiter: opening a page and waiting for it to load with Selenium
During my talk at the recent SauceCon conference, i described how you can write reliable Selenium tests by using WebDriverWait based methods to wait for page events to take place. I am now happy to announce that my little project, thewaiter library that i mentioned in the talk, is available to use from the Maven Repository! Read on for details. Continue reading Introducing thewaiter. A WebDriverWait based library for writing reliable Selenium tests
Let’s say you have a task to check whether a certain image is broken on your page. In case of a broken image, instead of it being rendered properly on the page in your browser, you will see a suggestive icon, like an X or something similar (depending on the browser), suggesting that it’s broken. Continue reading Checking whether an image is broken with HttpClient
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 times it might be the second, or the fourth, and so on. You only know that using getText() on the element returns a known text.
- if the element you are searching for has a different selector each time you open the page. You know only the type of element it is (whether it is a button, or an a element representing a link, or an img element) and what text should be displayed on that element.
- if the element you are looking for does not even have any attached attributes. That means it is only a tag, without an id or class, or anything else except for the tag name (tag being ‘a’ for links, ‘img’ for images, and so on). You know what getText() should return when applied to that element.
This is going to be a follow-up post in regards to the approach i showed at my SeleniumConf talk, on doing Selenium tests by using an Object Oriented approach.
I will have a series of such posts, to show more examples and to make it easier to understand how to use it. All the code presented here will be available in GitHub under this location: https://github.com/iamalittletester/learning-project. Continue reading Selenium tests, the Object Oriented way – example 1 (with code)