What is the method for accessing the HTML of the ElementFinder directly in the debugger without using a promise?

Upon analyzing the situation, I've come across an element named this.page.taskAssignment which is categorized as an ElementFinder. During my UI tests, when I attempt to click on this element, there seems to be no response. It has led me to believe that perhaps I am clicking on the wrong element; hence, I wish to verify what exactly is being clicked by examining the HTML in the debugger.

My endeavor with the WebStorm debugger involved:

this.page.taskAssignment.element.getTagName().then(e => {console.log(e)})
. However, despite my efforts, the output remains a promise without any sight of the HTML content.

Inquiry: How can I retrieve the HTML content of that specific element in the form of a string, rather than a Promise?

Answer №1

To retrieve the value, you can utilize the await keyword.

let formField = await element(by.formControlName(myField));
let formTag = await formField.getTagName();
let innerHtml = await browser.executeScript("return arguments[0].innerHTML;", formField);

(Previously, there was a getOuterHtml() method, but it has been removed by Selenium as per the protractor docs.)

If you encounter an error stating that you can only use `await` as a reserved word, it must be within an `async` function such as on your page object.

class myPageObject{
    async fillForm(myField) {
        let formField = await element(by.formControlName(myField));
        let formTag = await formField.getTagName();
        let innerHtml = await browser.executeScript("return arguments[0].innerHTML;", formField);

        // .... rest of code
    }
}

For more information on page objects, refer to https://www.protractortest.org/#/page-objects.

Answer №2

There are various methods to identify the specific element you want to access.

let targetElement: ElementFinder;

To retrieve the tagName: utilize await targetElement.getTagName() to obtain the tag name of the element.

To fetch a specific attribute of the element: use

await targetElement.getAttribute('class')
//if you desire the class name of the element. The same method can be applied to gather all attributes of the element finder.

Kindly note that all the above outputs will be in the form of a string.

I hope this information proves helpful to you

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

Implementing event triggers when setting a value for a date picker in Angular Kendo Date Picker

In my Angular form, I have two date pickers for selecting a start date and an end date. I need to ensure that the minimum value for the end date is set as the start date. To achieve this, I created a method that updates the min value of the end date whenev ...

Experiencing difficulty in transferring array information from a parent component to a child component within an

I'm currently working on a task where I need to pass data from a parent component to a child component. The data consists of an array that is nested within another array. parent.component.html <div *ngFor="let parent of parentArray; index as ...

I am unable to show a variable on the screen

Column Tariff 1: The variable FRAIS_ETRANGERS is associated with CODE:"NEK01". This variable is displayed in the template. Column Tariff 2: The variable FRAIS_ETRANGERS is linked to CODE:"NEK03". However, I am facing difficulties displ ...

Error message in Typescript with React: "The type 'ComponentClass<StyledComponentProps<{}>>' cannot be assigned to type 'typeof MyComponent'"

Currently experimenting with integrating the Material UI 1.0 (beta) @withStyles annotation into a React component. The documentation provides a JavaScript example (), however, it results in a compilation error when using Typescript. Despite the error, the ...

What is the process of applying arguments to a class constructor automatically?

In my code, there is an ES6 class called User and a global function named map(): class User { constructor(public name: string) {} } const map = <T, R>(project: (value: T) => R) => {} Instead of the usual way of calling map like this: map ...

Acquire multiple instances of NestJs dependencies using dependency injection within a single class

Below is a class called Product @Injectable() export class Product { brand: string; } I am injecting the Product class into ProductService export class ProductService { constructor(private readonly product: Product) {} update(products) { ...

Combine all the missing observables in RxJS into a single array

In my code, I am creating a NavBar with items that may require fetching extra information from an API and adding it to the subtitle field. I want to transform this into an Observable<NavItem[]> so that it can be rendered using an Async Pipe. Curren ...

Troubleshooting why the Typescript Omit property is not functioning correctly when used with the 'as' keyword

When both properties are needed during registration, but only one is necessary after, the system utilizes Firebase built-in functions for authentication and registration purposes. All other information will be stored in the Firebase user collection. The i ...

Remember to always call "done()" in Typescript + Mocha/Chai when dealing with async tests and hooks. Additionally, when returning a Promise, make sure it resolves correctly

It seems like I'm facing an old issue that I just can't seem to resolve, despite trying everything in my power. The error message reads: Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Pro ...

What is the process for linking to a Firefox instance using the debugger port?

I am attempting to perform remote debugging on a Firefox instance in a similar fashion to Chrome: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 By launching Chrome with this parameter, ...

There seems to be an issue with the React Native FlatList: It appears that there is no overload matching this call and some

I am currently learning React Native and attempting to create a basic chat room application. I am facing an issue with the FlatList component that I can't seem to resolve. Even though I have provided both the data prop and renderItem prop to the FlatL ...

The compatibility issue arises when using Material UI Portal with TypeScript, specifically with the 'children' property types

When rendering a component using Material-UI Portal that includes several Material UI buttons, the following code is used: <Portal container={this.myContainer}> <Button onClick={this.handleClick}>Do something</Button> //other but ...

Unable to retrieve input field in protractor testing

Struggling with accessing an input field in AngularJS/Protractor for testing purposes. Despite the app setting the input fields to their initial values when running on the browser, I am unable to interact with them or modify their contents during testing. ...

Update the function's argument type signature if the current argument is a function with properties

Looking for input on a potential title change, but for now, here are the details of my specific use case: I'm currently developing a library that facilitates executing methods remotely and accessing properties across serialized boundaries like those ...

Using absolute paths for templateUrl and styleUrls in Angular 6: A comprehensive guide

My angular application is filled with various components, but a recent requirement change forced me to switch from using relative URLs to absolute ones. Everything was going smoothly until I reached the templateUrl and styleUrls in the components. Despite ...

When trying to access a property in Typescript that may not exist on the object

Imagine having some data in JS like this example const obj = { // 'c' property should never be present a: 1, b: 2, } const keys = ['a', 'b', 'c'] // always contains 'a', 'b', or 'c' ...

A utility type in Typescript for managing default database schema values

I am currently exploring a method for incorporating default and virtual values in a database schema. The concept involves using a utility type to automatically convert a schema for insertion (props with defaults or generated by virtuals aren't necessa ...

Guide to locating the recursive function in Node.js runtime

As a beginner in the world of node and angular development, I have encountered a major issue - "FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory". Is there anyone who can help me identify the function ...

Error: The reference 'GetServerSideProps' is being incorrectly used as a type instead of a value. Perhaps you intended to use 'typeof GetServerSideProps' instead?

Index.tsx import Image from 'next/image' import Head from "next/head" import { sanityClient, urlFor } from "../sanity" import Link from 'next/link' import {Collection, address} from '../typings'; import ...

What is the most effective method for pausing execution until a variable is assigned a value?

I need a more efficient method to check if a variable has been set in my Angular application so that I don't have to repeatedly check its status. Currently, I have a ProductService that loads all products into a variable when the user first visits the ...