0
votes

I'm using Selenium IDE 2.3.0 to record actions in my web application and create tests.

Before every test I have to clear all cookies, load the main page, log in with a specific user and submit the login form. These ~10 commands are fix and every test case needs them, but I don't want to record or copy them from other tests every time.

Is there a way to configure how "empty" test cases are created?

I know I could create a prepare.html file or something and prepend it to a test suite. But I need to be able to run either a single test or all tests at once, so every test case must include the commands.

2

2 Answers

1
votes

Ok I finally came up with a solution that suits me. I wrote custom commands setUpTest and tearDownTest, so I only have to add those two manually to each test.

I used this post to get started:
Adding custom commands to Selenium IDE

0
votes

Selenium supports object-oriented design. You should create a class that takes those commands that you are referring to and always executes those, in each of the tests that you are executing you could then make a call to that class and the supporting method and then execute it.

A great resource for doing this is here.