dahngeek
2/10/2017 - 9:04 PM

Get all subitems without its items

Get all subitems without its items

// Ejemplo,
// <div class="property-info-agent clear">
//   <span><i class="fa fa-arrows-alt"></i><strong>Floor Area:</strong>234&nbsp;Mts²</span>
//   <span><i class="fa fa-bed"></i><strong>Habitaciones:</strong>3</span>
//   <span><i class="fa fa-male"></i><strong>Baños:</strong>2</span>
//   <span><i class="fa fa-car"></i><strong>Garaje:</strong>2</span>
// </div>


browser.execute(function(){
          var detalles = {};
          jQuery(".property-info-agent span").each(function(){
            var propiedad = jQuery(this).find("strong").text().trim();
            var valor = jQuery(this)
              .clone()    //clone the element
              .children() //select all the children
              .remove()   //remove all the children
              .end()  //again go back to selected element
              .text().trim();
            detalles[propiedad] = valor;
          });
          return detalles;
        });