-1

I use selenium, WebDriver, Intellij, Junit4, ChromeDriver, PageObject.

Testing this site: http://store.demoqa.com/products-page/product-category/ .

If I click manually on the link "Product Category", you can see that, the page will reload, the dropdown menu will disappear for a short moment. Actually you just need to hover over the link "Product Category" and click on "Accessories" using action.moveToElement(), but I don't know how to write code. Can you write me code.

This is my code:

public ProductPage clickOnAccessories(){

        //Click on link “Product Category” than “Accessories” on website navigation
        driver.findElement(By.id("menu-item-33")).click();
        driver.findElement(By.id("men34u-item-34")).click();

        }
Ramesh Bala
  • 89
  • 1
  • 13
MY DZON
  • 109
  • 1
  • 4
  • 9
  • Possible duplicate of [How to perform mouseover function in Selenium WebDriver using Java?](http://stackoverflow.com/questions/17293914/how-to-perform-mouseover-function-in-selenium-webdriver-using-java) – JeffC Dec 14 '16 at 22:24
  • Before posting a question you should spend some time googling for answers. You actually know the method you need to use, it should be trivial to find some sample code and try it before posting. – JeffC Dec 14 '16 at 22:25

1 Answers1

0

Here you go,

Actions act = new Actions(driver);
act.moveToElement(driver.findElement(By.xpath("//a[text()='Product Category']")));
act.perform();

driver.findElement(By.xpath("//a[text()='Accessories']")).click();
SelThroughJava
  • 321
  • 3
  • 14