0

I am trying to click a hover over 'edit' button. However, I keep getting "Element is not currently visible and so may not be interacted with" Error when I use mouseOverElement.
Any idea on how to make it work? Thanks

< div class="editbox" >
 < h2>Title< /h2>
  < ul>
    < li >
       < small class="editlinks" >
            < a class="edit" href="#">Edit< / a >
       < /small>
     < strong> Content
    < /li>
  < /ul>
< /div>

Here is my code:

Approach 1:

WebElement textArea = driver.findElement(By.cssSelector("div.editbox ul li"));
WebElement button = driver.findElement(By.cssSelector("div.editbox ul li small.editlinks a.edit"));
Actions builder = new Actions(driver);
builder.moveToElement(textArea).build().perform();
timer.wait(5000);
driver.findElement(By.cssSelector("div.editbox ul li small.editlinks a.edit")).clik();

Approach 2:

Actions builder = new Actions(driver);
builder.moveToElement(textArea);
timer.wait(5000);
builder.click(button);
builder.build().perform();

1 Answer 1

0

I'm using to following code to hover over an element:

if (element instanceof Locatable) {
    Locatable hoverItem = (Locatable) element;
    hoverItem.getLocationOnScreenOnceScrolledIntoView();
    Mouse mouse = ((HasInputDevices) webDriver).getMouse(); 
    mouse.mouseMove(hoverItem.getCoordinates());
}

Try if it works.

I'm not sure you can click on that li element, since it is invisible. Shouldn't you hover your link (a tag)?

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

4 Comments

However, a tag is a hidden button. I need to hover over to the li element in order to make the edit button visible. is there any way to do it? thanks
Normally, if you inspect the element with Chrome Dev Tools or Firebug, the element will be grayed out if invisible. Did you try the above code to hover?
I tried to use the above code. but the element is still not showing up for click.
@asgoth : I tried the above code and it is working fine for chrome -v26.x.xx browser. But fails in FF- v11.0 and IE- v8(64Bit). Is anything i've to do to work on other browsers? Is any other solution to resolve this issue? Let me know i am struggling with this issue for a long peroid

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.