Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
scott_hansen
Posts : 1
Join date : 2014-09-24

mouse hover doesn't work for safari and firefox browsers Empty mouse hover doesn't work for safari and firefox browsers

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);
hover.perform();
     
//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.
builder.moveToElement(firstAchieve).click().perform();
     
//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.");   
delay(1000);
     
//Click on the OK button
achieveBtn.click(); 

//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.
    try
    {
        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.
    try
    {
        WebElement element = webDriver.findElement(By.xpath(xpath));
 return element;
    }
    catch (WebDriverException e)
    {
        return null;
    }  
}



Hello,

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.
avatar
Paps_engineer
Active particpant
Active particpant
Posts : 10
Join date : 2014-07-24

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

Fri Oct 10, 2014 5:01 pm
Try to use this code
example:
WebElement from= browser.findElement(By.id("draggable")); 
WebElement to = browser.findElement(By.id("droppable")); 
new Actions(browser).dragAndDrop(from, to).build().perform();
  

Thanks,
Papaiadasan.S,
Automation COE,
Indium Software India Limited.
(indiumsoft.com/core-qa-offerings/test-automation)
Test Automation
Back to top
Permissions in this forum:
You cannot reply to topics in this forum