SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 7 of 7
  1. #1
    Junior Member
    Join Date
    Jul 2005
    Location
    UK
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    hyperlinks with TextExists

    Hello

    I'm a relative TP newbie.

    I have the following code to identify a string of text in a HTML division:

    Dim ServRes As THTMLDiv
    Dim RetVar As Boolean
    Dim R As TRectangle

    Set R = Rectangle()

    HTMLDiv("ID=results_0_cjxGrid_body").Attach

    Set ServRes = HTMLDiv("ID=results_0_cjxGrid_body")

    RetVar = ServRes.TextExists(Service, Rectangle:=R)


    RetVar is returning false. Through experimentation TP appears not be succesfully locating my 'Service' string on the screen because the text itself is in the form of a hyperlink.

    Does the TextExist method work with hyperlinks? Is there any easy way around this?

    Many thanks

  2. #2
    Member
    Join Date
    Jul 2003
    Location
    Germany
    Posts
    458
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: hyperlinks with TextExists

    Usually .TextExists is used for windows/frames such as

    Window("bla bla").Attach
    if Window.TextExists("mytext") then
    ' mytext is there!
    end if

    If you want to check whether a div contains a certain string you can do something like:

    dim myText as String
    myText = HTMLDiv("ID=results_0_cjxGrid_body").Text

    if InStr(myText, "searchterm") > 0 then
    ' the search term was found
    end if

    InStr return the position of the search string (2nd param) within the string (1st param). E.g.

    InStr("the quick brown fox", "quick")

    returns 5.

    It returns 0 if the string was not found.

  3. #3
    Member
    Join Date
    Oct 2007
    Location
    uk
    Posts
    278
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: hyperlinks with TextExists

    Hey Have you tried HTMLAnchor

    In my code I have done following code to check if particular link exists then check = pass else check= false

    dim LblnLinkCheck as Boolean

    LblnLinkCheck = HTMLAnchor("ID=esults_0_cjxGrid_body",tpAttachNoWa it).Exists

    IF LblnLinkCheck = True then
    msgbox(LblnLinkCheck)
    Else
    msgbox(LblnLinkCheck)
    End If

    Above code will look for particular (Hyperlink) value equal to mentioned ID and if exists the LblnLinkCheck value will become True other wise value will be False.

    Try and see if it works for you
    Never test the depth of the water with both feet.

    ASH

  4. #4
    Junior Member
    Join Date
    Jul 2005
    Location
    UK
    Posts
    6
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: hyperlinks with TextExists

    Thanks for the replys guys.

    I am able to check if the text exists successfully using your method Ash. However if it does - I then need to identify the pixel coordinates of the HTMLAnchor and click a checkbox approximately 100 pixels to the left of it.

    (The only way I can select the correct checkbox is to get the coordinates of the HTMLanchor first, each checkbox relates ro a particular HTMLanchor. The checkboxes themselves do not have any properties I can use to identify the correct one)

    All help appreciated.

  5. #5
    Member
    Join Date
    Oct 2007
    Location
    uk
    Posts
    278
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: hyperlinks with TextExists

    Hey Dude, I am glad HTMLAnchor works for you.

    Now as I believe you are new to automation testing, so let me give you a small tip (Make developers to work with you). Basically what I am saying is to ask developers to provide you IDs with all the objects, it is difficult to tick checkbox without property as you can never be sure if you are ticking the right checkbox. Using a pixel method can be a solution but not always because what will happen if other tester is using different screen resolution, will the mouse click on right check box.

    In my case I didn't have checkbox property but I have asked the developers to generate ID for each checkbox.

    Then I've used in the following manner

    ======
    Dim LblnLinkCheck as Boolean

    LblnLinkCheck = HTMLAnchor("ID=esults_0_cjxGrid_body",tpAttachNoWa it).Exists

    IF LblnLinkCheck = True then

    ===&gt; <font color="blue">HTMLCheckbox("ID=esults_0_cjxGrid_bod y_1",tpAttachNoWait).click</font>

    Else

    ' Raise Error log

    End If
    Never test the depth of the water with both feet.

    ASH

  6. #6
    Member
    Join Date
    Jul 2003
    Location
    Germany
    Posts
    458
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: hyperlinks with TextExists

    You could also try to take a look at the ElementID property. If you are able to identify the HTMLAnchor and the CheckBox is always two ElementID's before the HTMLAnchor you can identify the CheckBox by a simple calculation.

    E.g. if the difference between the anchor and the checkbox ElementID is always two you can identify the checkbox as follows:

    elemID = HTMLAnchor("ID=results_0_cjxGrid_body").ElementID
    HTMLCheckBox("ElementID=" &amp; elemID).Click

  7. #7
    Member
    Join Date
    Oct 2007
    Location
    uk
    Posts
    278
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: hyperlinks with TextExists

    Q.A.Tom my question is how would your code works if there are 100 checkboxes on the page and you want to tick checkbox number 50.
    Never test the depth of the water with both feet.

    ASH

 

 

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.34%
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 06:26 AM.

Copyright BetaSoft Inc.