【发布时间】:2014-05-14 19:33:50
【问题描述】:
我无法访问嵌套的 div。
这是我的场景。我需要访问内部 div 中的总数。有人可以在这里阐明一下吗?
<div id="RequestSend">
<div class="title">
Requests Sent
</div>
<div class="total">
10
</div>
</div>
<div id="RequestReceived">
<div class="title">
Requests Received
</div>
<div class="total">
20
</div>
</div>
我尝试了以下方法,但没有成功。
Approach 1:
prof.rb
=======
div(:total_count, {:class => 'total'})
div(:request_send, {:id => 'RequestSend'})
prof_spec.rb
=============
page.request_send_element.total_count.should eq 10
Output:
NoMethodError: undefined method `total_count' for #<Selenium::WebDriver::Element:0x....>
Approach 2:
prof.rb
=======
divs(:total_count, {:class => 'total'})
prof_spec.rb
============
total_count[0] # for first
total_count[1] # for second
Please note I am a new user to page object.
【问题讨论】:
标签: page-object-gem