Google Search

Friday, October 18, 2013

Working with radio Buttons & Lists in Selenium IDE - Day 4

In this post I will discuss

1.       Example to click & verify clicked Radio Button
2.       Example to check multiple items in a list, verify if they are checked.
3.       To extract the count of items in a list



Sample Code Used

<!DOCTYPE html>
<html>
<body>

<p><b>Note:</b> Sample Radio Buttons Script.</p>
<form action="">
<input type="radio" name="sex" value="male">Male<br>
<input type="radio" name="sex" value="female">Female
</form>

<p><b>Note:</b> Sample Drop Down Script.</p>
<form  action="">
<select name="cars" size="5" multiple="multiple">
 <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="vw">VW</option>
  <option value="audi">Audi</option>
</select>
</form>

</body>
</html>

Selenium Code



Decoding the selenium code

Example 1
Line 1 – Opening the desired Web Application. Command used: open
Line 2 – Clicking the desired radio button (female, in this case). Command used: click
Line 3 – Verifying that Radio button is clicked.Command usedverifyChecked

Example 2
Line 4 – Remove all defaults selections in the list. Command usedremoveAlllSelections
Line 5 – Select VW. Command used
Line 6 – Select Audi (Note different ways of selecting options). Command usedaddSelection
Line 7 – Verify that only 2 values i.e. ‘vw’ & ‘audi’ are selected. Command usedverifySelectedValues
Line 8 – Remove one of the Selections ‘VW’. Command usedremoveSelection

Example 3
Line 9 – Storing the count of items in list in a variable ‘count’. Command usedstoreXpathCount

Line10 - Displaying the value of variable ‘count’. Command usedecho

No comments:

Post a Comment