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).
Continue reading Quick Tip: Running automated tests in parallel
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:
This element would look something like:
The task is to easily select / deselect an element from the dropdwon.
Continue reading Quick Tip: Selenium – select / deselect a value from a dropdown
I’m thinking you should, in no particular order…
- Start from the basic . When learning a new language, start from the beginning. Understand the elementary notions of it. Make sure you know what the language represents, what it is used for, how to write it properly. Read the tutorials, try out the examples.
- Be lazy. Don’t reinvent the wheel. If you need some code that someone has already developed, use it. Use existing libraries where possible.
- Modularize, don’t copy paste. When you know you have bits of code that will repeat themselves, extract them in a separate method and call that method wherever the code is needed.
- Think and plan before you write your tests. Take time to analyze the requirements, to discuss the implementation with the developers, in order to identify the broadest and most relevant set of test cases. Take notes. Visualize how regular users will interact with the site. Make sketches. Jumping into testing just to finish it will make you skip some obvious scenarios.
- Name things properly. Whenever you pick a name for a method, attribute or test scenario, make it relevant to what it is supposed to do. Describe it as much as possible. Use a decent amount of letters (not 2-3 and not 100).
- Ask questions. Whenever something is not clear, or when you just need a confirmation of how well you understand the requirements, ask the people around you for information. No matter how basic or stupid the question might sound, it’s the start of a conversation which benefits all the people included in it.
- Separate concerns. Don’t put all the code in one class. Analyze what you must write. What part is the setup, what part is the verification? Usually tests should largely focus on the actual testing, not the setup, so maybe extract that part into a separate class/unit, so that you minimize how large a test it. Also, you can put in all validations in a separate place. In this case, when you read the test, you should have – a line of code which calls the setup; the test logic; one line of code that performs the validation (if possible).
Continue reading A few developer principles that testers should follow
I wrote a Java method, whose signature contains a number of parameters. This method is called by many other methods (i use the method in my tests). After a while i realize one of the parameters is not needed anymore. I want to change the method signature and to update all its’ references throughout my code.
Continue reading Quick Tip: IntelliJ – easily updating method calls when method signature changes
Some while ago i published an article in a local magazine on the topic of writing Selenium tests in an Object Oriented fashion. As i believe this is a very useful way of reducing the number of asserts tests can include, and to expand to a bigger audience, here is a different approach to writing Selenium tests.
This approach is recommended when you have, for example, a big module whose properties you must compare to the expected ones, after performing an action or when it comes to testing the translation of the page. Continue reading Selenium tests, the Object Oriented Way
Writing proper code in your IDE is made easier when using IntelliJ, due to its’ code analysis features. One option to perform a comprehensive coding issue search is to use the Inspect Code feature IntelliJ provides. From the class you want to check for issues, right click (inside the class, in the editor) and choose Analyze –> Inspect Code. Continue reading Improving your code by using IntelliJ’s Inspections feature
While running tests with Selenium, you might want to navigate between the pages that are opening, without knowing or caring about the URL that is assigned to them. You would like to use the browser’s back and forward functionality, to just go back one page from the current one, or forward to the next page. You might also want to refresh the current page, without performing a driver.get(“someURL”). Continue reading Page navigation with Selenium