I have been pondering this issue for the past few hours and haven't been able to find a solution. Essentially, I have a list structured like this
<ul class="list">
<li class="user">
<div class="name">Name</div>
<div class="surname">Surname</div>
</li>
<li class="user odd">
<div class="name">Name</div>
<div class="surname">Surname</div>
</li>
<li class="user">
<div class="name">Name</div>
<div class="surname">Surname</div>
</li>
<!--And so on....-->
</ul>
Here is how my nightwatch script is set up
.elements('css selector','.li',function(result){
console.log(result.value);
});
The result is an empty array []
My main question is what would be the most effective way to extract all the data in ul li div tags and output it as a JSON object using console.log?
Similar to:
{
"name": "name",
"surname": "Yaya",
},
{
"name": "name2",
"surname": "Yaya2",
},
If anyone can offer assistance or guidance on how to achieve this, I would greatly appreciate it.