Angular Protractor

I am attempting to choose all of the tasks on . Unfortunately, only the first one is being updated. What can I do to select all of the elements:

element.all(by.repeater('todo in todoList.todos')).then(function(rows) {
    for (var i = 0; i < rows.length; ++i) {                
        element.all(by.repeater('todo in todoList.todos')).get(i).element(by.model('todo.done')).click();
    } 
});

Answer №1

To achieve this, utilize the .each() method:

var items = element.all(by.repeater('item in itemList.items'));
items.each(function(item) {
    item.element(by.model('item.selected')).click();

    browser.sleep(2000);  // custom delay 
});

Answer №2

let tasks = element.all(by.repeater('task in taskList.tasks'));
tasks.get(1).click();
tasks.get(2).click();

When using element.all, it gathers all elements from the specified locator and get() allows you to select a specific element, similar to working with an array.

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

Tips for uploading a jpg image to the server using react-camera

My objective is to transfer an image captured from a webcam to a Lambda function, which will then upload it to AWS S3. The Lambda function appears to work during testing, but I'm struggling to determine the exact data that needs to be passed from the ...

Combining three.js geometry and selecting objects with an octree

I have been utilizing Three.js to showcase a variety of custom geometries in different positions and rotations. These geometries are static and do not change frequently, but users have the ability to manipulate them by adding, deleting, or altering the sha ...

Can a SVG Animation be created featuring a progress ring with both the right and left dash offsets moving simultaneously?

Currently in my codepen, I am working on a project where I am using GSAP. If you are unfamiliar with that, no worries - just focus on the dashoffset and dasharray in the SVG circulation path. You can find this project in Codepen which is part of our premi ...

"Utilize browser detection to direct users to appropriate pages - whether by using htaccess or another method

I'm in the process of creating a website and I've noticed that it looks quite bad on Firefox and IE. I was wondering if you could help me figure out how to redirect users to different pages based on the browser they are using. Since I am not an ...

Display the flowplayer div when the anchor is clicked

I have a dynamic CGI page that displays a list of files. The number of files varies based on uploaded content, so I am looking to create previews for video files. Below is a snippet of HTML code: <TMPL_LOOP files> <tr> <td&g ...

What is the best way to incorporate callback/await into my code?

After spending a considerable amount of time on my code, I've been struggling to incorporate callbacks, awaits, or any necessary elements with no success. The main query is, how can I delay the response until I receive callbacks from both functions? ...

Angular loop is unable to detect changes in the updated list

My Angular application is facing a peculiar issue that I can't seem to figure out. // Here are the class attributes causing trouble tenants: any[] = []; @Input() onTenantListChange: EventEmitter<Tenant[]>; ngOnInit(): void { this. ...

Layers in leaflet not displaying styles

Having trouble styling the layers received from a server. I've tried using the layer.setStyle() function and defining the style when creating the layer, but nothing seems to work. Here's how my code looks: var stateStyle = { "color": "#3D522 ...

How to successfully send data props from child components to parent in Vue3

I am currently working on a personal project to add to my portfolio. The project involves creating a registration site where users can input their personal data, shipping information, and then review everything before submission. To streamline the process ...

"Effortless integration of JavaScript with PHP for streamlined database access

My current project involves working with a database table containing two fields - one for URLs and the other for descriptive text. These fields will be updated regularly by a separate script. The task at hand is to create a timer that checks the database ...

Having difficulty accessing a PHP ajax post request

I've scoured every resource but can't seem to find a solution to this issue. I'm in the process of writing an ajax script, however, I am struggling to retrieve the correct value from the POST request. Here is the code I have so far: <t ...

The CSS files undergo modifications when executing the command "npm run dev"

I've been working on an open-source project where I encountered a bug. Even when there are no images to display, the "Load More" button in the web browser extension still appears. To fix this, I decided to add the class `removeButton` to the button an ...

Radio buttons with multiple levels

Looking to implement a unique two-level radio button feature for a specific option only. Currently, I have written a logic that will display additional radio buttons under the 'Spring' option. However, the issue is that when it's selected, t ...

Changing the value of an object property in JavaScript through mapping

Hey there! I've got a query. So, I have this array of objects and my goal is to convert the id of each object in the array into uppercase. Initially, I accomplished this using the following lines of code: let x = [ { id: "anc",path: "kdsfjdklsfj" ...

Express js routing issue ("Page Not Found")

Why do I receive a "Cannot GET /" message when I access my HTTP server at http://localhost:8000/? I am using Express JS for server-side routing and Angular for client-side. Some sources suggest that this error occurs because I haven't set a route for ...

Ensure that the token remains current with each axios operation

I need to access an Express REST API that demands a valid json web token for certain routes. In order to include the token from localstorage every time I needed, I had to create an "Axios config file". My http.js file includes the code below: import Vue ...

Leveraging AngularJS directives and $scope autonomously

Let me provide some context first: Previously, my focus was on developing lightweight, single-page Angular applications. However, in the past few days, I began working on a new project that combines Tapestry and Backbone. It has proven to be quite overwhe ...

Instructions on setting div opacity when Overflow is set to visibleExplanation on setting opacity for div with Overflow

In my HTML code, I have a div element and an image tag stacked one on top of the other. The div is smaller than the image. I have set the overflow property to visible for the div. My query is, when I add an image to the image tag, the content that overflow ...

AngularJS, ExpressJS, and Mongoose form a powerful trio of technologies

After successfully creating an API that sends JSON data to my AngularJS application, I encountered a problem when trying to view only one result using findById: exports.findById = function (req, res) { return ContactModel.findById(req.params.id, funct ...

Is There a Lack of 'Contains' Support in JavaScript's ScriptEngine?

Below is some code that I am working with. ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("JavaScript"); engine.eval("[1, 2, 3].contains(1)"); However, when I run the code, it throws the following e ...