0

I have a Menu which have li (list) elements which gets enabled after you mouse-hover a particular label.

    driver.get("www.snapdeal.com");   Actions actions = new Actions(driver);
    actions.moveToElement(driver.findElement(By.id("loggedOutAccount"))).build().perform();
    //Wait for 5 Secs
   driver.findElement(By.className("accountLink")).click();// Here it's throwing Element not visible exception

This code is doing the mouse-hover properly but not able to click the "SignIn Link" Link. Though on manually checking the element is Visible

DOM Structure -

<div id="loggedOutAccount" class="hd-rvmp-logout">
<a class="signIn" href="javascript:void(0);">
<i class="iconHeader accountUser"></i>
<label class="my-account-lang"> My Account</label>
<i class="mar_2_left right-downArrow breadcrumbArrow-down"></i>
</a>
<div class="sdNavDropWrapper accDetails" style="display: none; z-index: 999;">
<ul class="positionAbsolute pull-right">
<li class="customLoggedInState">
<div class="left triangle"></div>
<div class="right triangle"></div>
<div>
<a class="accountLink" href="javascript:void(0);">Click here to sign in ></a>
</div>
</li>
<li class="stop-event">
<li class="stop-event">
<li class="stop-event">
<li class="stop-event">
<li class="stop-event">
</ul>
</div>
</div>
7
  • does that element goes hide again when you remove mouse hover? Commented Feb 6, 2015 at 10:19
  • yes... elements hide again once the mouse hover is removed.. Commented Feb 6, 2015 at 10:23
  • Can you please use xpath to find both element? logoutbutton and accountlink? Commented Feb 6, 2015 at 10:27
  • Also remove wait if you have put there. Commented Feb 6, 2015 at 10:28
  • Once you have hover over it, you can try to move the driver focus to the required element by chaining 2 moveToElement calls. Commented Feb 6, 2015 at 10:30

1 Answer 1

1

Please use xpath for both element like below :

driver.get("www.snapdeal.com");   
Actions actions = new Actions(driver);
actions.moveToElement(driver.findElement(By.xpath("yourxpathhere"))).build().perform();

driver.findElement(By.xpath("yourxpathhere")).click();

I think class/Id repeating for other elements also for style purpose. so Xpath is better to find unique element.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.