鼠标悬停在IE浏览器Windows 8.1的问题上

时间:2015-10-21 05:34:33

标签: java python mysql selenium selenium-webdriver

这是我的代码:

<div id="banner_h1" class="ui-corner-tr">
TestET Department of Transportation
<a id="js_h2_agency_select_link" class="agencyselectlink" href="javascript:void(0);" title="View List of Agencies">
<img height="12" width="12" alt="Black Down Arrow" src="/images/down.gif">
</a>
<div id="js_h2_agency_select_dropdown" class="h2_agency_select_dropdown ui-corner-bottom invisible" style="position: absolute; top: 22px; left: 6px;">
<div class="dropdown_content ui-corner-all">
<a href="/site/home?action=Go&agencyid=TEST&change=changeagency" title="Lettings for Test Department of Transportation">Test Department of Transportation</a>
<a href="/site/home?action=Go&agencyid=LOCALTEST&change=changeagency" title="Lettings for Locality with Test Department of Transportation">Locality with Test Department of Transportation</a>
<a href="/site/home?action=Go&agencyid=TESTET&change=changeagency" title="Lettings for TestET Department of Transportation">TestET Department of Transportation</a>
<a href="/site/home?action=Go&agencyid=TESTCT&change=changeagency" title="Lettings for TestCT Department of Transportation">TestCT Department of Transportation</a>
<a href="/site/home?action=Go&agencyid=TESTMT&change=changeagency" title="Lettings for TestMT Department of Transportation">TestMT Department of Transportation</a>

这是IE的鼠标问题,我有一个鼠标悬停在元素上,然后打开一个下拉列表我会点击其中一个链接。

它在Windows 7所有IE浏览器版本中运行良好,但在使用IE浏览器的Windows 8和8.1中失败。

  

错误:ElementNotVisibleException:无法单击元素

(使用javascript使元素可见但失败)

以下是鼠标悬停在元素上的xpath

//div[@id='banner_h1']/a[@id='js_h2_agency_select_link']/img

OR //html/body/div/div/div[2]/a/img(两者都使用)

鼠标悬停后的Xpath单击链接

//html/body/div/div/div[2]/div/div/a[3]

请告诉我问题可能无法解决。

1 个答案:

答案 0 :(得分:0)

你试过在链接上悬停? (这是C#例子)

                //Hover on link.
                Actions actions = new Actions(driver);
                IWebElement menuHoverLink = driver.FindElement(By.XPath("//div[@id='banner_h1']"));
                actions.MoveToElement(menuHoverLink);
                actions.Build().Perform();

之后,您可以单击所需的按钮。