-
Notifications
You must be signed in to change notification settings - Fork 29
Description
I have the following HTML which describes a patternfly vertical navigation:
<div class="nav-pf-vertical nav-pf-vertical-with-sub-menus">
<ul class="list-group">
<li class="active list-group-item"><a href="#"><span title="Foo"></span><span class="list-group-item-value">Foo</span></a></li>
<li class="list-group-item"><a href="#"><span title="Bar"></span><span class="list-group-item-value">Bar</span></a></li>
<li class="list-group-item"><a href="#"><span title="Credentials"></span><span class="list-group-item-value">Baz</span></a></li>
</div>
If I try to initialize the VerticalNavigation with a CSS locator like this:
nav = VerticalNavigation(locator=(Locator(css='.nav-pf-vertical')))
Then the function nav.select('Bar') does not work, and it cannot find the element to select it. It then returns the following error:
selenium.common.exceptions.NoSuchElementException:
Message: Could not find an element './ul/li/a[span[normalize-space(.)="Bar"] or @href="https://github.com/Bar"]'
The above error implies that it is starting from the top div nav-pf-vertical, but it is not when searching the ./ul/li/a/span path. Rather, the select() function works properly when I initialize the VerticalNavigation with the HTML tag directly below, of the list-group class in the ul tag:
nav = VerticalNavigation(locator=(Locator(css='.list-group')))
The select() function then behaves normally. I believe that either the function needs to be refactored to only search starting from the parent of the <ul> tag, or the search needs to check for both possibilities.