How to get text/value of a ul > li element in nightwatch

1,656 views
Skip to first unread message

Jazz Bamrah

unread,
Dec 17, 2017, 11:59:12 PM12/17/17
to NightwatchJs
Hello All,

I basically want to get the li that contains the text 'ABC business'

<ul role="listbox" class="">
  <li role="option" id="react-autowhatever-1" class="y2ft6f-0-autosuggest__Styled-kpKbJF" data-section-index="0" data-suggestion-index="0">
      <a href="#">
          <div class="suggestion__thumbnail"></div>
          <div class="kpKbJF ghfVrI__suggestion__text__business-name"><!-- react-text: 693 -->ABC business<!-- /react-text -->
          <div class="y2ft6f-0-autosuggest__Styled-kpKbJF ghfVrI__suggestion__text__location"><!-- react-text: 695 -->Golden Square<!-- /react-text --><!-- react-text: 696 -->
          <!-- /react-text --><!-- react-text: 697 -->VIC<!-- /react-text -->
          </div></div>
      </a>
 </li>
<li>
  <a></a>
</li>
</ul>

I tried using the below but result.value return some [object] but how can I assert the value. Please help!!
return client
.elements('css selector', '#react-autowhatever-1-section-0-item-0 > a > div.y2ft6f-0-autosuggest__Styled-kpKbJF.ghfVrI__suggestion__text__business-name', function(result){
console.log('result.value = ' + result.value);
});

Eric Mumford

unread,
Dec 18, 2017, 10:41:04 PM12/18/17
to NightwatchJs
STOP
How have you verified that the CSS identifier is correct?

THINK
Evaluate using the tools at your disposal such as the JS console and document.querySelectorAll().

ANALYZE
Think through what you have tried here to us and what you've discovered. Posit conceptual crossings that you find uncrossable.

RESPOND
To us with that information.

Eric Mumford

unread,
Dec 18, 2017, 10:42:33 PM12/18/17
to NightwatchJs
What does this give you in the JS console:


document.querySelector('.suggestion__text__business-name').innerText
Reply all
Reply to author
Forward
0 new messages