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

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
Krishna
  • 153
  • 4
  • 18
  • also i have tried with below WebElement Tab_selection = driver.findElement(By.cssSelector("h3[headerindex = 2h]")); Tab_selection.click(); – Krishna Apr 28 '15 at 21:17

1 Answers1

1

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

h3[headerindex="2h"]

And, xpath locator is always an alternative:

By.xpath("//h3[@headerindex='2h']")
Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195