RE: Re-posting my question
I have site with AddCart buttons , and have run code like below . But i have problem in selecting the addcart buttons as explanined Below .
Please suggest common function which i can use to select the addCart button
For Exmaple :
listelements = driver.findElements(By.xpath(“//*[starts-with(@id,’ProductForm_’)]/div/input”)); –> Here I will get the Three AddKart Buttons with Index of 1,2,3 .
Please suggest . Attaching the ScreenShot
But This solution will work , But refer the below screen shot it fails to identify the AddCART Button
The Reason it was failed because of the div id change : .//*[@id=’ProductForm_106′]/div/input –> here id of div is 8 Instead of 6 which worked for other two AddCART buttons in the screen shot .
Question is how do we now identify even with dynamic div change ?
Appreciate your help
Can you paste or attach the DOM , one quick solution i could think of is to remove the div at all and try to use //input
Mean while can you try this locator //*[starts-with(@id,’ProductForm_’)]//input , it should select all the input elements inside you product form