Open gaurabhi1986 opened 7 years ago
Hi,
elements()
function is part of the webdriver protocol. If remember correctly, the part of nightwatch's api that uses the webdriver protocol directly, doesn't work with the @
locators. To overcome this, we did smth like this in our tests
const instancesPage = client.page.instancesPage();
const instanceName = instancesPage.elements.instancesTableName;
const instanceNames = [];
client.elements(instanceName.locateStrategy, instanceName.selector, (result) => {
result.value.forEach((value) => {
client.elementIdText(value.ELEMENT, (el) => {
instanceNames.push(el.value);
});
});
});
Hi,
Thanks for quick response.
I am getting error : "Cannot read property 'elementIdText' of undefined"
Thanks,
And what do you get when you replace the forEach with a console log:
client.elements(instanceName.locateStrategy, instanceName.selector, (result) => {
console.log(result);
});
I have used your project to create sample test framework but getting some issues
Sample Page Object code :
var artCommands = { validateArts: function() { this.api.elements('css selector','@arts', function(list){ })
}) };
module.exports = { commands: [artCommands], elements: { arts: { selector: 'div.index.section ul.index li' } } };
In the above code when I used validateArts command in my test script its not able to get arts element using @arts in this.api.elements() method but if i pass css path it will works fine.
can you please help to resolve this issue why artCommands unable to retrieve elements using @arts.
And also I need help to retrieve all the child element of li element. can you please let me know how can I iterate list to get all the child elements of li tags and their value.