RE: Regular expression in xpath


Hi Lakshay,
I would like to know how do we use Regular expression in finding elements using xpath in Selenium Webdriver.
In my current project,one page contains multiple checkbox items with all most similar pattern in xpath,  I am wondering whether can I use xpath instead of creating elements for each of the checkboxes.
One check box xpath is
another checkbox xpath is
another is, html/body/center/div/table/tbody/tr/td/div[2]/form/table[2]/tbody/tr/td[1]/table[2]/tbody/tr/td/table[2]/tbody/tr[16]/td[1]/input

How can I optimize the code by the use of regular expression in xpath without creating elements for each checkboxes.
Your help is really appreciated.


Nisha Train Asked on November 17, 2014 in Selenium WebDriver.

Hi Nisha,

Both the solutions are good below by Ankit & Vishal. Please close your question:

Lakshay Sharma

on November 18, 2014.
Add Comment
3 Answers

Thank you for your replies

Train Answered on November 18, 2014.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.