SUBSCRIBE HERE TO GET POST UPDATES VIA EMAIL :

Delivered by FeedBurner

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
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

1 comment:

  1. Thanks you for your post.
    It's good when my team using Boottrap!

    ReplyDelete