Record collection of elements - JavaScript Angular

I am facing an issue with my page code. The code contains a list of items and I need to extract the values of Test, Application, Success, Error from these items. However, when I try to write this data to a file, it returns [object, Object]. Can someone please assist me in solving this problem?

 <div _ngcontent-c5="" class="grid-container">
  <div _ngcontent-c5="" class="grid-x">
    <div _ngcontent-c5="" class="small-12 medium-12 large-6 cell">Test:</div>
    <div _ngcontent-c5="" class="small-12 medium-12 large-6 cell">
      <!--bindings={
"ng-reflect-ng-if": "true"
}--><span _ngcontent-c5="" class="success">It works</span>
      <!--bindings={
"ng-reflect-ng-if": "false"
}-->
      <!--bindings={
"ng-reflect-ng-if": "false"
}-->
    </div>
  </div>
  <div _ngcontent-c5="" class="grid-x">
    <div _ngcontent-c5="" class="small-12 medium-12 large-6 cell">Application:</div>
    <div _ngcontent-c5="" class="small-12 medium-12 large-6 cell">
      <!--bindings={
"ng-reflect-ng-if": "false"
}-->
      <!--bindings={
"ng-reflect-ng-if": "false"
}-->
      <!--bindings={
"ng-reflect-ng-if": "true"
}--><span _ngcontent-c5="" class="error">Error</span>
    </div>
  </div>

This is how I am attempting to retrieve the data:

it('save to file', () => {
var fs = require('fs');

var area = element.all(by.css('.div.grid-container'));
var outputFileName = 'Output.json';
fs.writeFile(outputFileName, area, function(err){
if(err){
  console.log(err);
}
else{
  console.log("JSON saved to " + outputFileName);
}
});
});

Answer №1

If you want to save the object to a file, consider using the method JSON.stringify(area) to convert it into a JSON string first.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Preventing page navigation in JavaScript: Why it's so challenging

I am encountering an issue with a link element that I have bound a click event to (specifically, all links of a certain class). Below is an example of the link element in question: <a id="2" class="paginationclick" style="cursor: pointer;" href=""> ...

An error is triggered by serializing a TinyBox POST form into an Array

When I implemented the code below, it performed as anticipated: TINY.box.show({url:target, post:$("form[name='currentSearch']").serialize(), width:650, mask:true, close:true, maskid:'boxMask', boxid:'popupBox', openjs:funct ...

I am looking for a way to generate unique dynamic IDs for each input textbox created within a PHP while loop. Can

How can I retrieve the ID of a selected text box generated within a while loop in order to update a field similar to phpMyAdmin? <?php while($row=mysql_fetch_assoc($result)) { ?> <tr> <td><input type ...

Is the object returned by the useParams hook maintained across renders?

The book that is displayed is based on the URL parameter obtained from the useParams hook. The selected book remains constant across renders unless there is a change in the value returned by the useParams hook. I am curious to find out if the object retur ...

Acquire Content using jQuery and Navigate page horizontally

I am trying to achieve a unique effect by capturing content x and horizontally scrolling the page while the mouse is in motion, similar to swiping on a tablet. It seems simple enough.. Capture clientX on mousedown, ScrollLeft by ClientX while moving, Di ...

What method does jQuery Validation use to configure the validation message?

A custom method was developed for the jQuery validation plugin to validate whether a given value meets the length requirements set during validation. The method is structured as follows: jQuery.validator.addMethod("exactLength", function(value, ...

Improper comment placement in Rails with AJAX and JQUERY

I am developing a "comment system without page refreshing" using Jquery and Ajax. Within posts/show.html.erb <%= @post.title %> <%= @post.body %> <%= render 'comment %> posts/_comment.html.erb <%= link_to "Add Comment", new_po ...

Exploring the methods for monitoring multiple UDP ports on a single address in Node.js within a single process

I am currently working on developing a Node.js application to manage a small drone. The SDK provides the following instructions: To establish a connection between the Tello and a PC, Mac, or mobile device, use Wi-Fi. Sending Commands & Receiving Responses ...

When I attempt to run JavaScript code on the server, it fails to execute properly

When I run my code on my PC without putting it on the server, it works perfectly fine. However, when I upload it to the server and try to call it, I encounter the following error: Uncaught ReferenceError: crearLienzo is not defined at onload ((index): ...

Utilizing GCE API within my website

Currently, my goal is to retrieve GCE information in a read-only manner to showcase infrastructure data on my website. To achieve this, I aim to acquire an OAuth2 token using the JS API and then transmit it to a Python Backend for GCE API calls. It's ...

Enhancing Next.js SEO with 'use client' Metadata

Currently, I am facing an issue with my product page. The metadata for this page is fetched from the backend using an API that retrieves data from a database. To fetch this data and update it on the client side, I am utilizing a custom hook. However, the p ...

Learn how to use Bootstrap to position my component below another component on the webpage

Understanding the basics of Bootstrap and how to assign sizes to columns is one thing, but I seem to be stuck on a simple use case. Here is the scenario: I have two components for a Todo list application: Component 'New Todo' (Form Input field ...

Establish a connection with the ejabberd server as well as the application server

I manage an ejabberd server and am currently working on implementing a chat module within my Angular/NodeJS application. Within my setup, the Angular app directly connects to the chat server. I have a roster consisting of 100 contacts, some marked as onli ...

Experiencing a missing handlebars helper error when utilizing a helper within partials in express-handlebars

I have set up custom helpers using express-handlebars like this: const { create } = require("express-handlebars"); // Configuring the handlebars engine const hbs = create({ helpers: require("./config/handlebars-helpers"), }); app.engi ...

Implementing a switch to trigger a JavaScript function that relies on a JSON object retrieved from a GET request

Having some trouble using a toggle to convert my incoming Kelvin temperature to Celsius and then to Fahrenheit. It loads properly as default Celsius when the page first loads, but once I try toggling the function outside of locationLook, it doesn't se ...

Using the Ternary Operator in JavaScript to Dynamically Update HTML Elements with Angular

Is there a way to convert the code below into a ternary operator so that it can be used in an .HTML file? statusChange && statusChange === 'Employed' ? true : employmentStatus === 'Employed'; To clarify, I want to assign the re ...

The log level in Selenium 4.10 is not configured to ALL

I am facing an issue with Selenium where it only reads a portion of the log instead of the entire log. I am unable to extract all the URLs using Python, although this is possible with the browser's web tools. I suspect that the problem lies in the ina ...

Tips for creating a 360 x 235 degree FOV image using three.js

My camera captures round images with a 235-degree field of view, like this one: https://i.sstatic.net/qNfrX.jpg I am familiar with threejs and have successfully rendered 360x360 images as equirectangular projections. However, I want to use threejs to rend ...

What is the most efficient way to close the entire browser window while ensuring the webDriver remains active?

When running my batch execution, I encounter the issue of multiple browsers opening with multiple tabs for the first scenario. I need to close all these browsers before moving on to the second scenario. Using Driver.close() only closes one tab in the brow ...

In AngularJs, users can select multiple options using check-boxes, which will automatically generate a tag based on the selected choices. Additionally,

I am looking to implement a feature where users can make multiple selections using checkboxes. Based on their selections, tags will be created using an Angular directive. If a user selects multiple checkboxes, corresponding tags should be generated. If a t ...