0
Actions action = new Actions(driver);
WebElement we = driver.findElement(By.xpath("//*[@id=\"container\"]/div/div[2]/div/ul/li[1]/span"));
action.moveToElement(we).moveToElement(driver.findElement(By.xpath("//*[@id=\"container\"]/div/div[2]/div/ul/li[1]/ul/li/ul/li[1]/ul/li[1]/a[@href='/mobile-phones-store?otracker=nmenu_sub_Electronics_0_Mobiles']"))).click().build().perform();  

I am trying to hover and click using xpath. The code is not throwing any error but it is still unable to perform click option after hover.

AndiCover
  • 1,724
  • 3
  • 17
  • 38
Megha R
  • 1
  • 1
  • 1
    Whats you question? whats the expected output? Please more descriptive and format the code. – alt255 Aug 17 '19 at 20:22

1 Answers1

0

Try with the below code snippet. I have tested it with chrome driver and works fine.

WebElement electronics_menuname = driver.findElement(By.xpath("//span[contains(text(),'Electronics')]"));
        Actions builder = new Actions(driver);
        builder.moveToElement(electronics_menuname).build().perform();

        WebElement mobile_menu_button = driver.findElement(By.xpath("//li[@class='_1KCOnI _2BfSTw _1h5QLb _3ZgIXy']//a[contains(text(),'Mobiles')]"));
        new WebDriverWait(driver,20).until(ExpectedConditions.elementToBeClickable(mobile_menu_button)).click();