SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 9 of 9
  1. #1
    Senior Member
    Join Date
    Dec 2004
    Location
    Pune
    Posts
    166
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Efficient and Optimized method of DP

    Hi,

    I'm using the function to set the text for the text field method as below

    strBrowser = "Welcome: Mercury Tours"
    strPage = "Welcome: Mercury Tours"

    call BrowserWebEdit ("userName","test")
    'Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").WebEdit("userName").Set "test"

    So whenever i need to set the text field i will just call the function mentioned above rather than writing the long line like the one which is commented above ('Browser("Welcome: Mercury Tours").Page...)

    Now as i've various function to set the weblist, checkbox, radio button etc. which method is more efficient?

    Do calling a function is more efficient and fast and consumes less memory than the traditional long line code?

    Please suggest me.

    Thanks,
    - ketan.
    Thanks,
    - ketan.

  2. #2
    Moderator ifraser's Avatar
    Join Date
    Jul 2004
    Location
    Brisbane, Australia
    Posts
    2,090
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Efficient and Optimized method of DP

    Very curious indeed...
    You can buy my Art from: "Post Cards now available"
    Ian Fraser Landscape Photography
    World Wide Shipping.

    http://mowogman.wordpress.com/

  3. #3
    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: Efficient and Optimized method of DP

    I would just say clock it and see it yourself. Also this kind of deep analysis should only be done one a need basis (IMO)

  4. #4
    Senior Member
    Join Date
    Dec 2004
    Location
    Pune
    Posts
    166
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Efficient and Optimized method of DP

    Hi Tarun,
    I agree, with what you said in your reply but if some one could atleast throw some pointers then it would be of great help!

    Anyways Thanks Tarun,

    -ketan.
    Thanks,
    - ketan.

  5. #5
    Senior Member
    Join Date
    Aug 2004
    Location
    Bloomington, IL
    Posts
    300
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Efficient and Optimized method of DP

    Hi Ketan,

    Here is your code--
    ------------------
    strBrowser = "Welcome: Mercury Tours"
    strPage = "Welcome: Mercury Tours"

    call BrowserWebEdit ("userName","test")
    'Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").WebEdit("userName").Set "test"


    ---------------------
    some time back i too got the same idea and tried to implement, After some point of time i stopped..Bcz

    Are you sure in your application every time the Browser and Page names would be constant? If the names are changed then you may need to write another function or need to increase the function parameters.Wont it difficult for maintanance?

    Are you sure that qtp identifies all of your text boxes with the same proerty? some times we use different properties like index, attached text.. that time you cannot use that function..

    'Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").WebEdit("index:=0").Set "test"

    Are you sure that your application hireachy is alwasy same? like

    'Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").WebEdit("index:=0").Set "test"
    'Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").Frame("xxxx").WebEdit("index:=0").Set "test"

    Can your function handle this?


    What i learned from my exp was writing a function for one line of code wont help us while automation. Correct me if i am wrong, Any more thoughts abt this?

    Thanks,
    Ashok

  6. #6
    Senior Member
    Join Date
    Dec 2004
    Location
    Pune
    Posts
    166
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Efficient and Optimized method of DP

    Thanks Ashok.
    Thanks,
    - ketan.

  7. #7
    Member
    Join Date
    Dec 2007
    Location
    Phoenix, AZ
    Posts
    32
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Efficient and Optimized method of DP

    You are correct - writing a function to replace 1 line of code to handle something like 1 edit box is somewhat foolish.

    However, using DP you can implement a fuction similar to the one below that handles all of your WebEdit boxes.


    EditBox "name:=UserName", Null
    EditBox "name:=SomeOtherName", "Index:=0"


    Sub EditBox(strRecMethod, strOptRecMethod, strValue)
    'Description:
    'Enters a value in the specified EditBox
    '================================================= ==============================
    'ParameterDescription:
    'strRecMethod = The recognition method for the EditBox
    'strOptRecMethod = Optional recognition method for the EditBox - when more than 1 with similar identification exists
    'strValue = The value to enter

    'Get Length of input value
    intValueLen = Len(strValue)

    If IsNull(strOptRecMethod) OR strOptRecMethod = "Null" Then
    'Get Max Length for input
    intMaxLen = Browser("index:=.*").Page("index:=.*").WebEdit(str RecMethod).GetROProperty ("max length")
    If intValueLen > intMaxLen Then
    If intMaxLen <> -1 Then
    'Trim Length of input
    Reporter.ReportEvent micWarning, strValue , intValueLen & ": Length exceeds field input value trimmed to: " & intMaxLen
    strValue = Left(strValue, intMaxLen)
    End If
    End If
    Browser("index:=.*").Page("index:=.*").WebEdit(str RecMethod).Set strValue
    Else
    'Get Max Length for input
    intMaxLen = Browser("index:=.*").Page("index:=.*").WebEdit(str RecMethod, strOptRecMethod).GetROProperty ("max length")
    If intValueLen > intMaxLen Then
    If intMaxLen <> -1 Then
    'Trim Length of input
    Reporter.ReportEvent micWarning, strValue , intValueLen & ": Length exceeds field input value trimmed to: " & intMaxLen
    strValue = Left(strValue, intMaxLen)
    End If
    End If
    Browser("index:=.*").Page("index:=.*").WebEdit(str RecMethod, strOptRecMethod).Set strValue
    End If

    End Sub

  8. #8
    Moderator ifraser's Avatar
    Join Date
    Jul 2004
    Location
    Brisbane, Australia
    Posts
    2,090
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Efficient and Optimized method of DP

    In the Demo link at the bottom of this post is a working example of what you are trying to do... At least I think its what you are trying to do. Your first post has nothing in it that is DP.
    You can buy my Art from: "Post Cards now available"
    Ian Fraser Landscape Photography
    World Wide Shipping.

    http://mowogman.wordpress.com/

  9. #9
    Senior Member
    Join Date
    Dec 2004
    Location
    Pune
    Posts
    166
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Efficient and Optimized method of DP

    Thanks Ford... I had a look at the functions for webedit in QTP Framework Demo and found very useful.

    Thanks to all of you for your support

    - ketan.
    Thanks,
    - ketan.

 

 

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.00%
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 04:10 AM.

Copyright BetaSoft Inc.