"Troubleshoot Protractor test cases in IntelliJ with the help of the JavaScript debugger tool within

I'm having issues debugging my Protractor script in Intellij Idea 14. I followed the Debugger configuration mentioned in protractor/docs/debugging.md and tried putting a break-point against console.log to check the value of lblInvalidLoginMsg object:

it('should do something', function() {
  txtEmail.sendKeys("<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="37565656775644531954585a">[email protected]</a>");
  txtPassword.sendKeys("aaaaa");
  btnSignIn.click();
  lblInvalidLoginMsg.getAttribute('value').then(function(){
    console.log("hello");
  })

  expect(lblInvalidLoginMsg.getAttribute('value')).toEqual('Blah Blah');
});

The problem is that when the breakpoint is encountered, the debugger doesn't show any values. It only displays available methods like getText(), getID(), but not the expected values.

The console output looks like this:

‌‌lblInvalidLoginMsg.getId()
‌ElementFinder
‌‌lblInvalidLoginMsg.isElementPresent();
‌webdriver.promise.Promise

Even the "Evaluate" feature is not providing the expected results. Am I missing something here?

Update: I have included a screenshot with my script in Debug mode, debug config, and results from the Protractor console.

Answer №1

When working with Protractor, understanding promises is crucial. To access the actual values of an element's text or attributes, you must resolve them using the then() function. Here's an example:

element(by.id('#myId')).then(function(elm) {
    elm.getText().then(function (text) {
        console.log(text);  // set a breakpoint here
    });  
});

Alternatively:

lblInvalidLoginMsg.getAttribute('value').then(function(value) {
    console.log(value);  // in this case, 'value' will contain the attribute value
});

If you need to debug your Protractor code, you can use browser developer tools and execute protractor's client-side script commands. Check out this resource:

For additional insights on debugging Protractor tests, consider these references:

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

I'm facing an issue with my GraphQL resolvers due to a circular dependency

After modifying my repositories to directly return the GQL resolvers, everything was going smoothly until I encountered a circular dependency issue. Now, I have two repositories that rely on each other, creating a dilemma that JavaScript cannot easily reso ...

Altering the texture of a mesh in Three.js can completely transform the appearance

I'm facing an issue with my model that contains multiple meshes. I only want to apply a texture to one specific mesh, but when I do, the entire model ends up with the same texture. What could be the mistake I'm making? function load_models(callb ...

Navigating through drop down boxes with XPath

Having recently delved into Selenium automation testing, I am struggling to locate the Xpath of two drop-down boxes within our web application. Despite examining the HTML code for both elements, I have yet to accurately pinpoint the unique identifier. Alth ...

Using Twig: Transfer the content of a textfield as a parameter in the routing

I have a task of redirecting to another page while passing along the value from a textfield. Here is my current code: {% extends "base.html.twig" %} {% block body %} <button onclick="host()">Host the session</button> <button onclic ...

Guide to creating a parallax scrolling effect with a background image

My frustration levels have hit an all-time high after spending days attempting to troubleshoot why parallax scrolling isn't functioning for a single image on a website I'm developing. To give you some context, here's the code I've been ...

Iterating over a range of values with _.each()

Can someone help me figure out why my syntax is incorrect for applying two values from different iteratees (day.classes and event.part) on line 5? <div class="days"> <div class="headers"> <% _.each(daysOfTheWeek, function(day) { %&g ...

Include the document when the query results in zero documents

Struggling to figure out how to add a document to a collection if a query returns no results. The current query lacks operators for checking the length or size of the result. How can this be achieved? The query in question: this.monthCollection = this.af ...

Exploring ways to enhance the appearance of a Sidebar Widget Navigation using JQuery

When creating navigational items with submenus, such as 'Primary Fees', I added an arrow for visual indication. To enhance user experience, I included an animation that rotates the arrow and highlights the Main Menu item in red upon hovering. Thi ...

What is the best way to retrieve the last xpath executed or utilized by selenium webdriver?

Within my code, I have a method named clickButton which contains multiple try-catch blocks with X-paths. How can I determine which X-path was most recently executed by the driver? public void actions(String action, String param, Webdriver driver){ switc ...

npm fails to install the dependencies listed in the package.json file

I've encountered an unusual issue. I'm attempting to install project dependencies on my server using a simple npm i command, but it's not generating a node_modules folder. I've already tried various suggested solutions such as running ...

Is there a way to consolidate my current scroll script into a single function?

I have a script that enables smooth scrolling of contents within a div when hovered over certain anchor tags. I am considering consolidating the script into a function to eliminate the need for copying and modifying it each time I want to implement this f ...

The error message "NgFor only supports binding to Iterables such as Arrays" is triggered even though the JSON response is formatted as an array

Using TypeScript in CompanyComponent Class export class CompanyComponent { apiService : APIService; data : any; private companyUrl = 'http://localhost:4000/api/company/'; constructor(apiService : APIService) { this.apiService = api ...

Ways to include text with specific choices in a drop-down menu?

Within a form, I am encountering a situation where a select box's options are pre-selected through ajax based on a previously entered value. I am now seeking a way to append additional text to these pre-selected options only. for (i in data) { $("#my ...

Struggling to display the array after adding a new item with the push method

Seeking assistance in JavaScript as a newcomer. I have written some code to print an array once a new item is added, but unfortunately, it's not displaying the array. I am puzzled as there are no errors showing up in the console either. In my code, I ...

Guide on implementing vuechartkick in a Nuxt.js project

In the directory /plugin/vue-chartkick, I created a vuechartkick plugin. import Vue from 'vue' import Chartkick from 'vue-chartkick' import Chart from 'chart.js' Vue.use(Chartkick.use(Chart)) This is the nuxt template sectio ...

Retrieving data from a dynamically-created Ajax form

I am encountering an issue that I need help with. Using AJAX, I have generated a table dynamically which includes a form with checkboxes for item checking. Here is a snippet of the code: <form name="formdocs"> Followed by: <input type="checkbo ...

Strings holding special arrangements of breaks in between

Currently, I am developing a portal that enables examiners to provide a problem statement, sample input, and sample output. However, I am facing an issue where the sample input/output values are stored as complete strings, causing line breaks to not render ...

jquery script that retrieves the href attribute of the anchor tag located near the button that is currently being clicked

Hello there! I am trying to extract the href of a link when the button next to it is clicked by the user. However, the challenge is that there are multiple buttons and links on the page. For example, if the first button is clicked, I want to display "www. ...

resolved after a new promise returned nothing (console.log will output undefined)

Here is my Promise Function that iterates through each blob in Azure BlobStorage and reads each blob. The console.log(download) displays the values as JSON. However, when trying to close the new Promise function, I want the resolve function to return the ...

The deletion of columns is malfunctioning when using jQuery

When I click on number 2, it deletes the second column, which is working correctly. However, when I click on number 3, it deletes the number 3 instead of its column. The code snippet causing this issue is shown below: Can someone assist me in identifying ...