Searching for a table element and clicking it based on its text with Protractor

<tr id="item" ng-repeat="item in itemList>
   <td id="code" ng-repeat="column in columns">Different Text</td>
</tr>

I have encountered some similar issues before, but I am still struggling to find a solution. Here is what I have attempted so far:

element.all(by.repeater('column in columns')).findElement(by.id('code')).getText('Different Text').click();

UPDATE:

<tr ng-repeat="item in items>
<td>{{item.name}}</td>
<td>{{item.description}}</td>
</tr>

This produces the following output:

<tr>
<td>New Name</td>
<td>Different Text</td>
</tr>
<tr>
<td>Another Name</td>
<td>Another Text</td>
</tr>

and so on

Answer №1

To achieve this, you must use the filter() method on the element you want:

var columns = element.all(by.repeater('column in columns'));
columns.filter(function (elm) {
    return elm.getText().then(function (text) {
        return text == 'Some Text';
    });
}).first().click();

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

AngularJS issue - [$compile:multidir] Encountering a problem with multiple directives

Currently, I am utilizing two packages for my project. The first one is an angularjs modal from the angular-ui package, which can be found at http://angular-ui.github.io/bootstrap/#/modal. The second package is Angular-flexslider, sourced from https://gith ...

Grouping items by a key in Vue and creating a chart to visualize similarities among those keys

I am working with an object that has the following structure; { SensorA: [ { id: 122, valueA: 345, "x-axis": 123344 }, { id: 123, valueA: 125, "x-axis": 123344 }, { id: 123, valueA: 185, "x-axis": 123344 }, { ...

Error callback not being invoked on save() method in AngularJS service

So I am currently using the AngularJS Restful Service $resource in my project. However, when I try to call the $save function and provide an error callback, it does not get invoked. Surprisingly, even though the server sends a 418 error, which is not a suc ...

Sharing a state object with another React file can be accomplished by using props or context to

My first React file makes an API call to retrieve data and save it in the state as Data. import React, { Component } from "react"; import axios from "axios"; import Layout from "./Layout"; class Db extends Component { constructor() { super(); th ...

Upon refreshing the browser page, AngularJS fails to redirect to the default page as expected

In my AngularJS route configuration, I have set up the following paths: moduleA.config(function($routeProvider){ $routeProvider. when('/A',{templateUrl:'A.jsp'}). when('/B',{templateUrl:'B.jsp'}). wh ...

Retrieve tabs according to the value selected in the dropdown menu

When a value is selected from a dropdown with options 1 to 5, I want to display a corresponding number of tabs. Below is the HTML code for the select box: <select id="Week" name="Week"> <option value="1">1</option> <option val ...

Changing a JSON String into a JSON Object

Utilizing AJAX, I am sending a PUT request to a RESTful web service. Before making the request, I convert the data returned from form submission (using ng-submit) into a JSON String: var serializedData =angular.toJson(person); Subsequently, I include it ...

Error code TS7053 occurs when an element implicitly has an 'any' type because a string expression cannot be used to index an empty object

I have implemented a code snippet that sorts items into groups based on their first character. For example, if the array of item looks like this: {name: 'Foo'} {name: 'Bar'} {name: 'Baz'} The expected result should be: B: ...

Having trouble transferring files to an unfamiliar directory using Node.js?

const { resolve } = require("path"); const prompt = require('prompt'); const fsPath = require('fs-path'); // Retrieve files from Directory const getFiles = dir => { const stack = [resolve(dir)]; const files = []; whi ...

The convergence of lighttpd with AngularJS's html5 mode offers a powerful

My angularJS website is hosted on a lighttpd server, but the html5 mode encounters a 404 error when I refresh or use a direct link. On my local Apache server, everything works fine and there are no issues with the rewrite expression in the .htaccess file. ...

What is the best way to leave a comment on a user's Instagram post using Senium?

Currently, I am utilizing the Selenium library in Python to execute a code that emulates typical human actions on Instagram. However, this particular action seems to be unattainable, almost as if Instagram has prohibited it altogether. I am attempting to ...

Ways to determine if the keys of an object are present in an array, filtered by the array key

Working on an Angular 2 Ionic application and I'm wondering if there's a straightforward way to filter individuals by age in a specific array and then verify if any key in another object matches the name of a person in the array, returning a bool ...

Sending AJAX data from VIEW to CONTROLLER in PHP (MVC) using AJAX: A step-by-step guide

I have a page at http://visiting/blog. The Controller contains two methods: action_index and add_index. When Action_index() executes, it returns pages with indexes. On the other hand, Add_index() invokes a model's method called add_data(), which inse ...

What is the best way to allow someone to chain callback methods on my custom jQuery plugin?

My goal is to enhance the functionality of jQuery.post() by implementing a way to check the response from the server and trigger different callbacks based on that response. For instance: $("#frmFoo").postForm("ajax") .start(function () { showSpinner( ...

A JavaScript code snippet that stores the total number of bytes read from a CSV file in a variable

I currently have a CSV file located on a web server that is regularly updated with numeric and string data of varying lengths. I am seeking a solution to calculate the total byte values of each row when reading the file, as the byte count is crucial due ...

What is the proper way to halt an iteration with the $q service in AngularJS

Trying to incorporate the $q service to introduce a pause in the iteration due to a condition that requires making API calls within a loop. Implemented the following method: function fetchData(id){ var deferred = $q.defer(); var data; Restangula ...

The React Bit Dev module is showing a 404 error

Attempting to incorporate the semantic-ui-react table reusable component from the Bit.dev community into my application. The link I am using is: To add this component to your application, use: npm i @bit/semantic-org.semantic-ui-react.table However, when ...

Change the font awesome class when the button is clicked

Here is the code I have in this jsfiddle. I am trying to change the font awesome icon on button click using javascript, but it doesn't seem to be working. I am new to javascript, so please pardon me if this is a silly question. HTML <button id="f ...

Assigning an identification number to specify the type of Chip

I am currently working on a project involving Material UI "Chips" that contain text and serve as references. Within the context of my project, I have Chips for both White Advantages and Black Advantages sections. However, there are instances where these Ch ...

Inspecting the final element of my jQuery slider

I've been working on a jQuery slider where I add the class "currentmemory" to each child of my memory2container to show which slider is displayed. The issue arises when I reach the last slider; instead of looping back to the first one and starting ov ...