>Selenium and Javascript events

>Have you ver been in situattion when youhave typed a value into a text box and you expect a
Javascript event to be called such as “OnBlur”

welll selenium has a method “FireEvent” which triggers the event for you, but then the trick is you have to strip the “on” and name for the event wouldbe “OnBlur”

I guess abit of example would make more sense, lol.
This is what my html look like

<input type="text" value="" onblur="JavaScript:ValidateSimpleMail(true);" size="25" name="EMAIL_1" id="EMAIL_1"/>

selenium command to type into an email box, which doesnt fire the event attached to the text box

browser.Type(“EMAIL_1”, “sam@sam.com”);

The work around is to use selenium to fire the event after it has typed in the textbox
FireEvent(locator, eventName) which in my case is

browser.FireEvent(“EMAIL_1”, “blur”);

Advertisements
This entry was posted in Software Testing and tagged , , , . Bookmark the permalink.

2 Responses to >Selenium and Javascript events

  1. >That was great…Got the solution for my problem..Thanks

  2. Rabia Naz Khan says:

    Thanks! 🙂 I figured out the solution for my problem!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s