Unable to interact with the existing xpath element

I am having trouble locating a specific element in Protractor while using Protractor + Jasmine + POM. Interestingly, I can find the element with count 1 in the developer console.

Despite adding a try and catch block for element location, it always ends up in the catch block.

//let erasertype = element(by.xpath("//a[@data-tool='Eraser']"));
let erasertype = element(By.xpath("//a[@data-tooloption='eraser']"));
this.selecterasertype = async () => {
    try {
        await erasertype.click();
    }
    catch (err) {
        console.log("Unable to select erasertype");
    }

Answer №1

element(By.xpath(`//a[@data-tooloption='raser']`))

Switch the ' and ".

To construct a flawless string, utilize template literals ``.

To verify, capture the error object and display it.

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

Send a substantial item for display using Express Layout

Utilizing Express layouts to render my webpage upon accessing a specific route: The current project I am developing is an admin panel designed for editing a substantial table of data (imagine a website dedicated to managing thousands of product entries, fo ...

Leveraging a function for filtering in AngularJS

I have developed an application where the content filter changes depending on which button is clicked. I have managed to figure out the straightforward filters, but now I am attempting to create a filter that displays content within a specified range. Bel ...

Can you explain the use of the "left" and "right" fields in the jstree jQuery plugin?

Currently, I am working on creating a tree using the jquery plugin jstree. While going through this plugin's database file, I came across two fields called "left" and "right". However, I am unclear about how these fields are utilized. Interestingly, ...

Checking an array of objects for validation using class-validator in Nest.js

I am working with NestJS and class-validator to validate an array of objects in the following format: [ {gameId: 1, numbers: [1, 2, 3, 5, 6]}, {gameId: 2, numbers: [5, 6, 3, 5, 8]} ] This is my resolver function: createBet(@Args('createBetInp ...

Printing Multiple Pages Using JavaScript and Cascading Style Sheets

Encountering difficulties displaying page numbers when printing multiple multipage reports Here is the provided HTML Format : <style type="text/css> body { counter-reset: report 1 page 0; } td.footer:after { counter-increment: page; content ...

Submitting form data including file uploads using AJAX

Currently, the file is being sent via AJAX using the following code: var fd = new FormData(); //additional actions to include files var xhr = new XMLHttpRequest(); xhr.open('POST', '/Upload/' + ID); xhr.send(fd); In ...

Ways to transform a foreach loop into a promise-based operation

I have a function that recursively deletes nodes: removeNode(data.toString()) function removeNode(node){ Item.findByIdAndDelete(node).then(()=>{ Item.find({parent: mongoose.Types.ObjectId(node)}).select('_id').then((nodes)=>{ ...

The click event handler in a basic Vue application is failing to work with a button

In my Vue.js project, I have implemented a button that toggles the showProduct property between true and false when clicked. Here is the HTML code: <div id="app"> <button v-on:click="showCheckout">Click Me</bu ...

Avoid excessive clicking on a button that initiates an ajax request to prevent spamming

When using two buttons to adjust the quantity of a product and update the price on a digital receipt via ajax, there is an issue when users spam the buttons. The quantity displayed in the input box does not always match what appears on the receipt. For in ...

When implementing getStaticProps and getStaticPaths in a dynamic route, a 404 error page is displayed

As someone new to Next.js, I decided to delve into creating a basic news website where I could access articles through this specific route: /[category]/[article] The directory structure of pages is organized as follows: _pages __[category] ____index.jsx ...

The element is inferred to have the 'any' type. No index signature matching the parameter type 'string' was found on the 'User1' type

I have been experimenting with computed properties in TypeScript, but I've encountered a specific issue: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'User1'. ...

The special function fails to execute within an "if" condition

As a newcomer to JavaScript/jQuery and Stack Overflow, I kindly ask for your patience in case there are any major errors in my approach. I am currently developing an HTML page with Bootstrap 3.3.7, featuring a pagination button group that toggles the visib ...

Angular Promises - Going from the triumph to the disappointment callback?

It seems like I might be pushing the boundaries of what Promises were intended for, but nonetheless, here is what I am attempting to do: $http.get('/api/endpoint/PlanA.json').then( function success( response ) { if ( response.data.is ...

Guide on incorporating a condition in the Promise prototype method then()

Currently, I am utilizing axios to retrieve data from an API and I'm in need of implementing a conditional statement based on the received data: axios.get('https://api.url.endpoint).then(response => ()) Can someone guide me on how to create ...

Validating optional fields in React

My registration form includes the following fields: Name Email Password Confirm password Optional field Select role (student, professor, secretary) Here's what I'm trying to achieve: If I want to create a user with a student role, the optional ...

Encountering a 'JSON parsing error' while transmitting data from Ajax to Django REST Framework

I've been encountering an issue while trying to send a JSON to my REST API built with Django Rest Framework. Every time I make this request, I receive an error message, regardless of the view I'm accessing. I suspect the problem lies in the AJAX ...

Security ExpoStore malfunctioning (React Native, TypeScript)

I am currently developing a mobile phone application that utilizes Stripe and Expo Bar Code Scanner. Upon launching the application, if camera permissions are granted, users can scan bar codes which contain only the id of the scanned item. If the item exis ...

php utilizing javascript to generate encrypted data for a hidden file

Within my MVC application, I have implemented Raty for rating images. Below is the code snippet: <div class="container"> <form method="post" class='form' role='form' action="?section=photo&view=addVote"> <input t ...

Tips on choosing a text option from a selection menu

When I try to retrieve the text displayed in my select menu upon selection, I encounter a challenge. While this.value allows me to fetch the value, both this.label and this.text return as undefined. Is there a method to extract the visible text from the d ...

Extract form input to utilize in nodemailer

Currently I am working on a form implementation where I intend to utilize nodemailer for sending test emails to myself. My goal is to have the email inputted into the form dynamically appear in both the "to" and "subject" fields when the user submits the f ...