Tips for using Selenium IDE plug-in on Chrome

Linh Do
2 min readOct 10, 2021

This plugin is not the best way to approach automation scripts. It’s a very quick way that can be used to record and verify some very basic cases. For most of the part, it’s easy to use in order to record and replay simple actions on the website.

However, the Selenium IDE’s document is not efficient in one place. On selenium.dev, they just provide us with some basic commands without any examples which makes me feel sometimes confusing and don’t know how to use some commands such as “execute script”, “assert” with parameters, etc.

I’m using it for a project and below are all my notes as some tips for using it.

  1. How to check if an element is focused?

1.1. Check if the element is focus and return to a variable by using “execute script”:

I have a textbox with id=lastname, I want to check if I left it empty then click submit button, this textbox will be focused. This check is not supported on Selenium IDE UI, you have to write a script like this:

execute script | return (window.document.getElementsByName(‘lastname’)[0] === document. activeElement); | lastname

1.2. Print the value you obtained in step 1

echo | ${lastname}

1.3. Use the command “assert” to verify:

assert | lastname | true

It’s a bit confusing here right? =)))

In step 2, you have to use ${} to print out the value, but in step 3, when using assert, just use the name of the variable.

2. Use “verify …” instead of “assert…”

If you want to continue to execute the next steps even one step failed.

In the test case for validation, we usually combine steps to validate the data. So, when one step is failed, the next steps should continue to execute. In this case, if you use the command “assert…”, the test will stop right at the step it failed. Instead of “assert…”, use “verify…” then all following steps will be executed regardless the error happens or not.

In the example below, Step 9 is failed, but Step 10 is still executed.

3. How to return sum with variable?

If your variable is a number and you assume that you can write like this to return a sum?

execute script| return ‘$’+${ProductPrice} + 2.5

If ProductPrice = 79, it will return $792.5 as a String. So, use parseFloat() or parseInt() will help:

execute script| return ‘$’+(parseFloat(${ProductPrice})+2.5) | Total

Now ${Total} = $81.5

Look kind of messy but that’s the way it works @_@

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Linh Do
Linh Do

Written by Linh Do

0 Followers

QA Engineer

No responses yet

Write a response