Handling events like focus or blur in selenium with “fireEvent” command

Last updated on October 8th, 2025 at 11:35 am

There are many types of HTML DOM Events available on web page. In selenium IDE, “fireEvent” command is the solution to handle such kind of events. Here i am trying to show you the use of “fireEvent” command with focus or blur event. You can handle any other event in this way.
“fireEvent” command with “focus” event
Let we see it with example. In bellow given example, when element “css=input[type=”text”]” gets focus, its color becomes yellow. Here i have used “fireEvent” command to get focus on that element. Run the script and observe yourself. You can use this command combination when the event occurs when an element gets focus. I have placed 5 second pause period to see event’s effect.

New Test
CommandTargetValue
openhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onfocus
selectFrameview
pause5000
fireEventcss=input[type=”text”]focus

“fireEvent” command with “blur” event
In bellow given example, when element “id=fname” lost the focus, all characters typed in text box are converted into uppercase. Here is the event occurs when a form element loses focus. So we can use “fireEvent” command with “blur” event to see its effect.

New Test
CommandTargetValue
openhttp://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onblur
selectFrameview
typeid=fnamea
pause5000focus
fireEventid=fnameblur
author avatar
Aravind QA Automation Engineer & Technical Blogger
Aravind is a QA Automation Engineer and technical blogger specializing in Playwright, Selenium, and AI in software testing. He shares practical tutorials to help QA professionals improve their automation skills.
Stay Updated with New Articles
Get the latest tutorials and insights delivered to your inbox.

One thought on “Handling events like focus or blur in selenium with “fireEvent” command

Leave a Reply

Your email address will not be published. Required fields are marked *