2015-10-21 113 views
0

這是我的代碼:鼠標懸停在IE瀏覽器窗口的問題8.1

<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瀏覽器版本中工作正常,但在Windows 8和8.1與IE瀏覽器失敗。

Error:ElementNotVisibleException: Cannot click on element

(使用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] 

請給我建議問題可能是我無法做到的。

回答

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(); 

之後,你可以點擊你想要的按鈕。