Using regular expressions in xpath Selenium 

Here is an example where I have used regular expressions in xpath.
This article includes a code sample that demonstrates how you can use the starts-with XML Path Language (XPath) string function to implement this requirement.

Here is my HTML source code:

Abrasion Resistance

Access Panels

Access Solutions

Accessories

Acoustic Performance

Affordable Playground Equipment

Aged Care Facilities

Aggregates

Air Circulation

Air Conditioning Filter Cleaning

Air Conditioning Maintenance

Air Conditioning Services

Air Flow

Air Fresheners

Air Movement

Alarm Monitoring

Alfresco

Alternative Waterproofing

Aluminium Composite

Amplifiers

Anodising

Anti Slip

Anti Vandal

Anti-graffiti

Anti-Rust

Apartments

Appliances


Here is the verifyElement command in Java to verify for the xpath element.
verifyTrue(selenium.isElementPresent(“//*[starts-with(@id, \"c100Item_P\")]“));


Author: Pavandeep Puddupakkam on October 14, 2010
Category: Selenium RC
Tags: ,
Google Webdriver Forum -The Online Community for Google Webdriver and Selenium RC Users and Professionals
2 responses to “Using regular expressions in xpath Selenium”
  1. Felipe says:

    This is by NO MEANS using Regular Expressions in Selenium. You did use the standard XPath starts-with function. I hope Selenium uses XPath 2.0 so we can really use regular expressions.

Leave a Reply

Last articles