abhi111abhishek / selenium-vba

Automatically exported from code.google.com/p/selenium-vba
0 stars 0 forks source link

count number of img inside div tags #66

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Operating system :
.Net Framework version : 4.0
Office Version : 2003
SeleniumWrapper version : 2.5.0

What is your issue ?

I am trying to count number of img tags inside different div tags.
I am using getcsscount but I am not really able to configure it properly.

My code goes like this.

<form id="Form1" method="POST" action="Negotiate.asp?ID=80010">
    <div class="navholder"></div>
    <div align="center" style="margin-bottom:5px;margin-top:5px;"></div>
    <h1 class="block"></h1>
    <div class="column left halves nomargin height500">
        <h2></h2>
        <table cellspacing="0" cellpadding="0">
            <tbody>
                <tr></tr>
                <tr></tr>
                <tr></tr>
                <tr>
                    <th></th>
                    <td>
                        <div class="flag" style="width:35px; display:inline-block; padding:2px;">
                            <img border="0" align="absmiddle" src="compressed/images/lvl1.gif"></img>
                            <img border="0" align="absmiddle" src="compressed/images/lvl2.gif"></img>
                            <img border="0" align="absmiddle" src="compressed/images/lvl3.gif"></img>
                            <img border="0" align="absmiddle" src="compressed/images/lvl4.gif"></img>
                        </div>
                    </td>
                </tr>
                <tr>
                    <th></th>
                    <td>
                        <div class="flag" style="width:35px; display:inline-block; padding:2px;">
                            <img border="0" align="absmiddle" src="compressed/images/lvl1.gif"></img>
                        </div>
                    </td>
                </tr>

Thanks in advance.

Original issue reported on code.google.com by religie...@gmail.com on 14 Apr 2014 at 8:48

Attachments:

GoogleCodeExporter commented 9 years ago
imageCount = driver.getCssCount("#Form1 .flag img")
Or
imageCount = driver.findElementsByCssSelector("#Form1 .flag img").Count

Original comment by florentbr on 14 Apr 2014 at 9:29

GoogleCodeExporter commented 9 years ago
Thanks a lot for your quick answer.
Now I want to count in a loop each img for each .flag

It is possible to write a code like driver.getCssCount("#Form1 .flag[" & k & "] 
img")

Original comment by religie...@gmail.com on 15 Apr 2014 at 6:36

GoogleCodeExporter commented 9 years ago
Yes it's possible:
For Each ele In wd.findElementsByCssSelector("#Form1 .flag")
    Debug.Print ele.findElementsByCssSelector("img").Count
Next

Original comment by florentbr on 15 Apr 2014 at 11:33

GoogleCodeExporter commented 9 years ago
Thanks a lot, it is working well :)

Original comment by religie...@gmail.com on 16 Apr 2014 at 12:58

GoogleCodeExporter commented 9 years ago

Original comment by florentbr on 8 Sep 2014 at 5:40