Navigating through carousel images using protractor

I'm facing an issue with my carousel image that changes based on the customer GUID I am currently viewing. While I have successfully implemented this feature, it seems to stop working when placed inside a for loop.

Here is the code snippet:

var date = element(by.css('i.icon.left-arrow'));
browser.wait(EC.elementToBeClickable(date), 30000, "Date Range is still not clickable");
date.click(); // This works but only goes back once.

In an attempt to click through all elements in a for loop, I encountered some challenges. Is this the correct approach in Angular? Seeking guidance on this.

var backArrow = element.all(by.css('i.icon.left-arrow'));
for (var i=0;i<backArrow.length;i++) {
    backArrow.click();
}

Below is the HTML element I am working with, which varies depending on the customer and can range from 1 to 50 images:

<i class="icon left-arrow"></i>

Answer №1

If you want to execute a function on each item within the ElementArrayFinder, you can utilize the each() method:

element.all(by.css('i.icon.left-arrow')).each(function (arrow) {
    arrow.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

Automate the process of filling out forms by utilizing Selenium or Requests

I'm attempting to access this website to access my bank account. I initially tried using selenium, but encountered issues only filling in the username field (possibly due to multiple forms on the page): from selenium import webdriver driver = webdri ...

Guide on implementing OrbitControls to a camera imported from a glTF file

I am facing an issue with OrbitControls.js when trying to apply it to a loaded camera in a three.js scene. While the camera and model load successfully, the OrbitControls.js seem to work only with cameras created directly in the three.js using new THREE.Pe ...

Enhance video playback by eliminating accidental scrolling through the space bar

When using a video player, I always prefer to pause it by pressing the spacebar. However, this function is not working as expected. The issue at hand is that instead of pausing the video, pressing the space bar causes the page to scroll down unexpectedly ...

What is the process for implementing JavaScript in Django?

I'm a newcomer to this and although I've tried searching on Google, I haven't found a solution. I'm facing an issue where I can include JavaScript within the HTML file, but it doesn't work when I try to separate it into its own fil ...

Navigating the mouse using the move_to function in Selenium with Ruby

I have been attempting to simulate mouse movement using Selenium WebDriver 2.4 in Ruby. Will I be able to visually observe the mouse moving on my screen during the test execution? This is causing some confusion for me. I have experimented with various ap ...

Using Express.js with Pug.js, dynamically render the page with new content following a fetch POST request

I have a collection of article previews sourced from a database and rendered on the webpage using a Pug.js mixin. each article in articles +articlePreview(article.title, article.text, article.imgSrc) To enhance the user experience, I want to implem ...

Error message encountered: Selenium grid unable to locate Driver class for Opera browser

I am currently setting up an environment using Selenium grid to run my Selenium tests on a remote machine. I have successfully configured all browsers except for Opera. Despite following the same configuration steps as the other browsers, when I start the ...

Selenium in Python lacks the capability to manage pop-up windows or alerts

Currently, I am attempting to retrieve the text from a pop-up window shown in an image. To do this, I am utilizing Selenium in Python. Below is the code snippet I am using: time.sleep(LOADING_TIME) alert = driver.switch_to.alert print(alert.text()) Howev ...

Selenium consistently provides users with a list that is devoid of any content

I've encountered some issues while trying to extract football team names from betfair.com. Despite my efforts, the result is always an empty list. Here is my latest attempt: from selenium import webdriver import pandas as pd driver = webdriver.C ...

Declaring a sophisticated array as a property within another property in Typescript

As a newcomer to Angular and Typescript, I am facing a challenge while declaring a property with a complex array as one of its values. Here is what I have attempted: groupedItem: { customGroupId: string, cgName: string, category: [{ cu ...

Verify the form input by taking into account other form controls, utilize other form control within the validation function

My goal is to validate both email and phone number based on certain criteria: If either the email or phone field is empty, or if the values entered are invalid, then both fields are considered invalid with the message "Please provide either a valid email ...

`CSS animation for vanishing line effect`

I want to create an animated logo that gives the illusion of being pulled up by a rope, represented by a vertical black line, from the bottom of the page to the top. As the logo moves upwards, I would like the rope to disappear behind it, but I'm uns ...

What is the mechanism behind angular2's spa routing functioning seamlessly without the need for the hash character in the url?

During my experience with the Angular2 "Tour of Heroes" tutorial, I made an interesting observation about how their single page application router functions without a trailing hash symbol (#) in the URL. This differs from the Kendo SPA router, which typica ...

What are the best practices for optimizing the display of my AngularJS website for GoogleBot and Optimizely?

My website, VoteCircle (www.votecircle.com), is experiencing display issues with Google Bot/Optimizely when utilizing A/B tests. The content that is not included in ng-view is showing up fine, but everything within ng-view remains hidden. The site was dev ...

Dynamically Growing Navigation Bar Elements with Nested Subcategories Based on Class Identification

Let's say you have a menu bar structured as follows: <nav> <ul class="nav"> <li class="menu1"><a href="#">Menu Item 1</a></li> <li class="menu2"><a href="#">Menu Item 2</a> <ul& ...

Could one potentially generate new static files in Nextjs without needing to rebuild the entire app?

After recently beginning to utilize NextJs' getStaticProps feature, I have found that the static files generated at build time are quite impressive. However, my content is not static and requires updates without having to rebuild the entire app each t ...

Tips for incorporating assertions into your tests within testlink for optimal test execution

Currently, I am in the process of creating tests in Selenium using Java and leveraging TestLink for the execution and results. Everything seems to be functioning properly without assertions, and the results are being displayed in TestLink as expected. Howe ...

What is the best way to pass parameters to a PHP script using AJAX to ensure they are properly processed on the server side?

I'm working with the following function: function myFunction () { $.getJSON('remote.php', function(json) { var messages = json; function check() { ... In this function, I call the remote.php script which e ...

Error: Module specifier "react-router-dom" could not be resolved. Relative references should start with either "/", "./", or "../"

I encountered an error message after executing the command npm run preview: Uncaught TypeError: Failed to resolve module specifier "react-router-dom". Relative references must start with either "/", "./", or "../". ...

Transferring Data from Python Script to Browser (with an xserver running on a Linux system)

Looking for suggestions on how to efficiently transfer data from a Python script to a web browser. The Python script, as well as the browser, are operating under an xServer environment in Linux (specifically Raspbian on Raspberry Pi). The script is respon ...