Sunday, June 30, 2013

selenium Mosue Over not working if hover property is defined in CSS

Problem

Selenium is not able to perform mouseOver if Hover property is defined in CSS
You can try yourself on this link using selenium ide http://www.w3schools.com/cssref/tryit.asp?filename=trycss_sel_link_more2
Selenium mouse Over has no effect on this link
please visit this link

Solution

According to this question, this is one of those perennial problems Selenium and :hover css
They discuss a couple of solutions, but it looks like the problem is that as Javascript cannot trigger the :hover pseudo class, so Selenium can't either.

You can use webdriver to solve this problem, Webdriver code for mouse over

void mouseOver(String UiLocator) throws Exception
{
element =  driver.findElement(findBy(UiLocator));
Actions builder=new Actions(driver);
builder.moveToElement(element).build().perform();
}


No comments:

Post a Comment