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.