Search code examples
javaseleniummousehover

Mousehover does not work - Selenium, Java, Chrome


I am trying to automate the hover on a specified element, in my case is an specified office name. When I hover on an office the information of it should appear. My problem is that when I run his code:

String officeId = findElement(designOfficesPosition, num).getAttribute(ConstantsFramework.ID);
WebElement office = getSupport().getDriver().findElement(By.id(officeId));


action.moveToElement(office).build().perform();
getSupport().pause(ConstantsFramework.TIME_OUT_10_SECONDS);

I don't get any errors but I don't see the information of the office. Am I missing something? Any ideas? Thanks

UPDATE

Here you can see a piece of the html:

<div id="officesListPreview">
<div class="roundBox previewOffice officesRotator">
<h3>Office information</h3>
<p class="numbers">
<div id="OPA-AT" class="officeContainer" style="display: none;">
<div id="BPO-BG" class="officeContainer" style="display: block;">
<a class="officeLink" href="http://www.bpo.bg/" target="_blank" style="">
<div class="detailsOffice">
</div>
<div id="BOIP-BX" class="officeContainer" style="display: none;">

Solution

  • SOLVED

    What I was missing is that there are two classes Actions and Action. I was using just Action class

    This works perfectly!!

    WebElement home = driver.findElement(By.xpath(//div[@id='homePage']));
    
    Actions actions = new Actions(driver);
    Action mouseOverHome = actions.moveToElement(home).build();
    
    mouseOverHome.perform();