Reyansh Krishna
Reyansh Krishna

Reputation: 21

Using nightwatch.js how can i select dynamically generated item with a dynamically provided value

I've got a problem to identify dynamically generated(using JQuery or some script) element present in a list box . I want to select a particular market value which i pass dynamically . the code i've used so far is

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 + '"]')

enter image description here

here pageValues.market is a dynamically provided value.

Inshort , i want to know how to generate click event on the dynamically generated listbox item with a dynamically provided value. using nightwatch.js

kindly help me out to solve this problem

Upvotes: 0

Views: 1928

Answers (1)

Reyansh Krishna
Reyansh Krishna

Reputation: 21

After several trial and errors , i succeded with this solution to handle the newly opened tabs of 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 want a better way to store the inspected elements in page objects for this newly created tab ..can you give me any suggestions or comments

Upvotes: 2

Related Questions