我正在尝试访问 li 数组中的 div
<ul>
<li class="views-row views-row-1 views-row-odd views-row-first">
<div class="news-item">
</li>
<li class="views-row views-row-2 views-row-even">
<li class="views-row views-row-3 views-row-odd">
<div class="news-item">
<div class="image">
<div class="details with-image">
<h2>
<p class="standfirst">The best two-seat </p>
<div class="meta">
<div class="pub-date">26 April 2012</div>
<div class="topic-bar clearfix">
<div class="topic car_review">review</div>
</div>
</div>
</div>
</div>
</li>
我正在尝试访问“div class="topic car_review">汽车评论”并获取其文本。我专门使用该文本的原因是,根据文本的内容,它会输入特定的步骤。
我正在使用的代码是
@topic = @browser.li(:class => /views-row-#{x}/).div(:class,'news-item').div(:class,'details').div(:class,'meta').div(:class,/topic /).text
该脚本之前运行良好,但突然停止工作,无法获取 div(:class,'news-item')。
我得到的错误信息是
unable to locate element, using {:class=>"news-item", :tag_name=>"div"} (Watir::Exception::UnknownObjectException)
我尝试了 div(:class => /news-/) 但仍然无法找到该元素
我真的卡住了!!!