List of CodeceptJS.Locator object

Hello,

I would like to use Codecept syntax to grab a list of locators, something like List = driver.findElements(…) in Selenium.

The need for this is to grab the list of products from a cart for example and store them in a list of Product objects or just as a list of strings by their name.

I have found a workaround but it’s not very pretty.

var names = []
let locator = locate("…")
for (i = 1; i <= await I.grabNumberOfVisibleElements(locator); i++) {
names.push(await I.grabTextFrom(locator.at(i)))
}

Is there a possibility to grab all the product containers as Locator array or list and iterate that array?

Thanks,
Mihai

1 Like

Yes I also need same thing. please find my question here

HI Team,

I found solution for this, by using I.grabAttributeFromALL & I.grabTextFromALL.