I am trying to automate a pretty trivial scenario where I have to get the text inside multiple li
child elements of a ul
elements and compare it against a given array. I am using Protractor with Cucumber JS and using async/await
to manage promises.
My scenario HTML looks something like this
<div class="some-class">
<ul class="some-ul-class">
<li>
<span>Heading1: </span>
<span class="some-span-class> Value of Heading 1</span>
</li>
<li>
<span>Heading2: </span>
<span class="some-span-class> Value of Heading 2</span>
</li>
<li>
<span>Heading3: </span>
<span class="some-span-class> Value of Heading 3</span>
</li>
<li>
<span>Heading4: </span>
<span class="some-span-class> Value of Heading 4</span>
</li>
<li>
<span>Heading5: </span>
<span class="some-span-class> Value of Heading 5</span>
</li>
I need to get the values of the first span element i.e the Heading1
, Heading2
texts. I saw a lot of approaches in SO, but none of them have resulted in a solution. Most of the solutions do not have async/await
implemented and if I try them, the code doesn't do what it is intended to do.
Examples I've referred : Protractor Tests get Values of Table entries Protractor : Read Table contents
If I try using the map
function inside the async
block, but that resulted in a ECONNREFUSED
error, and hence has been suggested not to do so here.
Would appreciate if someone can guide me towards a solution on this one.