Need to get the count of sections within a specific div

64 views
Skip to first unread message

bhag...@gmail.com

unread,
May 16, 2013, 2:03:39 AM5/16/13
to watir-...@googlegroups.com
HI All,

I am new to Watir and I need to get the count of sections within a specific DIV. Please see below.

<section id="lsBodyContent">
        <div id="boxContainer" class="lsBoxContainer">
            <section class="lsNewContentStructureBox ng-scope" ng-repeat="contentStructure in contentStructures">
                <p class="ng-binding">Text 1</p>
                <a href="#/scheme/Text 1">
                    <p><img src="assets/img/edit.svg" alt="edit-image" class="lsEditImg"></p>
                </a>
            </section>
<section class="lsNewContentStructureBox ng-scope" ng-repeat="contentStructure in contentStructures">
                <p class="ng-binding">Text 2</p>
                <a href="#/scheme/Text 2">
                    <p><img src="assets/img/edit.svg" alt="edit-image" class="lsEditImg"></p>
                </a>
            </section>
<section class="lsNewContentStructureBox ng-scope" ng-repeat="contentStructure in contentStructures">
                <p class="ng-binding">Text 3</p>
                <a href="#/scheme/Text 3">
                    <p><img src="assets/img/edit.svg" alt="edit-image" class="lsEditImg"></p>
                </a>
            </section>
        </div>
  </section>


I need to get the number of sections within the DIV id "boxContainer"

Thanks,
Bhagya.

Alex Rodionov

unread,
May 16, 2013, 5:22:51 AM5/16/13
to watir-...@googlegroups.com
That's pretty straightforward:

browser.div(id: 'boxContainer').sections.size

Super Kevy

unread,
May 16, 2013, 9:26:22 AM5/16/13
to Watir General
Alex nailed it. Please verify your success or failure.

BTW: A research method I use when I don't know is a quick google
search for example the topic "watir count elements in div" produced a
similar answer
http://stackoverflow.com/questions/6433084/how-to-get-the-number-of-elements-having-same-attribute-in-html-in-watir

Oscar Rieken

unread,
May 16, 2013, 9:46:09 AM5/16/13
to watir-...@googlegroups.com
I think one day we will maybe stop doing other peoples work for them. to me this seems like too simple and with no examples of what they tried.



--
--
Before posting, please read http://watir.com/support. In short: search before you ask, be nice.

watir-...@googlegroups.com
http://groups.google.com/group/watir-general
watir-genera...@googlegroups.com


---
You received this message because you are subscribed to the Google Groups "Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email to watir-genera...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Chuck van der Linden

unread,
May 17, 2013, 1:56:29 PM5/17/13
to watir-...@googlegroups.com
On Thursday, May 16, 2013 6:46:09 AM UTC-7, Oscar.Rieken wrote:
I think one day we will maybe stop doing other peoples work for them. to me this seems like too simple and with no examples of what they tried.

why use your own brain when someone else's is available?

OTOH if we insist on such stuff then we start to become a hostile community.

So usually I like to encourage the searching as a way to get an answer quicker..   Show them why trying a little bit of searching on their own is better for them, which is often getting an answer without having to wait.   (since they don't seem to care what is better for us, if we have real jobs, and feel entitled to instant answers by just asking folks on the web, appealing to self interest seems the most likely route to education )  



Reply all
Reply to author
Forward
0 new messages