I'm trying to automate some test scenarios of our e-commerce site.
There is a page where some products are listed. I want to randomly select one product, and click 'Add to Cart'. The only problem is, the button would be displayed only when we hover over the product and all the add to cart buttons have same properties.
So, I've used nested findElement
method to drill it down to the particular button.
prods = getObjects("productlisting_prodinfo");
WebElement outer = prods.get(itemposition);
builder.moveToElement(outer).build().perform();
WebElement ele1=outer.findElement(By.xpath(OR.getProperty("prodinfo_addtocart")));
ele1.click();
But unfortunately it doesn't seem to work as intended, and always selects the button on the first product. The hovering is done successfully, but button click is not as intended.
Any help to get this done would be highly appreciated.