The online community for software testing & quality assurance professionals
 
 
Calendar   Today's Topics
Sponsors:




Lost Password?

Home
BetaSoft
Blogs
Jobs
Training
News
Links
Downloads



Testing Tools >> Micro Focus/Compuware TestPartner

Pages: 1
heinzmeise
Newbie


Reged: 09/19/12
Posts: 3
TP doesn't recognizes the Link under a Span
      #716649 - 09/19/12 03:08 AM

Hello,

I'm trying to record the ID of a Link on a website, but TP just recognizes the overlaying <span> Tag - please assume the following structure:

Code:

<html>
<head></head>

<body>
<div class="content_div" id="1">
<div class="link_div" id="2">
<a class="myCustomLink" id="3" href="http://www.google.com">
<span id="4">klick me.</span>
</a>
</div>
</div>
</body>
</html>



When I start recording, the Pointer just gets the <span>, but ignores the underlying <a href> Tag. It would be great if someone could give me a hint,

big thanks in advance,

Chris


Post Extras: Print Post   Remind Me!   Notify Moderator  
Ozone
Newbie


Reged: 06/08/12
Posts: 13
Re: TP doesn't recognizes the Link under a Span [Re: heinzmeise]
      #716657 - 09/19/12 06:41 AM Attachment (124 downloads)

My example is using Windows Internet Explorer as the browser.

The issue is that you are recording. If you would use the identifying tool you would see what you are looking for. We rarely record and play here.

The <span> immediately surrounds the text klick me. If you move the identifier tool to the right of the klick me text you will see the <div>. Look at the attached screen shot.


Post Extras: Print Post   Remind Me!   Notify Moderator  
heinzmeise
Newbie


Reged: 09/19/12
Posts: 3
Re: TP doesn't recognizes the Link under a Span [Re: Ozone]
      #716674 - 09/19/12 07:48 AM

I used the Identifier tool as well, unfortunately it doesn't get's the HTMLAnchor: if I use a simple Link, e.g. <a href="http://www.example.com" id="3">Click me</a> it works. The Problem is that I'm using a Framework which generates the HTML, and I need to find a way to record the ID of the HTMLAnchor even if it contains a <Span>...

Post Extras: Print Post   Remind Me!   Notify Moderator  
Ozone
Newbie


Reged: 06/08/12
Posts: 13
Re: TP doesn't recognizes the Link under a Span [Re: heinzmeise]
      #716677 - 09/19/12 08:34 AM

I am going to give you some code that I used to discover all Anchor tags on an HTML page. You will have to modify it for your needs and ignore some of my custom function calls. WriteToErrorLog() is one of my functions that you can remark out. FastWaitWindowExists() is another.

It works by looking for up to 500 anchor tags by iterating through the index numbers and checking to see if they exist.

Code:
  

Sub Discover_all_AnchorTags(svFileName As String)

Dim nvIndex As Integer
Dim svHref As String
Dim svResult As String
Dim nvNum As String
Dim svCaptionText As String

ChDir APEX_PATH

Call Shell("C:\Program Files\Internet Explorer\IEXPLORE.EXE " & svFileName, vbMaximizedFocus)

Call FastWaitWindowExists("Application=IEXPLORE.EXE ClassName=IEFrame", Me.Name)

IEWindow("Application=IEXPLORE.EXE ClassName=IEFrame").Attach

Pause 2, tpPauseSeconds

' Attach to the browser window.
HTMLBrowser("ClassName=HTML.Browser").Attach

For nvIndex = 1 To 500

If HTMLAnchor("Application=IEXPLORE.EXE Index=" & Trim(CStr(nvIndex)) & "", tpAttachNoWait).Exists = True Then
'TestLog.Comment "Found HTMLAnchor tag " & Trim(CStr(nvIndex)) & " URL = " & HTMLAnchor("Application=IEXPLORE.EXE Index=" & Trim(CStr(nvIndex)) & "").Href
svHref = HTMLAnchor("Application=IEXPLORE.EXE Index=" & Trim(CStr(nvIndex)) & "").Href
svCaptionText = HTMLAnchor("Application=IEXPLORE.EXE Index=" & Trim(CStr(nvIndex)) & "").Caption
If InStr(1, svHref, "file:", vbTextCompare) > 0 Then
' Strip the 1st 8 characters from the front of the URL to remove 'file:///' from the URL. This will leave a full file\path.
svResult = Right(svHref, Len(svHref) - 8)
' Now replace the forward slashes with backslashes
svResult = Replace(svResult, "/", "\", 1, -1, vbTextCompare)
' Now replace the HTML character sequence '%20' string with a blank space.
svResult = Replace(svResult, "%20", Chr(32), 1, -1, vbTextCompare)
' Now strip off any mapid's at then end of the file name.
nvNum = InStr(1, svResult, "#", vbTextCompare)
If nvNum > 0 Then
svResult = Left(svResult, nvNum - 1)
End If
'TestLog.Comment "URL = " & svHref & " Stripped to " & svResult
' Now see if the URL exists.
If DoesExist(svResult, "FILE") = False Then
WriteToErrorLog Me.Name, "The link with the caption text of '" & svCaptionText & "' with a target URL = " & svHref & " cannot be found on the Help file named = " & svFileName, True
Else ' OK to click - it passes
'TestLog.Comment "Passes URL = " & svHref & " Caption = " & svCaptionText
End If
End If

Else
Exit For
End If

Next nvIndex

Call StopProgram("IEXPLORE.EXE")

End Sub



Post Extras: Print Post   Remind Me!   Notify Moderator  
heinzmeise
Newbie


Reged: 09/19/12
Posts: 3
Re: TP doesn't recognizes the Link under a Span [Re: Ozone]
      #716712 - 09/19/12 11:22 PM

@Ozone - thanks for sharing this, I'll give it a try soon (out of Office at the moment).

Edited by heinzmeise (09/19/12 11:23 PM)


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 4 anonymous users are browsing this forum.

Moderator:  Myrtle, Jim Brennan, AJ, DSquared 

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 2179

Rate this topic

Jump to

Contact Us | Privacy statement SQAForums

Powered by UBB.threads™ 6.5.5