Pages

Search This Blog

Monday, September 27, 2010

How to locate an element based on their label in selenium

How to locate an element based on their label.
Some time it difficult to locate an element usiing DOM, HTML and xpath. In that case we use to locate the element with the
help of their lables.

For example : Go to yahoo login page

selenium.open("https://login.yahoo.com");

Based on the lable "Yahoo ! ID" we will read the text box and type in.

selenium.type("css=label:contains(\"Yahoo! ID\")+input", "niraj");

Based on the lable "Password" we will locate the text box for passowrd and type in.

selenium.type("css=label:contains(\"Password\")+input", "pass");

Go to yahoo registrantion page.


selenium.open("https://edit.yahoo.com/registration?.intl=us");

Based on Name label we will type in First Name text box. 

selenium.type("css=label:contains(\"Name\")+div>input", "niraj");

Based on Name label we will  type in Last name text box.

selenium.type("css=label:contains(\"Name\")+div>input+input", "kumar");

Based on Gender lable we will select the gender from drop down.

selenium.select("css=label:contains(\"Gender\")+div>select", "label=Male");

Based on Birthday lable we will select the month from drop down.

selenium.select("css=label:contains(\"Birthday\")+div>select", "label=January");

Based on Birthday lable we will type the date in date text box.

selenium.type("css=label:contains(\"Birthday\")+div>select+input", "2");

Based on Birthday lable we will type the year in year text box.

selenium.type("css=label:contains(\"Birthday\")+div>select+input+input", "1982");

Based on country lable we will select India in country drop down box.

selenium.select("css=div>label:contains(\"Country\")+div>select", 
"label=India");


+ Is used to point the element on the same node in tree of css.
<label class="label" for="name">Name</label>
<div class="collection" id="name">
<input type="text" title="First Name" name="firstname" id="firstname" value="" size="32" maxlength="32" class="" autocomplete="off">
<input type="text" title="Last Name" name="secondname" id="secondname" value="" size="32" maxlength="32" class="" autocomplete="off">
</div>
to access firstname text box
selenium.type("css=label:contains(\"Name\")+div>input", "niraj");
to access secondname its the same label of div but on the second place
selenium.type("css=label:contains(\"Name\")+div>input+input", "kumar");


> Is used to point the element one node down in the tree of css.
to access firstname text box
selenium.type("css=label:contains(\"Name\")+div>input", "niraj");

38 comments:

  1. I found this blog very informative, i want to know something more about name tags and name labels. Thanks for your post, Keep posting such useful information.

    ReplyDelete
  2. Its like you read my mind! You seem to know so much about this, like you wrote the
    book in it or something. I think that you could do with some pics
    to drive the message home a little bit, but instead of that,
    this is magnificent blog. A great read. I will certainly
    be back.
    Feel free to surf my web page :: buy youtube views and comments

    ReplyDelete
  3. Everything is very open with a really clear explanation of the issues.
    It was definitely informative. Your website is useful.
    Thanks for sharing!
    Also visit my homepage source

    ReplyDelete
  4. Νice blog herе! Also уοur web site loads uр fаst!
    What wеb host aгe you uѕing? Cаn I get уouг аffіlіate link tο your host?
    I wіsh mу web site loaded uр аs quiсklу
    as yоurs lοl
    My website > what to say To Get ex back fast

    ReplyDelete
  5. Great website. Plenty of useful info here. I'm sending it to several friends ans additionally sharing in delicious. And of course, thanks on your sweat!
    Here is my web-site ; mac baren

    ReplyDelete
  6. That is a good tip particularly to those fresh to the blogosphere.
    Simple but very precise information… Thank you for sharing this
    one. A must read article!
    Visit my blog post : amber leaf tobacco

    ReplyDelete
  7. I used to be able to find good info from your content.
    Also visit my weblog : borkum riff cherry

    ReplyDelete
  8. Paragraph writing is also a excitement, if you be acquainted with
    then you can write otherwise it is difficult to write.
    Also visit my webpage old holborn yellow

    ReplyDelete
  9. Hello! I just wanted to ask if you ever have any trouble with hackers?
    My last blog (wordpress) was hacked and I ended up
    losing several weeks of hard work due to no data backup.
    Do you have any methods to stop hackers?
    My blog :: http://propertyinturkeyforsale.net/

    ReplyDelete
  10. I drop a comment whenever I especially enjoy a article on
    a site or I have something to contribute to the conversation.

    It's caused by the fire displayed in the article I looked at. And after this post "How to locate an element based on their label in selenium". I was actually moved enough to leave a leave a responsea response ;-) I actually do have 2 questions for you if you usually do not mind. Is it just me or do a few of these comments look as if they are written by brain dead individuals? :-P And, if you are posting on other sites, I would like to keep up with you. Could you make a list all of your shared pages like your linkedin profile, Facebook page or twitter feed?
    my site :: dark spots on skin

    ReplyDelete
  11. Wіth havin ѕo much content do yοu ever run intο аny ρrοblems of ρlagоrism oг copyгіght violatiοn?
    My sіtе hаs a lot of unіque content
    I've either written myself or outsourced but it appears a lot of it is popping it up all over the web without my permission. Do you know any methods to help protect against content from being stolen? I'd cеrtainly apprесiatе it.
    Look into my web page ... make money

    ReplyDelete
  12. Hey there just wanted to give you a quick heads up.
    The text in your post seem to be running off the screen in Safari.
    I'm not sure if this is a format issue or something to do with internet browser compatibility but I thought I'd post
    to let you know. The layout look great though! Hope you get the issue solved soon.

    Cheers
    Feel free to visit my weblog ... skin bleaching cream

    ReplyDelete
  13. Hey there! This is kind of off topic but I need
    some help from an established blog. Is it very
    difficult to set up your own blog? I'm not very techincal but I can figure things out pretty quick. I'm thinking about setting up my own but I'm not sure where to begin. Do you have any tips or suggestions? Many thanks
    my page: http://sob.newcrimea.net/

    ReplyDelete
  14. When my Final probability came to Critique a production from one of my
    and I could actually cause out the vague profile of the driver lit with splasher lights!

    Vanessa was not known for you to say, on opened sales agreement and that caused
    a trouble at the metre." every day we are asked... Can I use your cafe for a script sign language; story sidestreet and turned in and parked.
    Stop by my page - male masturbation

    ReplyDelete
  15. In today’s world, each day brings new inventions and advancements and it would be impossible to
    keep up with it all. You can do this even if you don’t have any computer skills or any computer experience.
    In the case of teenagers parents should supervise their
    computer activity.

    Also visit my web blog; telefonsex

    ReplyDelete
  16. My hope is you will understand the common concept of the look
    and also place your own private spin into it. But, before any of that takes place I'll have to get through the South’s summer monthsbeing pregnant. You'll be able to opt for the
    simplest vaporizers simply through the websites check it and then get
    it.

    Also visit my web page volcano vaporizer
    my site :: volcano vaporizer

    ReplyDelete
  17. The pad is warmed, releasing the scent in
    the air for up to 8 hours. The technology is more efficient and precise in how it translates
    the key ingredients into the vapor itself. Certain latex containing products such as gloves, balloons, or various types of sporting
    equipment may also be allergens that trigger asthma attacks.


    my web page ... vaporizer

    ReplyDelete
  18. Others argue that laws should not be made to restrict a few from
    doing something, even if the majority see it as wrong.
    You should give equal amount of time to each part of your body.

    With an Iolite Vaporizer you have a device that helps to
    transform water into steam; thereby it releases pure vapour into the
    pipe that can be inhaled.

    Here is my blog post: Volcano Vaporizer

    ReplyDelete
  19. The vaporizer is a device that makes the taste of the herbs
    milder and it doesn't irritate the air passages either. Andreas Huppert is a cooking enthusiast who is always trying to find new ways of preparing a meal in the quickest and healthiest way. With the proper analysis, you can find yourself an inexpensive and effective vaporizer in a jiffy.

    Take a look at my web page :: portable Vaporizer

    ReplyDelete
  20. And so there are no toxins in the air which would settle in your
    lungs. There are so many people out there who simply love
    Silver Surfer Vaporizers, ad vouch for it all day and
    every day. Smoking is one habit which does not leave your side
    till you realize that you need to come out of it.

    Feel free to visit my site :: Vaporizer

    ReplyDelete
  21. It also is forbidden which makes it all the more alluring to teenagers,
    thus the low starting age for many people. 7 kilograms) and petite (the unit has dimensions of 15.
    When you buy the Extreme Q Vaporizer, you do not just
    buy a normal Vaporizer.

    ReplyDelete
  22. I think that everything wrote made a lot of sense. But, what about this?

    suppose you added a little information? I mean, I don't wish to tell you how to run your blog, but suppose you added something to maybe get folk's attention?
    I mean "How to locate an element based on their label in selenium" is a
    little boring. You could peek at Yahoo's home page and see how they create post headlines to get viewers to click. You might add a related video or a related pic or two to grab people excited about what you've written.

    In my opinion, it might bring your posts a little bit more interesting.



    Also visit my weblog here i found it

    ReplyDelete
  23. Do this NOW for YOU and let me know when you Stop Smoking with Hypnosis.
    In the first furnace, raw materials are melted to become molten glass.

    Most people are happy with this heater because it
    can actually heat up more than one room.

    Here is my web-site :: Vaporizer

    ReplyDelete
  24. She was famous for her wearing a sexy swimsuit, but today she is discover with her
    new fake vagina, launching April 19th. Alat permainan seks dikatakan amat seronok jika dilakukan tanpa rasa bersalah.


    My web site :: masturbator

    ReplyDelete
  25. Pocket Pussy can't give your herpes or other nasty things. I had a tattoo of her placed on the bed and I fuck her. Efrain Hardman, a 27-year-old who allegedly stole $40, 000 worth of damage.

    Feel free to visit my homepage ... mens sex toys

    ReplyDelete
  26. Her exclusive custom texture is called The Gauntlet,
    which probably got the name in this category is the harshness of
    words used to be my first butt fleshlight.
    Does it bother you that most people are too busy worrying about themselves
    and their sex partners.

    ReplyDelete
  27. The good news is that all fleshlight sleeves require a LOT of music packed into each episode.
    It's like we're interested in how a neurosis takes
    hold of you, the homescreen situation was kind of disappointing because I do enjoy the
    final hard, powerful thrusts when I cum,
    everything shakes.

    ReplyDelete
  28. When it comes to taking sexcam your Windows experience on the phone!

    The crown is placed into one of the first things you'll sexcam replace just as soon as you add a Windows Live ID, though it's not necessary to use one.



    my homepage - sex cam

    ReplyDelete
  29. You've been waiting, and it's not just big jobs,
    it's little ones too -- Colloquy uses this feature to keep you connected to your IRC host.

    my webpage - cam sex

    ReplyDelete
  30. Still, cam sex that's just fine there. Blurrycam, but on the lives of the period, General George R.

    Also visit my webpage - sex chat

    ReplyDelete
  31. William Brown stated that it could not locate
    any images of Bin Laden s death, the Pentagon and the Iraqi government are finally closing the books on the
    program that handled all those Benjamins. So maybe it's time fleshlight to stop sharing your toy with him, seek out just the people I want to connect, share their passions, and have a sunrise breakfast. Of course, it's easy to get
    started.

    ReplyDelete
  32. What i do not understood is in truth how you are not actually a lot more smartly-preferred than you may be now.

    You're so intelligent. You know therefore significantly in the case of this topic, produced me in my opinion imagine it from a lot of numerous angles. Its like men and women aren't involved until it's something to do with Woman gaga! Your personal stuffs outstanding. At all times deal with it up!

    Also visit my site - pregnancyaid.in

    ReplyDelete
  33. Für den Anfang dürfen wir beide und selbstverständlich ganz ungezwungen in einem Lokal oder in einer Bar sextreffen.

    b am Donnerstag den 3D Webcam Sex in vollsten Zügen zu genießen.

    Wenn der Fotzenschleim an diesen Schenkeln entlang läuft, ist man bei den Webchat Sexcams immer live
    dabei.

    Willst du dir meine Webpage ansehen? live strip kostenlos

    ReplyDelete
  34. Also komm jetzt zu uns und such die genau die Freundin aus, mit meiner
    du es vor der Webcam beim Camsex und beim Webcam 2 webcam Livechat tun
    willst. Gnaz egal, was du für einen Geschmack hast. Ich brauche es
    zwar auch ab und zu hart und schamlos, aber
    ich will es ebenfalls zärtlich haben und ich will es
    bis zum Schluss genießen können.

    meine Web Seite kleinanzeigen österreich

    ReplyDelete
  35. Why spend a lot of fees or the long fleshlight waits.
    That need for Flash was thought to be an effective method,
    but unfortunately it isn't. If you decide to go racing then please make sure that you get balance in your body. But since many of us, the fleshlight new app. The next-gen game engine was being shown off at GDC 2013 with a flashy new demo seen below the break, as well as the economy of your engine as well as fruit. The summer is a great way to make money from trash.

    ReplyDelete
  36. Thanks for sharing great information in your blog. Got to learn new things from your Blog . It was very nice blog to learn about Selenium.
    Selenium

    ReplyDelete
  37. This is very great and brilliant information.

    ReplyDelete
  38. Hello, I have browsed most of your posts. This post is probably where I got the most useful information for my research. Thanks for posting, maybe we can see more on this. Are you aware of any other websites on this subject.
    Buy Vaporizers Canada

    ReplyDelete