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 2001
    Location
    New York, NY
    Posts
    26
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Replacing hard coded values in script

    How do I replace the hardcoded value below with a variable?

    Browser("NetOxygen").Page("NetOxygen").Frame("Fram e").WebEdit("username").Set "Admin"

    I want to be able to use something as follows:

    Dim LoginName = 'Admin'

    Browser("NetOxygen").Page("NetOxygen").Frame("Fram e").WebEdit("username").Set &LoginName


    Thanks.

  2. #2
    Senior Member
    Join Date
    Jun 2000
    Location
    Charlotte, NC, USA
    Posts
    617
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Replacing hard coded values in script

    Consider the online help that comes with QTP.
    Resistance is futile.

    SuperK

  3. #3
    Senior Member
    Join Date
    Jan 2005
    Location
    VA
    Posts
    237
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Replacing hard coded values in script

    in a vbs file, define your variables such as

    const LoginName = "Admin"
    const uName = "username"
    ...

    in your QTP script (that has included the vbs file above), it can be changed to something like ...

    Browser("NetOxygen").Page("NetOxygen").Frame("Fram e").WebEdit(uName").Set LoginName
    Regards!

  4. #4
    Junior Member
    Join Date
    Jul 2001
    Location
    New York, NY
    Posts
    26
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Replacing hard coded values in script

    Originally posted by chin8673:
    in a vbs file, define your variables such as

    const LoginName = "Admin"
    const uName = "username"
    ...

    in your QTP script (that has included the vbs file above), it can be changed to something like ...

    Browser("NetOxygen").Page("NetOxygen").Frame("Fram e").WebEdit(uName").Set LoginName
    <font size="2" face="Verdana, Arial, Helvetica">Works great. Thank you so much for your help!

    As you instructed, I created a VBS file with the name of the variable and the actual value. Why do I have to declare it as a const?

    Then I entered the following code in my script:

    Browser("NetOxygen").Page("NetOxygen").Frame("Fram e").WebEdit("Username").Set LoginName

    1. I am not sure why you changed "Username" to uName. I just want to not hard code the actual value of "Username".

  5. #5
    Junior Member
    Join Date
    Jul 2001
    Location
    New York, NY
    Posts
    26
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Replacing hard coded values in script

    I found out that I don't need a VBS file as long as I declared it before I use the variable. So on the same action, I did the following code:

    Const LoginName = "Admin"

    Browser("NetOxygen").Page("NetOxygen").Frame("Fram e").WebEdit("username").Set LoginName
    Browser("NetOxygen").Page("NetOxygen").Frame("Fram e").WebEdit("password").SetSecure "43615778631294eaade0e61e584b"
    Browser("NetOxygen").Page("NetOxygen").Frame("Fram e").WebButton("Submit").Click

    Works great without using the VBS file. Thanks for the tip though.

  6. #6
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: Replacing hard coded values in script

    This again is hard coded. When you say harded coded that means you have used a value in the code directly.

    For removing hard coded variable you need to put the value of the variable either in a parameter/environment/data table.

  7. #7
    Junior Member
    Join Date
    Jul 2001
    Location
    New York, NY
    Posts
    26
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Replacing hard coded values in script

    Yes, you are right. I will look into that. Thank you Tarun.

 

 

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 12:23 PM.

Copyright BetaSoft Inc.