Ruby Watir Iterate through list and find element -
i have unordered list. ul-list
------------ li-ola ola description  ------------ li-james james description ------------ li-jake joe description ------------   all descriptions embedded in div using same id name "description" need verify items in list has description. without knowing how big list is.
so far have:
bb = @browser.ul(:id => 'ul-list') bb.lis.each |li|   fail unless @browser.div(:class => 'description').exists? end   fixed previous error test pass when there nothing in list. :/
sample html
<ul id=“ul-list”> <li id=“li-ola”>         <div class=“return”>           <table>             <tbody>             <tr class=“info_return”>               <td class="info_return_label">brand</td>               <td class="info_return_value">               ola               </td>             </tr>             <tr class="info_return_row">               <td class="info_return_desc_label">description</td>               <td class="info_return_description">               test data               </td>             </tr>             </tbody>           </table>         </div>       </li> </ul>      
for sample html, code prints success. sure not work you?
bb = browser.ul(:id => 'ul-list') bb.lis.each |li|   puts 'success' if li.td(:class => 'info_return_description').exists? end      
Comments
Post a Comment