我在尝试访问网站下拉菜单中的某些链接时遇到问题。当您将光标放在按钮上时,如第一张图片所示,菜单会下拉。下面是网页脚本的图片。我想要做的是单击下拉菜单中的搜索规范按钮。类似的代码会是这样的:
e.frame(:name => "content").frame(:name => "main").a(:index => 0).click.a(:index => 10).click
但是,这不是有效的代码和平,我只是不知道正确的做法。
< e.frame(:name => "content").frame(:name => "main")
=> #<Watir::Frame:0x7f74b4d4 located=false selector={:name=>"main"}>
irb(main):064:0> my_frame.a(:text => 'Operations').click
Watir::Exception::UnknownObjectException: unable to locate element, using {:text
=>"Operations", :tag_name=>"a"}
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir
-webdriver/elements/element.rb:365:in `assert_exists'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir
-webdriver/elements/element.rb:95:in `click'
from (irb):64
from C:/Ruby193/bin/irb:12:in `<main>'
irb(main):065:0>