'I am working on a VBA project with selenium and I am wondering how to find an element if the class names are the same

I need to get the second or third of the classes shown, '4' now but will change, but the class names are the same. How can I get the class I want and send it to a cell on the file?

enter image description here



Solution 1:[1]

To find individual ts class.

(//span[@class='Dj']//span[@class='ts'])[1]
(//span[@class='Dj']//span[@class='ts'])[2]
(//span[@class='Dj']//span[@class='ts'])[3]

You can also try directly, if it works:

To find individual ts class

(//span[@class='ts'])[1]
(//span[@class='ts'])[2]
(//span[@class='ts'])[3]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Anand Gautam