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 – the code that deals with not encountering the exception (if the code in try executes) and the code that deals with encountering the exception (if the code in catch executes).
In my previous post i talked about how to check whether an element is displayed or not. There are times when tests where such an action is performed fail randomly (sometimes they will pass, other times they won’t). The assumption here is that the element was not displayed within a decent amount of time when there were test failures, but would have appeared later on. Therefore if the test would have waited a little bit before performing the presence check, it would have passed. Continue reading Selenium: How to wait for an element to be displayed / not displayed
When you have more than one assertion in your test, you might want one of two things:
- Have your tests fail once the first assertion failure is encountered.
- Have all your assertions run, no matter if they have passed or failed. Of course, after they are run, if there are failures, you want the test to fail, and also show you where the issues were.
Suppose you are starting work on a new piece of software that you will need to write automated tests for. Your goal is to cover the most relevant test scenarios that apply to the feature , without missing or forgetting one. Below are a few steps (guidelines) to help you achieve identifying those required scenarios (a sort of ‘how i do it and it works for me’ guide). Continue reading How to identify the test scenarios you have to automate
During Selenium test execution, i want to store a screenshot of what is displayed in the browser to understand in what conditions the test ran.
I have a bunch of tests that i would like to run faster, by making them execute in parallel. In my tests:
- I am not using a DataProvider and only want to make the same test run several times.
- I am using a DataProvider and want my test to run with the provided values from the provider, but in parallel.
- I am not using DataProviders, but my tests are ran by using the textng.xml file that specifies which tests to run (as per this article).
Having an HTML dropdown on a web page, i would like to select, via Selenium, an element from it, or deselect the selected one.
An example of an HTML representation of a dropdown can be found below – it displays a list of winter months:
<select id="winter"> <option value="Dec">December</option> <option value="Jan">January</option> <option value="Feb">February</option> </select>
This element would look something like:
The task is to easily select / deselect an element from the dropdwon.