Acess Javascript Using Selenium IDE.

We can observe that some events on web page are functioning or firing without clicking on mouse. That type of  events are made using javascript. For example sometimes a button color is automatically changed when mouse is over the button or showing an alert message etc.
In this situations we may not be able to use selenium “click”  command to verify elements.
However we can made our test on selenium by using the following Firing events:

The fireEvent works against the following JavaScript events:
onFocus
onBlur
onChange
onSubmit
onMouseOut
onMouseOver

onFocus

The onfocus attribute use on web page to receive the focus of user attention.
For example, when a user click on a input field may change the color of the input field. Now describe how we can check or verify that our onFocus event is working properly on webpage.
Step-2: Click on Name input field.
Note: we can see that input field background color is changed. This is made by using javascript onfocus attribute.
Step-3: Now write selenium IDE commands as the followings:


Command
Target
Value
open
http://bdsqa.blogspot.com/p/practice-selenium.html

fireEvent
id=name
focus
verifyAttribute
id=name@style
background-color: rgb(255, 255, 0);


  • Selenium IDE window should be showing as the following:


1 comment: