Monday, November 7, 2011

Some examples for global pattern

Some examples for global pattern , Selenium Notes, Examples,Videos, By.www.laxmiroy.blogspot.com/


Lets say your element looks like

<input class="foo" value="the text value" name="theText">

verifyEquals("*text*", selenium.getValue("theText"));

<input type="hidden" value="the hidden value" name="theHidden">

verifyEquals("* hidden value", selenium.getValue("theHidden"));

If you have drop down combo box then you can use global pattern matching .

<select id="theSelect">
<option id="o1" value="option1">first option</option>
<option selected="selected" id="o2" value="option2">second option</option>
<option id="o3" value="option3">third,,option</option>
</select>

select the second option and verify like this

assertEquals("second *", selenium.getSelectedLabel("theSelect"));
or,
String[] arr = {"first*", "second*", "third*"};

verifyEquals(arr, selenium.getSelectOptions("theSelect"));

The question mark ? indicates there is zero or one of the preceding element. For example, colo?r matches both "color" and "colour".

If your element is like
<input class="foo" value="the text value" name="theText">

verifyEquals("?oo", selenium.getAttribute("theText@class"));

No comments:

Post a Comment