Thursday 3 October 2013

How to use Regular expressions in IDE selenium plugin in with example



Using Regular Expression Patterns with selenium
Regular Expression Patterns is another matching text pattern which describe text pattern to selenium.There are another two matching text patterns(Globing Patterns and Exact Patterns) are available but this is the most powerful matching text pattern from all these three.Regular Expression Pattern describes expected text.
Pattern to selenium using some special characters rather than specifying that exact text.You need to use text”regexp;” at the beginning of your text pattern to describe it as a Regular Expression and then you have to write  your expression.Example so that you can understand it better.
Using Regular Expression Pattern to click on link in selenium
New Test
Command
Target
Value
open
http://software-testing-tutorials-automation.blogspot.in/

clickAndWait
link=regexp:.*bo.* M.*

In above example “clickAndWait” command will click on About Me” link on home page.In”link=regexp;*bo.*M.*”, word ”regexp;” describes that this is regular expression and “ .*bo.*M.*” is the expected text pattern for link “About Me”.
Using Regular Expression Pattern to select label from drop down in selenium
New Test
Command
Target
Value
open
http://www.ebay.com

select
gh-cat
label=regexp:.*am.* P.*

In this  example, “select” command will select “Cameras & Photos” from the search categories drop down on ebay store.
Using Regular Expression Pattern verify dynamic text pattern

New Test
Command
Target
Value
open
http://software-testing-tutorials-automation.blogspot.in/2013/06/matching-text-patterns-globbing.html

verifyTextPresent
regexp:Friday.*[0-9]{4}


Here “verifyTextPresent” will verifies the text. In this regular expression,[0-9]{4} describes the 1 to 4 digits(for year)



No comments:

Post a Comment