This is a short tutorial with screenshots on how to create and run test cases in Bromine v3. We’ll follow a few easy steps that will include recording the test case with Selenium IDE, creating a JAR file and finally adding it to Bromine and running it. So, lets begin.
Create a test script
There is more then one way to create a test script that will be run on Selenium server, and we will of course use the easiest one ![]()
Selenium IDE is the tool for us. It is an extension for Firefox, that enables us to record a test cases by simply clicking in Firefox’s main window. The IDE allows us to export the recording in multiple programming languages supported by Selenium, so we can have a complete test case in our desired language without typing a word. And here comes to big BUT. Bromine can’t run test scripts recorded like this. We need to add some extra variables and code that will enable our test cases to communicate with Bromine. Don’t be scared, we still don’t need to do any coding ourselves, thanks to the good falks at Bromine development. They have created a special format code that will enable Selenium IDE to export the recorded test script to Java and PHP that is specially formed for use with Bromine. All we need to do is to add this code to Selenium IDE:
- Download and install Selenium IDE (http://seleniumhq.org/download/)
- After restarting Firefox, open it from Tools -> Selenium IDE
- Now we have the IDE window, and we can add the new format to it
- Open Options -> Options…
- Select the Formats tab and click the Add button
- Selenium IDE Format Source window is displayed. Enter a name for the format: Java-Bromine (for example)
- Copy the content of <webroot>/IDE-formats/BR3-java.txt (or BR3-php.txt if you are using PHP for the test cases) and paste it in the text area (make sure you overwrite the existing code).
- Save it and close the options window.
- Now we can record the test case.
- Once its done, choose File -> Export Test Case As… -> Java-Bromine and save it on your disk. [SinglePic not found]
Now we have a code that can be used by Bromine to run the test case. Well, this isn’t quite true. Before we add it to bromine, we need to compile it and create an executable JAR file:
- Add the 4 jars found under /app/webroot/testscripts/Google sample/jar/lib as libraries
- Create a class with your code and set it as the main class
- Compile
If you really don’t know how to do this, check out Compiling a Java code for Bromine in Eclipse.
At this point we have a valid test case that we can add to Bromine so it can run the test case for us.
Setting up Bromine to run test scripts
Before we start with these steps, let me just make a little detour here to clarify some terminology:
Planning is where you plan all your testing activities, meaning you setup your requirements and testcases. Projects Everything belongs to a project. Projects have multiple users attached to them. Projects have multiple sites attached to them. Sites are the various URLs that the project uses eg. developement/production URLs. Add/edit the sites by editing the project. Requirements work as containers for testcases as well as other sub-requirements. You can add requirements from the Planning menu. You can manage requirements structure by clicking ‘Manage requirements’ which will enable you to drag ‘n drop them on to each other, making them sub-requirements of each other. Requirements contain the OS/browser combinations that contained testcases will be run in. Testcases should be the humanly readable test of some functionality. A testcase can have a single testscript attached to it. Attach the testscript by using the upload testscript functionality. Testcases can have steps attached to them. Steps are a step by step description of the test, eg. open google.com, google.com opens. Add/edit steps when editing the testcase. Testcases must be linked to a requirement. A single testcase can be linked to multiple requirements. Use the ‘Manage testcases’ link to drag ‘n drop testcases to the requirements they should be linked to. (taken from http://wiki.openqa.org/display/BR/Planning)- Open Bromine, and log in (admin/admin by default)
- If you don’t have a new project created, please create one now (Control Panel -> Projects -> New Project), otherwise select it from the drop down
- Now we need to create a new requirement and a new test case. Requirements will tell Bromine which browser on which OS to use for its test cases. Lets create one now.
- Go to Planning -> Add Requirement and fill in the form. Once saved, it will appear in the left sidebar, so just click on it. Now you can see a table with OS and Browser names. Lets edit this by choosing the edit link in the top right corner.
- Check the desired checkboxes (if you don’t have a browser or OS in the list, you can add it from the control pannel), and finally click submit.
- Now we have a requirement, and we can create the test case now.
- Planning -> Add Testcase and fill in the form.
- Now click the Manage testcases link in the Options part of the sidebar, and drag and drop the new testcase from the second column to the first, so it appears under our requirement.
- Selecting Done from the Options part of the sidebar we are finished tying the test case to the requirement.
- We are ready to upload our script. Click on the test case in the sidebar and edit it.
- By clicking the Upload new testscript you can upload the previously created JAR file.
- Submit the data.
The setup of Bromine is now finish. Now we can move on to the next step.
Running test cases in Bromine
Testlabs is the place to go for running the test cases and to review the results. Results are displayed in a newest run order, so you’ll always have the result from the last run on the top of the page.
The test cases can be run in two ways:
- The whole requirement – it will run all of the linked test cases in all available browsers and OS combinations.
- Single test case – this will run only the selected test case. The browser/OS combination is based on the requirement the given test case is linked to.
We’ll look into the last one, the single test case execution.
- Navigate to TESTLABS
- Select a test case from the left column
- The Details appear for the selected test case, and here by clicking the green arrow we can run the testcase
- Bromine will lunch the browser, and execute the test case. A new window is displayed with the results that is refreshing on each selenium command, and displays the success of it.
- Now that the running is finished successfully (or with errors), we can examine the report for each run by clicking on the green check sign (or x if the test failed).
Hi
You have made some really nice tutorials for Bromine 3. Since you have been giving Bromine a lot of time maybe you wanna help out, bring ideas to the project, code some…
Please contact me
Visti
This is the first I’ve seen that explains the process in detail. Thanks!
[...] A duplicate of this post can be seen on the author’s personal blog: http://vilmoss.com/ [...]
Hi!
When I tried to play with Bromine, I get an ERROR : Error: stateOfTheSystem reports errors.
When I selected a test case from the left column, under Details Section,
RUN TESTCASE: Error: stateOfTheSystem reports errors
so anyone can help me out?
It is had to figure out what the problem is based on only one line of error message. I’m guessing bromine was not set up right. Take a look at Install Bromine, Setting up Bromine, Running test cases in Bromine, and Compiling a Java code for Bromine. If these tutorials do not solve the problem, submit a post to the Bromine forum with a detailed description of your problem.
[...] http://alasdoo.com/2010/04/running-test … romine-v3/ [...]