Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3996646
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:18:16+00:00 2026-05-20T07:18:16+00:00

I must be overlooking something very obvious. What’s wrong with this XPath expression? I

  • 0

I must be overlooking something very obvious. What’s wrong with this XPath expression? I want to get a count of table rows which match a regex for id?

selenium.getXpathCount("//tr[matches(@id,'data-row-\\d+')]");

I’m getting:

com.thoughtworks.selenium.SeleniumException:
ERROR: Invalid xpath [2]:
//tr[matches(@id,’data-row-\d+’)]

Here’s sample html:

<table>
  <tbody>
    <tr id="data-row-0"><td>foo</td></tr>
    <tr id="data-row-1"><td>bar</td></tr>
    <tr id="data-row-2"><td>baz</td></tr>
  </tbody>
</table>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T07:18:17+00:00Added an answer on May 20, 2026 at 7:18 am

    Selenium 1.x does not support XPath 2.0. Hence you cannot use XPath 2.0 methods like matches(), replace() etc..

    You might want to consider XPath 1.0 methods like contains(), starts-with() etc.

    Also, to achieve your goal you can try

    //tr[starts-with(@id,'data-row-') and translate(@id,'0123456789','')]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I must be overlooking something terribly obvious. I need to execute a C program,
I must be overlooking something very simple here but I can't seem to figure
OK, I must be overlooking something silly because I am unable to get my
Ok I must be overlooking something extremely simple but I am lost. Given this
I must be overlooking something simple. I'm setting a variable from a query result
I must be going insane. This is incredibly simple so I am apparently overlooking
I've made snippets before but I must be overlooking something really simple; I cannot
I think I'm overlooking something simple here, I can't imagine this is impossible to
I am sure I am overlooking something very basic here, but I just don't
I'm new to jQueryUI and I think I am overlooking something very basic... Quick

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.