Ruby Selenium Web Driver: How to count child element nodes of a specific node -


am novice selenium programmer please me this...

i have below html , trying count child nodes of element <div class="result-controls"> 4 (1 div , 3 li elements)

<div class="result-controls">    <div class="attachment">       <li class="add-attachment-button-column"><a><button>add attachments</button></a></li><input type="file" multiple="" style="display: none;">    </div>    <li class="sign-button-column"><a href="javascript:void(0)"><button>sign</button></a></li>    <li class="draft-button-column"><a><button>draft</button></a></li>    <li class="delete-column"> <a href="javascript:void(0)"><svg class="glyphicon-trash" viewbox="0 0 100 100"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#trash"></use></svg> </a></li> </div> 

currently calculating count separately below (row variable has above html)

  li_actions_count = row.find_elements(:xpath => "./li").length   div_actions_count = row.find_elements(:xpath => "./div").length 

can me simple way in ruby using selenium web driver

there possible ways depending on how specific want xpath be, f.e. if want count child elements of name, can use * :

row.find_elements(:xpath => "*").length 

and if want count child elements of names i.e li , div :

row.find_elements(:xpath => "*[self::li|self::div]").length 

Comments