Monday, November 7, 2011

Regular expression

Regular expression , Selenium Notes, Examples,Videos, By.www.laxmiroy.blogspot.com/


Regular expression patterns are the most powerful of the three types of patterns that Selenese supports.
Regular expressions are also supported by most high-level programming languages, many text editors and a host of tools, including the Linux/Unix command-line utilities grep, sed, and awk.

regexp (wildcard) matching


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

verifyEquals("regexp:^[a-z ]+$", selenium.getValue("theText"));

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

verifyEquals("regexp:dd", selenium.getValue("theHidden"));


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

assertEquals("regexp:second .*", selenium.getSelectedLabel("theSelect"));

verify Attributes using regular expression

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

verifyEquals("regexp:^f", selenium.getAttribute("theText@class"));

verifyEquals("regex:^[a-z ]+$", selenium.getValue("theText"));

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

assertEquals("exact:second option", selenium.getSelectedLabel("theSelect"));

String[] arr = {"regexp:^first.*?", "second option", "third*"};
verifyEquals(arr, selenium.getSelectOptions("theSelect"));

No comments:

Post a Comment