Recently, I came across an HTML snippet on a website that caught my attention. It involved accessing and clicking on a specific attribute value using Selenium and Java.
<a class="" data-images="{"detail_url":"//assets.supremenewyork.com/156246/ma/VKFiZkcDgXY.jpg","zoomed_url":"//assets.supremenewyork.com/156246/zo/VKFiZkcDgXY.jpg"}" data-style-name="White" data-style-id="21049" data-sold-out="false" data-description="null" href="/shop/jackets/kiu5tqj83/myh25duje?alt=0" data-no-tubolink="data-no-tubolink">
<img width="32" height="32" src="//assets.supremenewyork.com/156246/sw/VKFiZkcDgXY.jpg" alt="Vkfizkcdgxy">
</a>
In my quest to access the attribute's value with selenium & java and then click it, I attempted the following:
WebElement white = driver.findElement(By.xpath("//class[@data-style-name='White']"));
white.click();
However, this resulted in errors like:
"Unable to locate element: {"method":"xpath","selector":"//*[@id=details]/ul/li[3]/a[2]"} Command duration or timeout: 0 milliseconds"