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*");


19 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
  10. Hi,

    How to write a xpath ,that ignores the case for example below is the xpath in selenium webdriver


    //div[@id='model-showroom-current-year-container'][div[div[div[div]]]]/div/div/descendant::div[@class='model-name' and contains(text(),' C-MAX')]

    ReplyDelete
    Replies
    1. The xpath should ignore the case of 'C-MAX',Kindly let me know on this Niraj

      Delete
  11. It is perfect time to make a few plans for the future and it is time to be happy.
    I've learn this put up and if I could I desire to counsel you some attention-grabbing things or suggestions. Maybe you could write next articles relating to this article. I desire to read more things approximately it!

    my blog - party hardcore

    ReplyDelete
  12. Greate pieces. Keep posting such kind of information on your page.
    Im really impressed by your site.
    Hey there, You've performed an incredible job. I'll certainly digg it
    and individually recommend to my friends. I'm sure they'll be benefited
    from this web site.

    Here is my page :: http://sexvideovoyeur.com/

    ReplyDelete
  13. First off I would like to say great blog! I had a quick question which I'd like to ask if you do not mind. I was interested to find out how you center yourself and clear your mind before writing. I have had trouble clearing my thoughts in getting my thoughts out there. I truly do enjoy writing but it just seems like the first 10 to 15 minutes are usually lost just trying to figure out how to begin. Any ideas or hints? Many thanks!

    Stop by my web page; xvideo

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. This comment has been removed by the author.

    ReplyDelete
  16. Its Brilliant knowledge For Over-automation.Over-automation is so good.

    ReplyDelete