Results 1 to 5 of 5
  1. #1

    Capturing the URL

    Hi Guys

    I'm having real trouble trying to find the correct method to use for capturing the http header of a test.

    What I want to do is:

    (1) Capture the full http header in the test on the fly (e.g.) 'http://www.domain.com/page32.asp?123', and store this as a global variable.


    (2) Then extract the '123' part of the http header global variable, and also store this as a global variable.

    Any help would be much appreciated as i'm pulling hair out!

    Many Thanks

  2. #2
    Join Date
    Sep 2001
    Doncaster, UK

    Re: Capturing the URL

    First you will need to create a user defined environment value (see user guide), I will use MyURL as a pre-defined Env Var.

    Now capture url as follows replacing the ... with your browser and page.

    x = Browser("...").Page("...").GetROProperty("url")

    y = Split(x,"?")

    Environment.Value("MyURL") = y(1)

    Let me know if this works, Mark Smith.

  3. #3

    Re: Capturing the URL

    Yes, the above stmts will works 100%
    A Test Engineer should be a Programmer.

  4. #4

    Re: Capturing the URL

    Hi Mark

    Here's what i've done using your guidance, for the example Mercury 'newtours' website:

    'AJT: Ensure all variables are dimensioned
    Option Explicit

    Browser("Welcome: Mercury").Page("Welcome: Mercury").WebEdit("userName").Set "wizzypiggy"

    'AJT: Dim variables available to all procedures in all scripts
    Public MyURL, MyURLCode, x, y

    'AJT: Capture full URL & set "MyURL" as user defined environment variable
    x = Browser("Welcome: Mercury").Page("Welcome: Mercury").GetROProperty("URL")
    msgbox("TEST Output = " & (MyURL))

    'AJT: Trim part of user defined environment variable "MyURL" & set desired output as "MyURLCode" as user defined environment variable
    y = Mid(x, 17, 7)
    msgbox("TEST Output = " & (MyURLCode))

    Thanks so much for your help, it guided me to finding what I wanted to know.

    Am I right to think that the above user defined environment variables will now be available to me in other tests? Not quite sure what the theory to this is! And also is there a way to now use the extracted URL ("MyURL" variable) to call a page within script?

    I'm finding my way around the object model quite confusing, I really wish there were some reference manuals on using QTP on the net written by poeple other than Mercury but I can't find any.

    If your not able to help on the above additional questions then thank you so much for the previous help, a head ache much releived! [img]images/icons/blush.gif[/img] )


  5. #5

    Re: Capturing the URL

    >Capture the full http header in the test on the fly (e.g.)
    >http://www.domain.com/page32.asp?123', and store this as a global variable.

    'First, you have to figure out: what is unique surroundings in your target address.
    'Than, make VBscript string manipulation accordingly.
    'Next is:
    'Example of such a calculation, using some IE address.
    'The goal: retrieve the UserID , which is "455442" and will be always
    'dinamically changed in Run time.

    Adrr = "123.234.234://www.devguru.c/vbscript/UserID=455442&mid.html"
    'computing logic:
    'return numbers of characters surrounded target String
    'calculating numbers to substract from left:
    'should add 1, because "=" is not included in the count result
    iUntilID = InStr(Adrr, "=") + 1
    'calculating number to substract from righ
    iAfterID = InStr(Adrr, "&")
    'calculating numbers to take out of string
    diff = iAfterID - iUntilID
    'Here it is:
    final = Mid(Adrr, iUntilID, diff)
    'representing whatever is above in one line:
    final = Mid(Adrr, InStr(Adrr, "=") + 1, _
    InStr(Adrr, "&") - (InStr(Adrr, _
    "=") + 1))



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 03:39 PM.

Copyright BetaSoft Inc.