user2744620
user2744620

Reputation: 439

Protractor - Identifying Ui-Sref link

I am trying to identify the links on the following html by the following. I have installed linkUiSref by using npm. But i am still getting object has no method linkUisref. Please advise.

element(by.linkUiSref(element(by.css('#monitoring-tab > ul > li:nth-child(2) > a'))))

    <nav id="monitoring-tab" class="pure-menu pure-menu-open pure-menu-horizontal ng-scope">
  <ul>
    <li ui-sref-active="pure-menu-selected" ng-hide="hideTab.now" class="pure-menu-selected">
      <a ui-sref="app.monitoring.real-time" href="#/monitoring/real-time">
        Now
      </a>
    </li>
    <li ui-sref-active="pure-menu-selected" class="">
      <a ui-sref="app.monitoring.historical.day" href="#/monitoring/historical/day">
      Day</a>
    </li>
    <li ui-sref-active="pure-menu-selected" class="">
      <a ui-sref="app.monitoring.historical.month" href="#/monitoring/historical/month">
      Month</a>
    </li>
    <li ui-sref-active="pure-menu-selected" class="">
      <a ui-sref="app.monitoring.historical.year" href="#/monitoring/historical/year">
      Year</a>
    </li>
    <li ui-sref-active="pure-menu-selected" class="">
      <a ui-sref="app.monitoring.historical.lifetime" href="#/monitoring/historical/lifetime">
      Lifetime</a>
    </li>
  </ul>
</nav>

Upvotes: 2

Views: 1731

Answers (1)

Leo Gallucci
Leo Gallucci

Reputation: 16722

Usage:

by.linkUiSref(toState, [parentElement]).

toState is a String that represents a ui-router state.

You're passing an ElementFinder instead of a String ... so do:

$('#monitoring-tab').element(by.linkUiSref('app.monitoring.historical.month'));

Can also do:

$('#monitoring-tab').element(by.linkText('Month'));

Upvotes: 1

Related Questions