I am using firefox browser. I tried the mouse hover on the menu but not displaying its respective submenu when hover on the main menu using selenium webdriver.It only select the menu "Claims" and stops there only.Its not executing testScript further because on mouse hover submenu not displayed.So
HTML CODE
<body>
<div id="div_LockPane" class="LockOff"/>
<div id="claim-newclaimsearch" class="page-wrap" data-menu-hovered="">
<div class="header">
<div class="row">
<div class="column small-12 large-2 logo">
<nav class="column small-12 large-10 navigation-container" role="navigation">
<ul class="main-menu">
<li>
<li class="active">
<a href="/Menu/Claims">
<div class="menu-icon">
<img src="/content/common/images/menu-icons/claims.png"/>
</div>
<span class="name">Claims</span>
</a><div class="arrow-container">
<div class="sub-menu-container">
<div class="row sub-menu">
<div class="column title-side">
<h2 class="title">Claims</h2>
</div>
<div class="column points-side">
<ul>
<li class="active">
<a href="/Claim/NewClaimSearch">New Claims</a>
</li>
<div class="search-page">
<div id="search-advanced-tools" data-state="collapsed">
<div class="row">
<div class="column">
<h2 class="action-title">New Claims</h2>
</div>
</div>
I have to hover on menu "Claims" and select submenu "NEW CLAIMS"
Selenium Code
//private final By PRODUCT_CATEGORY = By.linkText("Claims");
private final By PRODUCT_CATEGORY= By.xpath("//a[contains(.,'Claims')]");
private final By PRODUCT_SUBCATEGORY = By.linkText("NEW CLAIMS");
@Test()
void testLogincase2() throws Exception{
Thread.sleep(2000);
WebElement hoverBtn = driver.findElement(PRODUCT_CATEGORY);
System.out.println("click on Claims");
Thread.sleep(2000);
Actions action = new Actions(driver);
Thread.sleep(2000);
action.moveToElement(hoverBtn).perform();
Thread.sleep(1000);
WebElement subElement = driver.findElement(PRODUCT_SUBCATEGORY);
Thread.sleep(1000);
action.moveToElement(subElement);
System.out.println("No claims");
Thread.sleep(2000);
action.click();
Thread.sleep(2000);
action.perform();
}
As you see in below attached image here the menu "Claims" got detected by driver as it colour become a bit darker then other menu .But the submenu is not displayed like as i have shown in above image. The mouse hover event is not working