Display results as :

Rechercher Advanced Search

Latest topics
» why do i get this error
Sun Apr 23, 2017 9:43 pm by anbarasi

» wait property
Sun Apr 23, 2017 12:50 pm by anbarasi

» What is the use of Selenium Remote Control
Fri Apr 21, 2017 7:24 pm by azharuddin

» How can I fix it? TCP PORT Exhaustion
Wed Apr 19, 2017 3:29 pm by JohnSnow

» Difference between QTP, Selenium and Silk test
Wed Apr 19, 2017 2:30 pm by Basilios Will

» Locator for google document
Tue Apr 18, 2017 10:01 pm by SergeyK

» I encountered a mistake: Couldn't register this node
Sat Apr 15, 2017 9:06 pm by skyshine725

» Current version tutorial for just creating a browser instance - Visual Studio
Fri Apr 14, 2017 2:47 am by KilpAr

» cant able to select drop down otions
Thu Apr 13, 2017 6:08 pm by anbarasi


mouse hover doesn't work for safari and firefox browsers

View previous topic View next topic Go down

mouse hover doesn't work for safari and firefox browsers

Post by scott_hansen on Wed Sep 24, 2014 11:04 pm

//Find the achievements element without the number.  waitForElementXPath is wrapper I wrote using the function waitUntilExpectedConditions
WebElement achieveCircle = waitForElementXpath(webDriver,DEFAULT_WAIT_TIME,"html/body/div/div[2]/div/section/div/div/section/div[2]/div/span");

Assert.assertNotNull(achieveCircle,"achieveCircle not found."); 
//Hover over the element.
Actions builder = new Actions(webDriver);
Actions hover = builder.moveToElement(achieveCircle);
//Find the second achievement link
WebElement firstAchieve =  waitForElementXpath(webDriver,DEFAULT_WAIT_TIME,"/html/body/div/div[2]/div/section/div/div/section/div[2]/div/div/div/div[3]/div/div[2]/a");
//Verify that the link was found
Assert.assertNotNull(firstAchieve,"First achievement link not found"); 
//Move to the element and click on it in one step.
//Look for the new driving achievement box
WebElement driveText = waitForElementXpath(webDriver,DEFAULT_WAIT_TIME, "html/body/div[3]/div/div[2]/div[2]/div/div/div/div");
Assert.assertNotNull(driveText,"New Driving Achievement Text not found.");   
//Find the OK button.
//findElemByXpath() is another wrapper function I wrote that catches element not found exception.
WebElement achieveBtn = findElemByXPath(webDriver,"html/body/div[3]/div/div[2]/div[2]/div/div/div[2]/div/div[5]/a/span");
Assert.assertNotNull(achieveBtn,"Can't find OK button on New Driving Achievement box.");   
//Click on the OK button; 

//Wait for a web element to be visible up to the waitTime.
//webDriver is the selenium driver that was setup earlier.  waitTime is seconds.  xpath is X path of element to wait for.
public WebElement waitForElementXpath(WebDriver driver, int waitTime, String xpath)
    WebElement element;
    WebDriverWait wait = new WebDriverWait(driver, waitTime);
    //Catch the timeout exception if we don't find the element.
        element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xpath)));
    catch (TimeoutException e)
        element = null;
    return element; 

//find web element by X path.
//webDrive is the driver setup earlier.  xpath is Xpath of element to search for.
public WebElement findElemByXPath(WebDriver webDriver, String xpath)
    //Use findElement and catch the not found exception.
        WebElement element = webDriver.findElement(By.xpath(xpath));
 return element;
    catch (WebDriverException e)
        return null;


I use the code above to hover over a circle containing the number of accomplishments and wait for 2 link elements to appear.  Then I move to one of the 2 link elements, click on it and wait for a popup box to appear.

The code works for the Chrome and IE browsers.

The code does not work for Firefox though.  The accomplishments circle is clicked and the link element appears.  However Selenium doesn't find them and the test fails.

For the Safari browser, I get an Exception "movemouseto command not recognized" when the hover.perform(); statement is executed.

I hope my code I've pasted is not too long.  I wrote 2 "wrapper" functions to wait for an element and another function to locate an element.

Thank you.


Posts : 1
Join date : 2014-09-24

Back to top Go down

Re: mouse hover doesn't work for safari and firefox browsers

Post by Paps_engineer on Fri Oct 10, 2014 5:01 pm

Try to use this code
WebElement from= browser.findElement("draggable")); 
WebElement to = browser.findElement("droppable")); 
new Actions(browser).dragAndDrop(from, to).build().perform();

Automation COE,
Indium Software India Limited.
Test Automation

Active particpant
Active particpant

Posts : 10
Join date : 2014-07-24

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum