Skip to content

VerticalNavigation select() method needs strange initialization to function #65

@dsesami

Description

@dsesami

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions