Currently working with nodeJS and experimenting with the following code snippet:
for (let i = 1; i <= elSize; i++) {
try {
let DeviceName = await driver
.findElement(By.xpath("//span[@class='a-size-medium a-color-base a-text-normal']['i']"))
.getText();
console.log(i + ". Device Name: " + DeviceName + "\n");
} catch (e) {
await driver.executeScript(
...
catch statements...
);
}
}
Attempting to include the 'i' variable from the for loop in the xpath. Facing issues due to the absence of double quotes, resulting in an unrecognizable xpath like this one:
driver.findElement(By.xpath("(//span[@class='a-size-medium a-color-base a-text-normal')["+ i +"]")).getText();
This causes the xpath to be unrecognized.
Here is an example of how the xpath can be identified in the browser:
//span[@class='a-size-medium a-color-base a-text-normal']['i']