I have encountered a challenge with looping through multiple div containers on the page that all have the same class name 'sponge'. My goal is to retrieve details from each of these containers, but I am struggling to figure out the right approach. Here is my current attempt...
const containers = await driver.findElements(By.className(`sponge`))
for(let i = 0; i < containers.length; i++){
let details = await containers[i].findElement(By.xpath(`//div[2]/div[1]/div/p`)).getText()
console.log(details)
}
Unfortunately, when I run the code snippet above, it retrieves the same 'details' from the first 'sponge' container repeatedly for the total number of 'containers'. It seems to be unable to locate the specific 'details' in each individual container as intended.