点击第一个元素而不是休息,在这里我必须一个接一个地点击所有链接。
HTML code:
<div class = "MangoList">
<ul class = "Mangos">
<li class = "MangoLi">
<a href="#" class = "MoreInfo">
<img src="-------------" class="mangoImage" alt="apple" title="----">
</a>
<li class = "MangoLi"></li>
<li class = "MangoLi"></li>
<li class = "MangoLi"></li>
<li class = "MangoLi"></li>
<li class = "MangoLi"></li>
.
.
. ---------> 50 li
.
<li class = "MangoLi"></li>
</ul>
</div>
这是代码
def links
@browser.elements(:css => "div.MangoList ul li a")
end
def links_text
links.each do |link_elements|
link_elements.click
sleep(3)
end
Error:-Watir::Exception::UnknownObjectException: unable to locate element, using {:element=>#<Selenium::WebDriver::Element:0x..fa9b907d0 id="0.011786506854683632-5">}