Summary
In this guide, learn how to:
How to Create a Selenium Script
To create a selenium script you will need a selenium IDE. For instructions on installing a selenium IDE, refer to “Requirements for creating selenium scripts.”
In this guide we will be using the Katalon Automation Recorder, a Selenium IDE for Chrome.
- With the Katalon IDE open, begin by clicking New. Name the script and click OK
- Next, get started by my manually entering commands or by using the recorder. We’ll start with the recorder and add commands manually as we need them.
So, click the Record button and we will now automatically create a simple 3-page script.
- Type “https://www.bluetriangle.com/” into the browser’s search bar and press enter.
- Click “About Us” on the top of the Blue Triangle home page.
- Now click the “About the Platform” button.
Now, look back at the Katalon window and you should see the commands that were recorded. Press Stop to stop recording.
- Next we’ll playback what was recorded to make sure it works. Click Play. Katalon will take control of the browser and begin performing the actions in the script Look back at the Katalon window and you should see the commands highlight in green when successful.
- Now we will put more validation in the script by adding some commands manually. Blue Triangle always recommends adding validation after each step so it is clear why and when the script has failed if it does.
- Right-click on first row with the “open” command. Select “Add Command.”
- Next click on the new line that appears, and fill in the command field with “assertTextPresent” and the target field with “Blue Triangle.” The assertTextPresent command will fail when the given text is not present on the page.
- Follow the same steps to input the same validation for the other pages as shown in the screenshot below.
- You should be able to playback the script now and see all commands highlight in green. To save your script, click the 3 dot icon next to “Untitled Test Suite*” and click Save Text Suite As.
-
Note: to upload your script to the Blue Triangle Portal, the script will need some additional formatting. Continue reading for How to Format and Upload Your Script to Blue Triangle.
For more information about the Katalon Automation Recorder, click here for a quick start guide. https://www.katalon.com/resources-center/blog/katalon-automation-recorder/
How to Format Your Script for Blue Triangle
To properly measure the performance of each page a script traverses Blue Triangle requires a specific format.
For this example we’ll use the Demo Blue Triangle Script created in the How to Create a Selenium Script tutorial.
To proceed, we need to identify which commands in the script can be grouped together to represent a page or a step.
A step typically begins with a navigation or field input and ends with some validation on the page it leads to.
In the example above, we know the open command gives us the Blue Triangle Home Page. We also know we want to validate the Home Page has loaded by searching for the text “Blue Triangle.” We’ll group these commands together as the Home Page Step.
To format this, we use a reserved form of the selenium command “store”. The target will be the step or page name, and the value will be “stepName1.”
The same goes for the other pages, only the number after “stepName” will increment. See the script completely formatted below.
Once you have this formatting in place, you’re ready to upload it to the Blue Triangle Portal.
How to Upload Your Script to Blue Triangle
- Click the Settings icon, which looks like a gear in the toolbar at the top of the page.
- Select Synthetic Scripts from the Synthetic Configuration section
- Click Create Synthetic Script.
- Click the button to Upload a Selenium IDE Script File (.html).
- Find your formatted selenium script on your computer and select to upload it.
- Your script will fill into the page like this:
- Finally, scroll to the bottom of the screen and click Create.
- You should now see you script in the table from step 2.
To start running this script in the portal, refer to the guide How to Create a Multi-Page Synthetic Monitor.
Comments
0 comments
Please sign in to leave a comment.