0
我一直在嘗試通過在這裏和谷歌組的論壇搜索大約2天,沒有發現我的工作。基本上頂部導航菜單被放入下面的HTML:無法執行Watir懸停或鼠標懸停主導航菜單
<div id="topNav">
<div id="headerLogo">
<div id="mainNav">
<ul id="nav">
<li id="navTab01" class="manageUsers">
<a class="mainNavItem" title="Manage Users And Groups" href="#"> </a>
<ul class="dropdown" style="display: none;">
</li>
<li id="navTab02" class="manageContent">
<a class="mainNavItem current" title="Manage Content" href="#"> </a>
<ul class="dropdown" style="display: none;">
<li class="manageSubRegions">
<li class="manageBusinessDirectoryEntries">
<a class="dropdownItemHasFlyout current" href="/BusinessDirectoryEntry"> Business Directory</a>
<ul class="flyout" style="display: none; left: 224px;">
</li>
<li>
</ul>
</li>
<li id="navTab03" class="manageFinancials">
<li id="navTab04" class="runReports">
</ul>
</div>
</div>
菜單項我想操縱是navTab002它具有擴展的HTML:
<li id="navTab02" class="manageContent">
<a class="mainNavItem current" title="Manage Content" href="#"> </a>
<ul class="dropdown" style="display: none;">
<li class="manageSubRegions">
<a class="current" href="/SubRegion"> Regions</a>
</li>
<li class="manageBusinessDirectoryEntries">
<a class="dropdownItemHasFlyout current" href="/BusinessDirectoryEntry"> Business Directory</a>
<ul class="flyout" style="display: none; left: 224px;">
<li class="businessDirectoryEntryQuickAdd">
<a class="current" href="/BusinessDirectoryEntry/QuickAdd"> Quick Add</a>
</li>
<li class="manageBusinessCustomListings">
<a class="current" href="/BusinessDirectoryCustomListing"> Sectors</a>
</li>
<li class="manageBusinessDirectoryProfileTypes">
<a class="current" href="/BusinessDirectoryProfileType"> Profile Types</a>
</li>
<li class="manageBusinessDirectoryPrivateTypes">
<a class="current" href="/BusinessDirectoryPrivateType"> Private Types</a>
</li>
<li class="displayOptions">
<a class="current" href="/DisplayOption">Display Options</a>
</li>
</ul>
</li>
我想點擊第三個項目在鼠標懸停(或鼠標點擊)的下拉列表中,可以手動使用它。
Java腳本正在使用hoverIntent(可能)對我造成問題 - 不確定。
當我手動運行我期間使用控制檯節電:
DOMNodeRemoved DOMSubtreeModified DOMNodeInserted DOMSubtreeModified DOMNodeRemoved DOMSubtreeModified DOMNodeInserted DOMSubtreeModified DOMNodeRemoved DOMSubtreeModified
一個bazzillion倍。
這是編碼我試圖用Ruby的Watir的日誌:
irb(main):001:0> require 'watir'
=> true
<Watir::Browser.start("http://services.leedsgrenville.com/")
=> #<Watir::IE:0x4c618ca8 url="http://services.leedsgrenville.com/" title="Admin
istration">
<ink(:index, 1).attribute_value("/BusinessDirectoryEntry")
NoMethodError: undefined method `li' for main:Object
from (irb):3
from C:/Ruby193/bin/irb:12:in `<main>'
irb(main):004:0> browser.li(:text, 'Manage Users & groups').link(:index, 1).at>
Watir::Exception::UnknownObjectException: Unable to locate element, using {:tag_
name=>["li"], :text=>"Manage Users & groups"}
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:66:in `assert_exists'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:135:in `document'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/locator.rb:31:in `document'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/locator.rb:136:in `each_element'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/locator.rb:21:in `block in each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/locator.rb:20:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/locator.rb:20:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/locator.rb:147:in `locate'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:33:in `locate'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:63:in `assert_exists'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:407:in `attribute_value'
from (irb):4
from C:/Ruby193/bin/irb:12:in `<main>'
irb(main):005:0> browser.li.flash
=> nil
irb(main):006:0> browser.li(id => "navTab02").flash
NameError: undefined local variable or method `id' for main:Object
from (irb):6
from C:/Ruby193/bin/irb:12:in `<main>'
irb(main):007:0> browser.li(id => "navTab02").flash
NameError: undefined local variable or method `id' for main:Object
from (irb):7
from C:/Ruby193/bin/irb:12:in `<main>'
irb(main):008:0> browser.li(index, 2).flash
NameError: undefined local variable or method `index' for main:Object
from (irb):8
from C:/Ruby193/bin/irb:12:in `<main>'
irb(main):009:0> browser.li(index, 2)
NameError: undefined local variable or method `index' for main:Object
from (irb):9
from C:/Ruby193/bin/irb:12:in `<main>'
<nk(:text, /Manage Content/).fire_event('onmouseover')
=> ""
<(:text, /Manage Content/).fire_event('onmouseover')
=> ""
<(:text, /Manage Content/).fire_event('onmouseover')
=> ""
irb(main):013:0> browser.link(:text, /Manage Content/).flash
=> nil
irb(main):014:0> browser.link(:text, /navTab01/).flash
Watir::Exception::UnknownObjectException: Unable to locate element, using {:tag_
name=>["a"], :text=>/navTab01/}
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:66:in `assert_exists'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:280:in `flash'
from (irb):14
from C:/Ruby193/bin/irb:12:in `<main>'
irb(main):015:0> browser.link(:text, /navTab01/).flash
Watir::Exception::UnknownObjectException: Unable to locate element, using {:tag_
name=>["a"], :text=>/navTab01/}
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:66:in `assert_exists'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:280:in `flash'
from (irb):15
from C:/Ruby193/bin/irb:12:in `<main>'
irb(main):016:0> browser.link(:text, /Manage Content/).flash
=> nil
irb(main):017:0> browser.link(:text, /Manage Content/).flash
=> nil
irb(main):018:0>
<(:class => 'manageContent', :text => 'Manage Content').link.click
Watir::Exception::UnknownObjectException: Unable to locate element, using {:tag_
name=>["li"], :class=>"manageContent", :text=>"Manage Content"}
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:66:in `assert_exists'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:135:in `document'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/locator.rb:31:in `document'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/locator.rb:136:in `each_element'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/locator.rb:21:in `block in each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/locator.rb:20:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/locator.rb:20:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/locator.rb:147:in `locate'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:33:in `locate'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:63:in `assert_exists'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:412:in `perform_action'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:269:in `click!'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:211:in `click'
from (irb):19
from C:/Ruby193/bin/irb:12:in `<main>'
<(:class => 'manageContent', :text => 'Business Directory').link.click
Watir::Exception::UnknownObjectException: Unable to locate element, using {:tag_
name=>["li"], :class=>"manageContent", :text=>"Business Directory"}
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:66:in `assert_exists'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:135:in `document'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/locator.rb:31:in `document'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/locator.rb:136:in `each_element'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/locator.rb:21:in `block in each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/locator.rb:20:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/locator.rb:20:in `each'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/locator.rb:147:in `locate'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:33:in `locate'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:63:in `assert_exists'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:412:in `perform_action'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:269:in `click!'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:211:in `click'
from (irb):20
from C:/Ruby193/bin/irb:12:in `<main>'
irb(main):021:0> browser.div(:id, "mainNav").fire_event "onmouseover"
=> ""
irb(main):022:0> browser.div(:id, "mainNav").fire_event "onmouseover"
=> ""
irb(main):023:0> browser.link(:id => "navTab01").click
Watir::Exception::UnknownObjectException: Unable to locate element, using {:tag_
name=>["a"], :id=>"navTab01"}
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:66:in `assert_exists'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:412:in `perform_action'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:269:in `click!'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:211:in `click'
from (irb):23
from C:/Ruby193/bin/irb:12:in `<main>'
irb(main):024:0> browser.link(:class => "manageUsers").click
Watir::Exception::UnknownObjectException: Unable to locate element, using {:tag_
name=>["a"], :class=>"manageUsers"}
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:66:in `assert_exists'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:412:in `perform_action'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:269:in `click!'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:211:in `click'
from (irb):24
from C:/Ruby193/bin/irb:12:in `<main>'
irb(main):025:0> browser.div(:id, "mainNav").hover
NoMethodError: undefined method `hover' for #<Watir::Div:0x30b3610>
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.1.0/lib/watir-c
lassic/element.rb:431:in `method_missing'
from (irb):25
from C:/Ruby193/bin/irb:12:in `<main>'
irb(main):026:0> class Watir::Element
irb(main):027:1> def hover
irb(main):028:2> assert_exists
irb(main):029:2>
irb(main):030:2* driver.action.move_to(@element).perform
irb(main):031:2> end
irb(main):032:1> end
=> nil
<ll(:text, "Manage Content").fire_event("onmouseover")
NoMethodError: undefined method `cell' for #<Watir::IE:0x3276978>
from (irb):33
from C:/Ruby193/bin/irb:12:in `<main>'
irb(main):034:0> require 'WET'
LoadError: cannot load such file -- WET
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:i
n `require'
from C:/Ruby193/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:i
n `require'
from (irb):34
from C:/Ruby193/bin/irb:12:in `<main>'
實際的Java代碼是:
$("#mainNav, #mainNavDropdown").hoverIntent(
{
interval: 200,
timeout: 1000,
over: function()
{
$(this).addClass("over");
$("#mainNavDropdown").stop(true, true).slideDown(500,
function()
{
$(this).css("height", ""); // Make sure animation didn't screw up
});
},
out: function()
{
$(this).removeClass("over");
if (!$("#mainNav, #mainNavDropdown").hasClass("over"))
$("#mainNavDropdown").stop().slideUp(500,
function()
{
$(this).css("height", ""); // Make sure animation didn't screw up
});
}
});
// Hide the menu on body click
$("body")
.click(function(evt)
{
if ($(evt.target)
.parents()
.andSelf()
.filter("#mainNav, #mainNavDropdown").length == 0)
$("#mainNavDropdown").stop().slideUp(300,
function()
{
$(this).css("height", ""); // Make sure animation didn't screw up
});
});
如果任何人都可以嘗試幫助我,這將是真棒!
你能夠創建一個測試頁面或爲頁面提供登錄嗎?如果沒有合適的東西,這些問題很難調試。 –
你可以在http://www.crasustainability2011.com/en/index.asp找到類似的網站 - 我不能讓你看到實際的網站,因爲它是私人的:(網站提供的功能與菜單相似,但是。希望有幫助 – user1636092
在CRA頁面上,哪個鏈接與您需要實現的級別相似?我已經能夠做到「可持續性服務>服務」,但在執行「可持續性服務>項目亮點> EHS管理時遇到了一些問題支持」。 –