SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 4 of 4

Thread: Xpath Question

  1. #1
    Member
    Join Date
    Jun 2009
    Posts
    76
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Xpath Question

    I have more than one "Add To Cart" button on the page. I dont know how to specify in the XPath to select the First one appear on the page. Some one kindly help me.


    <a href="/shoppingcart.jhtml?isbn=9781427797858&addtocar t=true">
    <img class="midimage" height="18" border="0" width="74" alt="Add to Cart" src="/images/redesign06/buttons/add-to-cart.gif"/>
    </a>

  2. #2
    Advanced Member KishoreApplabs's Avatar
    Join Date
    Oct 2006
    Posts
    965
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Xpath Question

    First try to record the object, you will let getthe ID.For recording purpose better use Twist selenium tool instead of IDE.

    Regards,
    Kishore

  3. #3
    Member
    Join Date
    Jun 2009
    Posts
    76
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Xpath Question

    We use lot of Java Script here. Most of the components doesn't have any Id's, even if it has it would be a random no generated and it subject to change everytime. Only approach work here is the Xpath

  4. #4
    Senior Member
    Join Date
    Oct 2001
    Location
    Cambridge, MA, USA
    Posts
    263
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Xpath Question

    Will the url in the href follow the same pattern, just a different isbn number?

    //a[contains(@href, 'shoppingcard.jhtml?isbn')][1]

    If that's not valid, perhaps looking for the image (although that's probably a bit more fragile)

    //a/img[@src='/images/redesign06/buttons/add-to-cart.gif']

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.71%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 09:44 PM.

Copyright BetaSoft Inc.