Pages

Search This Blog

Loading...

Wednesday, October 6, 2010

How to verify value in drop down list.

How to verify value in drop down list.
We somehow manage to find the element on the page but its difficult to fund element with some specific attributes.
Take an example How to find some value is in drop down list or now? To find element drop down is easy but to find a drop down having some specific
value in their list is difficult.

Go to www.ebay.in you will see there is drop down along with search text box.
How to veify a specific value "Collectibles" is in drop down list.

Using Xpath:

<tr>
 <td>verifyElementPresent</td>
 <td>//select[@id='_sacat']/option[contains(text(),'Collectibles')]</td>
 <td></td>
</tr>

verifyTrue(selenium.isElementPresent("//select[@id='_sacat']/option[contains(text(),'Collectibles')]"));


Using CSS:

<tr>
 <td>verifyElementPresent</td>
 <td>css=select#_sacat>option:contains("Fun")</td>
 <td></td>
</tr>

verifyTrue(selenium.isElementPresent("css=select#_sacat>option:contains(\"Fun\")"));

<tr>
 <td>verifyElementPresent</td>
 <td>css=select>option:contains("Fun")</td>
 <td></td>
</tr>


How to select the value in drop down using regular expression.

There are situation when we need to select the drop down value with some partial text .
With the help of regular expression we can select the drop down value

<tr>
 <td>select</td>
 <td>_sacat</td>
 <td>label=regexp:Fun*</td>
</tr>

selenium.select("_sacat", "label=regexp:Fun*");


11 comments:

  1. Hi Niraj,
    Very Very usefull Blog. Frankly speaking i am learning selenium thru your website.
    I have one dount.
    in ebay.in if u need to find the xpath of categories i.e. for ex: Watches under categories. How to find?

    Thanks,
    Sudbhir Bhat

    ReplyDelete
  2. Sorry for late reply.
    In fact we have to find category drop down element. And all the list in drop down will be known by its label.
    so first using xpath we will find th drop down to locate this.
    xpath=//select[@id='_sacat']
    then with the help of label will find out the watches category.
    label=Watches

    <tr>
    <td>select</td>
    <td>xpath=//select[@id='_sacat']</td>
    <td>label=Watches</td>
    </tr>
    or
    selenium.select("xpath=//select[@id='_sacat']", "label=Watches");

    let me know if dint find any luck on that

    ReplyDelete
    Replies
    1. Hi Niraj,
      Very Very usefull for me...
      Thanks

      Delete
  3. Spot on with this write-up, I really believe this amazing site needs far
    more attention. I'll probably be back again to see more, thanks for the information!
    Also see my web page: view this site

    ReplyDelete
  4. I like it when folks get together and share thoughts.
    Great website, keep it up!
    Here is my webpage ... how can I get taller

    ReplyDelete
  5. Greetings! I know this is kinda off topic but I was
    wondering which blog platform are you using for this website?
    I'm getting sick and tired of Wordpress because I've had issues with hackers and I'm looking at alternatives for another platform. I would be awesome if you could point me in the direction of a good platform.

    Also visit my blog post :: internet dating websites

    ReplyDelete
  6. Hey! This is my first visit to your blog! We
    are a team of volunteers and starting a new project in a community in the same
    niche. Your blog provided us beneficial information to
    work on. You have done a marvellous job!

    my homepage: free dating and chat

    ReplyDelete
  7. Hello There. I found your weblog the usage of msn.

    This is a very neatly written article. I�ll make sure to bookmark it and return to learn more
    of your helpful information. Thank you for the post.

    I�ll definitely comeback.

    my homepage - online datine

    ReplyDelete
  8. Thanks for the points you have shared here.
    Another thing I would like to talk about is that computer memory requirements
    generally increase along with other breakthroughs in the technological know-how.
    For instance, when new generations of cpus are introduced to the market, there is usually a matching increase in the shape eferences of
    both the pc memory and hard drive space. This is because the
    software program operated by way of these processors will inevitably rise in power to make new engineering.


    Here is my website: fuckbook

    ReplyDelete
  9. I just could not leave your website prior to suggesting that I really loved the usual info an individual supply
    on your visitors? Is gonna be back ceaselessly in order to inspect new posts

    Feel free to surf to my website; free adult personals

    ReplyDelete