How to get xpath on given page for Dresses Category (image with Dresses text)
i tried this : Actions action = new Actions(driver);
WebElement clothestyle = driver.findElement(By.xpath("//span[@data-csa-c-id='8nt4i-t93vdn-vkyjb-b2c2aj']")); action.moveToElement(clothestyle).build().perform();
But NoSuchElementException is coming
CodePudding user response:
Try to find more simple Xpath, your's seems be based on auto-generated data, so can expired soon. Try something like:
//img[@alt='Dresses']/../../parent::a
or
//img[@alt='Dresses']/parent::div
Also, if you need just open section, clicking element should be enough:
WebElement clothestyle = driver.findElement(By.xpath("//img[@alt='Dresses']/../../parent::a"));
clothestyle.click();