PositiveGuy
PositiveGuy

Reputation: 47743

XPath Invalid Selector Error

I can't see why I get an invalid selector error in my XPath syntax here:

The given selector /*/tbody[@id='custContainer']/tr/td/a(starts-with(@href, 'Customers/') is either invalid or does not result in a WebElement. The following error occurred: [InvalidSelectorError] Unable to locate an element with the xpath expression /*/tbody[@id='dgContainer']/tr/td/a(starts-with(@href, 'Customers/') because of the following error: [Exception... "The expression is not a legal expression." code: "51" nsresult: "0x805b0033 (NS_ERROR_DOM_INVALID_EXPRESSION_ERR)" location: "resource://fxdriver/modules/atoms.js Line: 2398"]

This is a call I'm doing in Selenium using By.XPath. I also tried // instead of /*/ for the start of that path but not sure which to use...not sure of that's the problem or if it's some other part of my string here.

I also tried contains instead of starts-with.

FYI I'm new to Selenium and XPath....

Upvotes: 1

Views: 3550

Answers (1)

Kirill Polishchuk
Kirill Polishchuk

Reputation: 56172

Definitely your XPath expression is incorrect. Define predicate in square brackets, i.e.:

/*/tbody[@id='custContainer']/tr/td/a[starts-with(@href, 'Customers/')]

Upvotes: 0

Related Questions