I'm curious about how to use nightwatch.js to target a dynamically generated element with a dynamic value

I'm facing an issue with identifying dynamically generated elements in a list box using JQuery or some other scripting language. My goal is to select a specific market value that is passed dynamically. The code I've currently implemented is as follows:

browser.useXpath().waitForElementVisible('.//*[@id="NIRPaymentReasonDropDown_1"]', 1000)

browser.useXpath().click('//*[@id="NIRPaymentReasonDropDown_1"]/span[1]/span/span[1]') 
           .click('//*[@id="NIRPaymentReason_1_listbox"]/li[text()="' + pageValues.market + '"]')

https://i.sstatic.net/ktQ3M.png

In this context, the variable pageValues.market represents a dynamically fetched value.

To sum up, my question is how can I trigger a click event on a dynamically generated listbox item with a provided dynamic value using nightwatch.js

I would greatly appreciate any assistance in resolving this issue.

Answer №1

My persistence paid off as I finally found a solution to effectively manage the newly opened tabs on the same webpage

 browser.windowHandles(function(result) {
                            var authorizePopup = result.value[1];
                            this.waitForElementVisible('#confirmation-modal', 2000)
                            this.switchWindow(authorizePopup);
                            this.assert.containsText(".modal-title", "Payment Details");
                            this.click('#confirm-checkbox')
                                .click('#submit-payment-btn')
                        })

I'm looking for a more efficient way to organize and store the elements in page objects for this new tab. Any suggestions or input would be greatly appreciated.

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

Is there an issue with Ajax connecting to the database?

I have created an HTML file where I need AJAX to connect to the database in the background and fetch the selected city based on the user's pre-selected country. Essentially, I want the database to load all the cities in the drop-down menu automaticall ...

How to Send Data to ASP.NET MVC Controller Using AJAX Request with jQuery

I am trying to send parameters to a controller from jQuery, but I am struggling with it. The call works fine without parameters when the URL is just /SurveySection/EditLocalization. Shouldn't it be something like this: /SurveySection/EditLocalization? ...

"Is there a way to retain the value of a variable outside of an ajax success

I've been working on some form validation functions and here's what I've come up with: <script> $(document).ready(function() { var dataObject = {}; $('#username').keyup(function () { id = $(this).attr('id'); ...

Clearing the view state of a specific repeater control

There is a specific requirement that I must fulfill, which involves deleting the view state of a particular repeater using jQuery or JavaScript. For instance, suppose I have two repeaters: repeater 1 and repeater 2. Upon clicking a button, I would like to ...

The mesh takes on a more defined geometric shape once it has been processed using ThreeCSG

When I use ThreeCSG to subtract one mesh from another, I encounter a problem. The main mesh is a ring and the mesh to subtract is a diamond. Initially, the scene looks fine: Mesh fine. However, after subtracting the meshes, the ring become angular: Mesh Br ...

Struggling to retrieve scope variable within ng-template inside script tag

Trying to create a template for inline editing with Angular, I found this useful tutorial: Here is my code: <table class="table"> <tbody> <tr class="table-row" ng-repeat="admin in admins" ng-include="getTemplate(admin)" ...

Newbie: Troubleshooting Vue Errors - "Vue is not recognized"

I'm currently at the beginning stages of learning Vue and am practicing implementing it. However, I keep encountering the errors "vue was used before it was defined" and "Vue is not defined". Below are excerpts from my HTML and JS files for reference. ...

javascript The event handler is not functioning properly for the dynamically loaded AJAX content

I am facing an issue with adding a JavaScript event listener to a dynamically loaded div via AJAX. Below is my code snippet: var QuantityMiniCart = function() { var infor = document.querySelectorAll( '.mini-cart-product-infor' ); if ( ...

Submitting with enter key on typeahead suggestions

Seeking guidance on Bootstrap typeahead: how can I configure it to submit the entered text upon pressing the enter key? Specifically, if I type "hello" in the typeahead input and hit enter, how can I submit "hello"? I've successfully disabled the aut ...

What is causing the delay in retrieving elements using getX() method in Selenium?

Recently, I've been experimenting with web scraping using Selenium. However, I've noticed that there is a delay when calling getText(), getAttribute(), or getTagName() on the WebElements stored in an ArrayList from the website. The website I&apo ...

Managing the jQuery.noConflict function

Upon review, I noticed that the scripts I inherited start like this: var $j = jQuery.noConflict(); The purpose behind this code is not clear to me. While I understand the intent is to avoid conflicts, I am uncertain about the specific conflict it aims to ...

Learn the best way to send query parameters through the Next.js navigation router and take advantage of

Currently, I am implementing import { useHistory } from 'react-router-dom' const history = useHistory() ... history.push('/foo?bar=10') However, only the 'foo' part is being pushed into the url. What is the correct way to pas ...

Difficulty in switching state value from true to false in ReactJS

As a newcomer to the world of reactjs, I am currently experimenting with setting the state of input_active to true or false depending on onBlur and onFocus events. This allows me to dynamically change the style of the input element. Here is a snippet of t ...

What is the best way to search for a specific item in Express.js?

I recently got the Leaderboard API issue fixed, but now I'm encountering a new problem with express Querying. Specifically, I'm attempting to search for a specific Discord ID using quick.db as my database. I've included an excerpt of my expr ...

Adding fields to all objects in an array within MongoDB

I'm trying to update all objects in an array by adding a new field only if it doesn't already exist. I attempted to use the updateMany method but it doesn't seem to be working. Can someone please assist me? const updateResult = await Form.up ...

How come the values keep appearing without any loops or subsequent calls being made to the PHP file?

Here is a demo example showcasing 'Server Sent Events(SSE)': Embed HTML code(index.html) : <!DOCTYPE html> <html> <body> <h1>Receiving server updates</h1> <div id="result"></div> <script> if(type ...

The persistent Bulma dropdown glitch that refuses to close

In the project I'm working on, I have implemented a Bulma dropdown. While the dropdown functions correctly, I am facing an issue when adding multiple dropdowns in different columns with backend integration. When one dropdown is open and another is cli ...

How can I subtract a value from an array using node-js?

If we consider a simple scenario where an array totalSpots = [95] contains only one value, and a new booking is made, the goal is to automatically assign one parking spot to the user who booked it. This will involve reducing the value in the array by 1 or ...

The persistent problem with constantly polling the $.ajax request

One issue I'm facing involves a continuous polling $.ajax request. The challenge lies in initiating it immediately first, and then running it at intervals set in the setTimeout call. Take a look at the example code here. myObj = {}; var output = ...

Rotating an object in Three.js: Animate back and forth along two different azimuth angles

My three.js project features a 3D object that is meant to be viewed from the front only, as it appears as a single plane and is transparent from the back... Using orbitControls, I have restricted movement of both azimuth and polar angle... To enhance the ...