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

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
Command Target Value
open http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onfocus
selectFrame view
pause 5000
fireEvent css=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
Command Target Value
open http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onblur
selectFrame view
type id=fname a
pause 5000 focus
fireEvent id=fname blur

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 *