2

I am trying to refer to a class using classname with selenium but the same class got a hidden tag with exactly same name and all other values except ng-show=false

AS below:

ul class="nav nav-pills nav-stacked ng-hide" ng-show="false" <br>
ul class="nav nav-pills nav-stacked"

How can I refer to the second tag?
I didn't try @tabIndex as sometimes, the hidden tags are more than one.

Guy
  • 46,488
  • 10
  • 44
  • 88
SFstarter
  • 35
  • 7

1 Answers1

2

You can find by the missing class ng-hide. Find element witch has the classes nav nav-pills nav-stacked but not ng-hide

driver.findElement(By.cssSelector(".nav.nav-pills.nav-stacked:not(.ng-hide) > div"));

Or by not having ng-show="false"

driver.findElement(By.cssSelector(".nav.nav-pills.nav-stacked:not([ng-show='false']) > div"));
Guy
  • 46,488
  • 10
  • 44
  • 88
  • Sorry for not framing the question correctly earlier. But I am trying to refer the Div Class tag with in the ul class that I mentioned above. This div class tag doesnt have ng-hide/show mentioned. Hope I am clear here.. Thanks in advance. – SFstarter Mar 22 '16 at 21:20
  • @megan assuming the `
    ` tag is the direct child just add `> div` at the end, this will give you direct child with `
    ` tag. I added it to my answer as well.
    – Guy Mar 22 '16 at 21:24
  • yes but its giving all the div tags with in. Can I limit it to the very first div tag. Thanks – SFstarter Mar 22 '16 at 21:34
  • Got it working by giving the classname along with the div. Thanks for your help! @Guy – SFstarter Mar 22 '16 at 21:48