Count the amount of items in a Slider

94 views
Skip to first unread message

Venu Reddy

unread,
Jul 4, 2011, 3:27:30 AM7/4/11
to seleniu...@googlegroups.com
Hi All,


How to find the total number of items are present in a slider. Please find the below HTML code,attached screen shot and do the needful.


<div class="odd">
    <select style="display: none;" id="47_17" name="47_17" class="dropdown" title="Slider questions ">
    <option value="M">please select</option>
    <option title="Slider questions " value="18">Slider response 1</option>
    <option title="Slider questions " value="19">Slider response 2</option>
    <option title="Slider questions " value="20">Slider response 3</option>
    <option title="Slider questions " value="21">Slider response 4</option>
    </select>
    <div role="application" class="ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all">
        <a style="left: 50%;" href="#" tabindex="0" id="handle_47_17" class="ui-slider-handle ui-state-default ui-corner-all" role="slider" aria-labelledby="undefined" aria-valuemin="0" aria-valuemax="4" aria-valuenow="2" aria-valuetext="Slider response 2">
        <span class="screenReaderContext"></span>
        <span class="ui-slider-tooltip ui-widget-content ui-corner-all">
            <span class="ttContent">Slider response 2</span>
            <span class="ui-tooltip-pointer-down ui-widget-content">
                <span style="border-top: 7px solid rgb(255, 255, 255);" class="ui-tooltip-pointer-down-inner">
                </span>
            </span>
        </span>
    </a>
        <ol class="ui-slider-scale ui-helper-reset" role="presentation">
            <li style="left: 0%; display: block; width: 20%;">
                <span style="margin-left: -37px; margin-right: 24.6667px;" class="ui-slider-label ui-slider-label-show">please select</span>
                <span class="ui-slider-tic ui-widget-content" style="display: none;"></span>
            </li>
            <li style="left: 25%; display: block; width: 20%;">
                <span style="margin-left: -49px; margin-right: 32.6667px;" class="ui-slider-label ui-slider-label-show">Slider response 1</span>
                <span class="ui-slider-tic ui-widget-content"></span>
            </li>
            <li style="left: 50%; display: block; width: 20%;">
                <span style="margin-left: -49px; margin-right: 32.6667px;" class="ui-slider-label ui-slider-label-show">Slider response 2</span>
                <span class="ui-slider-tic ui-widget-content"></span>
            </li>
            <li style="left: 75%; display: block; width: 20%;">
                <span style="margin-left: -49px; margin-right: 32.6667px;" class="ui-slider-label ui-slider-label-show">Slider response 3</span>
                <span class="ui-slider-tic ui-widget-content"></span>
            </li>
            <li style="left: 100%; display: block; width: 20%;">
                <span style="margin-left: -49px; margin-right: 32.6667px;" class="ui-slider-label ui-slider-label-show">Slider response 4</span>
                <span class="ui-slider-tic ui-widget-content" style="display: none;"></span>
            </li>
        </ol>
    </div>
</div>

Regards,
Gopal.
ScreenHunter_01 Jul. 04 12.48.gif

Mark Collin

unread,
Jul 4, 2011, 4:11:07 AM7/4/11
to seleniu...@googlegroups.com

Looks fairly simple at first glance.  It looks like the slider is taking a select list and transforming it into a slider which will fall back to a select box if JavaScript is not available (nice and accessible).  All you need to do is count the number of options that the select element holds (and decrement it by one if you want to ignore the “please select” option.

 

Easily done with selenium.getXPathCount() using the selenium 1 API, or by using List<WebElement> optionsNumber = driver.findElements(…) in the webdriver api and counting the number of elements that get inserted into the list.  The XPath you want will be:

 

//select[@id=’47_17’]/option

 

Obviously if this is not a static ID (which it may not be looking at the style of it) you will need to tweak the above slightly.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


-- This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error please notify postm...@ardescosolutions.com

Venu Reddy

unread,
Jul 4, 2011, 4:56:34 AM7/4/11
to seleniu...@googlegroups.com
Thanks Mark.

As you expected it is dynamicID.
Thanks for the response and the solution. It is working fine.
Reply all
Reply to author
Forward
0 new messages