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
    Dec 2006
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    ChildObjects/Descriptive Programming -> slow

    I'm currently writing on a qtp-framework without using the OR.
    There is 1 thing I can't understand, if I using my code when I only have 1 browser openend, it takes 9seconds on the codeline 'set oCollection = objPage.Childobjects(oDesc)'. If I run this code when more than 1 browser is opened, I instantly get my msgbox telling me how many webedits there were found.

    For my example I use the linked-in website and it returns me 5 webedits.

    <font class="small">Code:</font><hr /><pre> <font color="blue">
    Sub FindChildObjects()

    set objPage=Browser("name:=.*","index:=0").Page("index :=0")
    Set oDesc = Description.Create()
    oDesc("micclass").Value = "WebEdit"
    'Possible values: text; hidden -&gt; so 'text' means it is a visible control I SUPPOSE!
    oDesc("type").value = "text"
    Set oCollection = objPage.ChildObjects(oDesc)

    NumberOfobjects = oCollection.Count
    msgbox NumberOfobjects

    For i = 0 To NumberOfobjects - 1
    msgbox oCollection(i).getroproperty("name") &amp; "-" &amp; oCollection(i).getroproperty("type")
    Next

    End Sub
    </font> </pre><hr />

    Who can tell me what is causing this behavior? And even better, how to get rid of it!

  2. #2
    Moderator
    Join Date
    Sep 2001
    Location
    Doncaster, UK
    Posts
    5,788
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: ChildObjects/Descriptive Programming -> slow

    For single browsers use:

    set objPage=Browser("micClass:=Browser").Page("micClas s:=Page")

    Mark Smith.

  3. #3
    Junior Member
    Join Date
    Dec 2006
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: ChildObjects/Descriptive Programming -> slow

    [ QUOTE ]
    For single browsers use:

    set objPage=Browser("micClass:=Browser").Page("micClas s:=Page")

    Mark Smith.

    [/ QUOTE ]

    That works indeed when using a single browser. It's actually the same as:
    set objPage=Browser("name:=.*").Page("index:=0")

    But the problem is, sometimes the webapp opens another window and then I receive an error when using your code (because there is more than 1 match of course). I actually need a solution that works for both.

    Or a workaround could be some code to check if there is more than 1 browser. So I wrote this:

    <font class="small">Code:</font><hr /><pre>
    <font color="blue">
    i=0
    sBrowserName = ""
    Do while Browser("name:=.*","index:=" &amp; i ).exist
    If sBrowserName = browser("name:=.*","index:=" &amp;i).getroproperty("name") Then
    Exit do
    else
    msgbox browser("name:=.*","index:="&amp;i).getroproperty( "name")
    sBrowserName=browser("name:=.*","index:="&amp;i).g etroproperty("name")
    i=i+1
    End If
    Loop</font>
    </pre><hr />

    But then my code pauzes on the browser.exist line when the browser with an unexisting index is not found. So again, I lose time.

  4. #4
    Moderator
    Join Date
    Jan 2007
    Location
    Pittsburgh, PA
    Posts
    2,497
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: ChildObjects/Descriptive Programming -> slow

    Try this technique to create browser description.

    Function BrowserDesc()
    Dim Obj
    Set Obj = Description.Create
    Obj("micclass").Value = "Browser"
    'Obj(openedbytestingtool").Value = True 'Add this line to Ignore QC Browser
    If Desktop.ChildObjects(Obj).Count = 1 Then
    Set BrowserDesc = Obj
    Else
    Obj("CreationTime").Value = 0
    Set BrowserDesc = Obj
    End If

    Set Obj = Nothing
    End Function

    Browser(BrowserDesc).HighLight

  5. #5
    Junior Member
    Join Date
    Dec 2006
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: ChildObjects/Descriptive Programming -> slow

    Thanks for your help! I fixed it using following code to detect how much browserwindows are available and based on that number I set my browserobject.

    <font class="small">Code:</font><hr /><pre> <font color="blue">
    Sub FindChildObjects()

    Set oBrowserDesc=Description.Create
    oBrowserDesc("micclass").value="Browser"
    iBCount= desktop.ChildObjects(oBrowserDesc).count

    If iBCount = 1 Then
    Set objPage = Browser("name:=.*").Page("index:=0")
    else
    Set objPage = Browser("name:=.*","index:=0").Page("index:=0")
    End If

    Set oDesc = Description.Create()
    oDesc("micclass").Value = "WebEdit"
    oDesc("type").value = "text" 'Possible values: text; hidden -&gt; so 'text' means it is a visible control I SUPPOSE!
    Set oCollection = objPage.ChildObjects(oDesc)

    NumberOfobjects = oCollection.Count
    msgbox NumberOfobjects

    For i = 0 To NumberOfobjects - 1
    msgbox oCollection(i).getroproperty("name") &amp; "-" &amp; oCollection(i).getroproperty("type")
    Next

    End Sub
    </font>
    </pre><hr />

  6. #6
    Member
    Join Date
    Oct 2003
    Location
    Norfolk, VA
    Posts
    360
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: ChildObjects/Descriptive Programming -> slow

    Additionally, your method works quicker if you set the timeout for exist:

    <font class="small">Code:</font><hr /><pre>i=0
    sBrowserName = ""
    Do while Browser("micclass:=Browser","index:=" &amp; i ).exist(0)

    msgbox browser("name:=.*","index:="&amp;i).getroproperty( "name")
    sBrowserName=browser("name:=.*","index:="&amp;i).g etroproperty("name")
    i=i+1

    Loop
    msgbox "There are "&amp;cstr(i)&amp;" browsers currently open"</pre><hr />

    There is a default timeout for exist (I think it's 10 or 20 seconds) by setting a value you override that default.
    A good rule of thumb is to never measure with your thumb.

  7. #7
    Junior Member
    Join Date
    Dec 2006
    Posts
    11
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: ChildObjects/Descriptive Programming -> slow

    [ QUOTE ]
    Additionally, your method works quicker if you set the timeout for exist:

    <font class="small">Code:</font><hr /><pre>i=0
    sBrowserName = ""
    Do while Browser("micclass:=Browser","index:=" &amp; i ).exist(0)

    msgbox browser("name:=.*","index:="&amp;i).getroproperty( "name")
    sBrowserName=browser("name:=.*","index:="&amp;i).g etroproperty("name")
    i=i+1

    Loop
    msgbox "There are "&amp;cstr(i)&amp;" browsers currently open"</pre><hr />

    There is a default timeout for exist (I think it's 10 or 20 seconds) by setting a value you override that default.

    [/ QUOTE ]

    Ah, thanks for that info, I completely forgot that! I was looking in the options to change the timeout but forgot it was even easier! Thanks guys!

 

 

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 04:45 PM.

Copyright BetaSoft Inc.