1
<h3 class="menuheader expandable " headerindex="1h"><span class="accordprefix"></span>

<h3 class="menuheader expandable " headerindex="2h"><span class="accordprefix"></span>
<h3 class="menuheader expandable " headerindex="3h"><span class="accordprefix"></span>

Our application is having the above headers. Each header is having the headerindex as an unique value to identify. I have used the below code:

WebElement Tab_selection = driver.findElement(By.cssSelector("<h3>[headerindex=2h]"));
Tab_selection.click();

But it is showing the exception:

invalid selector: An invalid or illegal selector was specified. Could you please help on that

1
  • also i have tried with below WebElement Tab_selection = driver.findElement(By.cssSelector("h3[headerindex = 2h]")); Tab_selection.click(); Commented Apr 28, 2015 at 21:17

1 Answer 1

1

You need to enclose 2h into quotes (explanation):

h3[headerindex="2h"]

And, xpath locator is always an alternative:

By.xpath("//h3[@headerindex='2h']")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.