鼠标悬停不起作用 - Selenium,Java,Chrome
Mousehover does not work - Selenium, Java, Chrome
我正在尝试自动悬停在指定的元素上,在我的例子中是指定的办公室名称。
当我将鼠标悬停在办公室时,它的信息应该会出现。
我的问题是,当我 运行 他的代码时:
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);
我没有收到任何错误,但我没有看到办公室的信息。我错过了什么吗?有任何想法吗?谢谢
更新
在这里你可以看到一段 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;">
已解决
我缺少的是有两个 classes Actions 和 Action。我只使用了 Action class
这非常有效!!
WebElement home = driver.findElement(By.xpath(//div[@id='homePage']));
Actions actions = new Actions(driver);
Action mouseOverHome = actions.moveToElement(home).build();
mouseOverHome.perform();
您也可以尝试通过 HasInputDevices 接口进行操作。
RemoteWebElement homePage = (RemoteWebElement) driver.findElement(By.xpath(//div[@id='homePage']));
((HasInputDevices)driver).getMouse().mouseMove(homePage.getCoordinates());
我正在尝试自动悬停在指定的元素上,在我的例子中是指定的办公室名称。 当我将鼠标悬停在办公室时,它的信息应该会出现。 我的问题是,当我 运行 他的代码时:
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);
我没有收到任何错误,但我没有看到办公室的信息。我错过了什么吗?有任何想法吗?谢谢
更新
在这里你可以看到一段 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;">
已解决
我缺少的是有两个 classes Actions 和 Action。我只使用了 Action class
这非常有效!!
WebElement home = driver.findElement(By.xpath(//div[@id='homePage']));
Actions actions = new Actions(driver);
Action mouseOverHome = actions.moveToElement(home).build();
mouseOverHome.perform();
您也可以尝试通过 HasInputDevices 接口进行操作。
RemoteWebElement homePage = (RemoteWebElement) driver.findElement(By.xpath(//div[@id='homePage']));
((HasInputDevices)driver).getMouse().mouseMove(homePage.getCoordinates());