xpath of one element is: //div[@class=name-slider-header']//button//img[2]
xpath of another element is: //div[@class=name-slider-header']//button//img[1]
Actually I need to check attribute of element must contains "red" after element gets disabled
after clicking "n" times, so I am using element.getAttribute("src").contains("red");
element2.getAttribute("src").contains("red");
Is it possible to find common xpath for this elements?
Use the following xpath to identify the image
elements where src
value contains red
//div[@class='name-slider-header']//button//img[contains(@src, 'red')]
code:
imgElements = driver.findElements(By.xpath("//div[@class='name-slider-header']//button//img[contains(@src, 'red')]"));