Using regexpi in selenium.isTextPresent() 

Here is an example where you can use regexpi in selenium.isTextPresent(). You can use regexpi when you are checking for the text but are not worried about the case-sensitivity if the text.

Say I am looking for the text “This is SeleniumWiki.com” and the text on the webpage is “This is seleniumwiki.com”; if you use selenium.isTextPresent(“This is SeleniumWiki.com”) your script will fail. To verify this you can use selenium.IsTextPresent(“regexpi:This is SeleniumWiki.com”)


try
{
Assert.IsTrue(selenium.IsTextPresent("regexpi:This is SeleniumWiki.com"));
}
catch (AssertionException e)
{
verificationErrors.Append(e.Message);
}

The regexp function is case sensitive in matching regular expressions to a string, and regexpi is case insensitive.


Author: Pavandeep Puddupakkam on October 20, 2010
Category: Selenium RC, Software Testing, Visual Studio 2010
Tags: ,
Selenium Webdriver Forum -The Online Community for Selenium Webdriver and Selenium RC Users and Professionals
5 responses to “Using regexpi in selenium.isTextPresent()”
  1. luciano says:

    Assert.IsTrue(Regex.IsMatch(selenium.GetText(webTouHeading), Control.Product +" example string", RegexOptions.IgnoreCase));

  2. Giribabu says:

    Displaying following error “line 18: ExecutionResult: Object reference not set to an instance of an object.” when i use following code “selenium.IsTextPresent(“regexpi:Prices Saved”

  3. Ravi Teja says:

    Hi , I am having similar requirement , i need to select a checkbox , i will get the checkbox name dynamically during the program execution. I need to select the checkbox ignoring case sensitivity , i have

    tried

    selenium.click(“css=td[class='dxeListBoxItem dxeT']:contains(“regexpi:”+str+””)”);

    but it is highlighting as error in eclipse .
    Please help me in solving this.

    ThankS & Regards
    Ravi Teja P.

Leave a Reply

Last articles