mardi 8 janvier 2019

ul li list items checked and save it in Nightwatchjs

I'm making something like news site and I need to do some testing with Nightwatchjs.

I need to make something like RSS and when testing the information to be send to API.

Here what i tried it

browser.elements('css selector','ul#feed-list', function (result) {
    els = result.value;
    var jsonString = "";
    els.forEach(function(el,j,elz) {
      browser.elementIdText(el.ELEMENT, function(text) {
        jsonString += text;
    })
  console.log(jsonString);
  })

Here the sample code to the from the site:

<html>
<body>
<div1>
<div2>
<div3>
<div class="tab-active">
<div class="full-content">
<ul class="media-list" id="list-feed">
<li class="block blog _feedBlog blog-feed" id="blog-******">
<div clas="news-body">
<div class="author">
<div class="title">
<div class="news-text">

****** is the id of the news. Tab active is the whole tab with news. full-content is also the whole feed under tab-active. So basic i need to read the last 10 items of the ul and if they are not already send it to the API to be send. I need title, author and newsText to be in varibles so i can send it and if something is missing or text is small size on the news to be notified.

Thanks!

Aucun commentaire:

Enregistrer un commentaire