SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 6 of 6
  1. #1
    Member
    Join Date
    Jan 2008
    Posts
    284
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    How to click a link(href) that matches partially?

    Actually the url in the source code is - '/ccc/ctxxxx/Load.xxx?ID=54354355 and the Id value changes everytime based on the input.

    What i am looking to do is if the url matches partially then click on the link..but as i removed id value below line is not working.Any ideas how to click the href with partial match?

    driver.findElement(By.xpath("//a[contains(@href, '/ccc/ctxxxx/Load.xxx?ID')]")).click();

  2. #2
    Member
    Join Date
    Sep 2008
    Location
    India
    Posts
    422
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to click a link(href) that matches partially?

    you can use regular expression to make dynamic string.
    ~Vivek
    -------------------------------------------
    Software Testing Interview Question and Answer
    --------------------------------------------

  3. #3
    Senior Member
    Join Date
    Jan 2010
    Location
    Poznań, Poland
    Posts
    188
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to click a link(href) that matches partially?

    Maybe contains() is sufficient ?
    regards,
    Lukasz Morawski, QA Engineer
    Cognifide testing blog
    PTaQ

  4. #4
    SQA Knight
    Join Date
    May 2006
    Location
    Playa Del Rey, California, United States
    Posts
    2,594
    Post Thanks / Like
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0

    Re: How to click a link(href) that matches partially?

    That line looks like it should work. Maybe there's a different web element that also contains a @href property that matches your search string as well.
    David Lai
    SDET / Consultant
    LinkedIn profile

  5. #5
    Moderator
    Join Date
    Sep 2001
    Location
    Doncaster, UK
    Posts
    5,788
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to click a link(href) that matches partially?

    If the link has a static portion of text you could use (this is a Python binding) so you would need to find the equivalent for the language you are using:

    find_elements_by_partial_link_text

    Mark Smith.

  6. #6
    Member
    Join Date
    Apr 2004
    Location
    California
    Posts
    292
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to click a link(href) that matches partially?

    TestingZeal, I had a similar problem and the following worked for me:

    "//td[@class='contentbold' ]/a/b[contains(text(),'"+applicationName+"')]"

 

 

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 9.09%
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 11:38 PM.

Copyright BetaSoft Inc.