Michau
Michau

Reputation: 59

xPath element location - selenium

Have following source on the webpage , what I want is to click on the button which is under class fa fa-repeat. Tried to use xpath = "//*[@id=\"accountsList\"//following-sibling::i[@class='fa fa-repeat']" but it doesn't work. Could anyone help/explain me why ? And what could be the best alternative to locate such elements (not necessary via xpath, could be css selector as well) ...

My HTML code is as below:

<li class="list-group-item">
    <div class="row account-item">
        <div class="col-xs-10">
            <span class="label label-danger account-status">O<br>F<br>F</span>
            <div><b>assssss</b></div>
            <div>company</div>
        </div>
        <div class="col-xs-2 text-right">
            <i data-account="ababa" class="fa fa-repeat"></i>
            <i class="account-options fa fa-ellipsis-v" data-toggle="dropdown"></i>
            <ul class="dropdown-menu" role="menu">
                <li>
                    <a data-account="fds" class="account-option toggle-active">
                        <i class="fa fa-play"></i> Start </a>
                </li>
            </ul>
        </div>
    </div>
</li>

Upvotes: 0

Views: 175

Answers (1)

har07
har07

Reputation: 89285

The target i element is not sibling of *[@id='accountsList'] but descendant :

//*[@id='accountsList']//i[@class='fa fa-repeat']

or using more specific path :

//*[@id='accountsList']/div/div/i[@class='fa fa-repeat']

Upvotes: 1

Related Questions