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

What is the best method for accessing a local html file using Selenium Safari WebDriver on macOS?

I attempted: safariDriver.get("file:///Users/pathToMyHtml/index.html"); safariDriver.get("/Users/pathToMyHtml/index.html"); Unfortunately, neither of these methods were successful. I am using Java on a macOS Sierra system. (Interestingly, if the page is ...

Issue: EPERM - Unable to perform action, scan directory 'C:/Users/ . . . /node_modules/react-native-gesture-handler/android/'

Every time I execute the command: npx react-native run-android An error message is displayed as follows: Error: EPERM: operation not permitted, scandir 'C:/Users/ . . . /node_modules/react-native-gesture-handler/android/... Even after running the C ...

Creating an interactive map on an image using HTML and drawing circles

I've been experimenting with drawing circles on images using the map property in HTML. I have an image set up, and when clicking on the image in JavaScript, I'm adding the area coordinates for the map property. However, I keep encountering a null ...

What is the method for verifying PHP information using jQuery AJAX?

On my PHP page, I have an else statement that filters data from a SQL database based on user input. Below is some pseudo code: NextPage.php //Include database configuration file include('../dbConfig.php'); if(isset($_POST['pageno']) ...

Sustain unbroken websocket connection with Discord using Node.js

I've been working on developing a Discord bot using the raw API, but I've encountered an issue where the bot stops functioning after some time. I suspect that this is due to neglecting to maintain the websocket connection. How can I ensure that ...

What is the process for taking a screenshot in selenium with a particular resolution?

I need help capturing a custom resolution screenshot of the HTML canvas element using my Chrome browser. Currently, when I use the code snippet provided below, it captures a screenshot with a resolution of 1544px*638px. How can I modify the code to capture ...

Ways to retrieve a success or failure notification from Paypal?

Could you please guide me on how to retrieve transaction details after completing a PayPal payment in AngularJS? Also, how can I handle success or failure responses from the PayPal payment? ...

The PHP page is not receiving the variable passed through AJAX

Within the following code snippet, there seems to be an issue with accessing the dataString variable in the comment.php page. To retrieve the variable name, I utilized $_POST['name']. $(document).ready(function(){ $("#submit").click( function() ...

What are the benefits of having a dedicated REST backend API?

Background: I am a novice programmer who is self-taught in the hopes of creating a Single Page Application. I have started learning JavaScript, jQuery, PHP, and MySQL, and now feel quite comfortable with all of them. I began working with Ember, but now I a ...

How can I address the issue of having multiple console logs within the

I am facing an issue where my code is logging to the console 3 times upon page load and incrementing its index. I cannot figure out why this is happening despite attempting to make adjustments within a useEffect. My project involves using the typewriter-ef ...

Using JavaScript/jQuery to tally characters

Here is the code snippet that I am currently working with: PHP <input style="color:red;font-size:12pt;font-style:italic;" readonly="" type="text" name="q22length" size="3" maxlength="3" value="50"/> <textarea onkeydown="textCounter(doc ...

Shifting and positioning the card to the center in a React application

I am currently constructing a React page to display prices. To achieve this, I have created a Card element where all the data will be placed and reused. Here is how it appears at the moment: https://i.stack.imgur.com/iOroS.png Please disregard the red b ...

transferring a JavaScript variable to PHP upon submitting a form

This question arises after my previous inquiry on the topic of counting the rows in an HTML table using PHP. Since I didn't find a solution that worked for me, I am exploring new methods but struggling with the implementation. My approach involves ass ...

It is not possible to retrieve a cookie via a request

Currently, I am in the process of setting up an Express JS server that uses cookies. This is my first time incorporating cookies into a project :) Upon user login, I send cookies to them using the following code: res.cookie('pseudo', list[i].ps ...

Selenium: When a new browser window opens, the current window will automatically close

I'm currently working on automating an application where, upon clicking a button on a screen, the current window closes and a new one opens. This process repeats four times before reaching the final window that needs to be tested. However, Selenium We ...

Issues with Login and Register functionality in a node.js application using MongoDB

I am facing an issue with my app.js. After registering for a new account, it should send the data to MongoDB and then take me directly to page2. However, instead of that, it redirects me back to the home page. Moreover, when I try to log in by entering my ...

Users may encounter an issue when attempting to swipe from the bottom to the top on iOS while

I am trying to adjust the wifi status on ios by swiping up from the Control Center located at the bottom of the screen. dimension = driverWrapper.getIosDriver().manage().window().getSize(); int middleX = dimension.getWidth() / 2; int y = dimen ...

Error retrieving resource: server returned a 404 status code indicating file not found for javaScript and CSS files

I can't seem to get my css and js files to load on the server. Here is how my file structure looks like: GAME_Folder HTML doctype html head link(href='https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap' rel='sty ...

Aggregating and organizing all TypeScript files within the project while preserving the file hierarchy

Looking to utilize a task runner such as Grunt or Gulp to compile TS to JS files in various locations within the project folder. The goal is to ensure that the outputted JS files are placed in the same directory where the project will look for them alongsi ...

What is the process of linking a response to the correct request in a callback function?

While reading "The Node Beginner Book" by Manuel Kiesling, I stumbled upon the following code snippet located under a request handler. I'm curious about how the correct response object will be referenced when handling multiple concurrent requests: v ...