SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 7 of 7
  1. #1
    Member
    Join Date
    Dec 2007
    Posts
    66
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Count same Div in the same webpage (dinamic)

    I swear, I couldn't find a similar post...it's blody hard!

    Problem: I have a page whcih includes the same DIV more then once, but with dinamic content.

    It's about staff profile page (no tables are present), and each member is present within each single box-Div.

    Now, how can I count the amount of div presents and take the innertext(or outer) from it?

    I guess that the only way to do it is via descriptive programming, but I'm not very good on it, and I have not got a clue about it.

    Any suggestion guys.

    Thanks

  2. #2
    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: Count same Div in the same webpage (dinamic)

    User ChildObjects method. Look in QTP help file or forum for more details.

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

    Re: Count same Div in the same webpage (dinamic)

    Hi Taurun

    OK
    I managed to work to this code. This should basically navigate from the top level through the page where I want to count the Divs (and get their propety "innertext"):


    Browser("Browser").Sync
    Browser("Browser").Page("ParentPage").Sync
    Browser("Browser").Page("ParentPage").Image("menu_ aboutus").FireEvent "onmouseover"
    Browser("Browser").Page("ParentPage").Link("Our Team").Click
    Browser("Browser_OurTeam").Sync
    Sub ChildObjects_Example()
    Set oDesc = Description.Create()

    oDesc("html id").Value = "main_value" <-used to identify the Object within the OR

    Set Lists = Browser("Browser_OurTeam").Page("OurTeam").ChildOb jects(oDesc)

    NumberOfLists = Lists.Count()
    For i = 0 To NumberOfLists - 1
    DataTable("Text", dtGlobalSheet) = Browser("Browser_OurTeam").Page("OurTeam").WebElem ent("Staff Box").GetROProperty("innertext")
    Lists(i).Select i + 1
    Next
    End Sub

    All I want to do is to naviagate from:
    ParentPage> OurTeam page

    within this page

    identify the webElement "Staff Box" and

    For each of them report the "innertext" value and put it in the GlobalSheet.

    Ah...I was about to forget. IT DOESN'T WORK

  4. #4
    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: Count same Div in the same webpage (dinamic)

    HTML ID is supposed to be unique for any object hence the code is not suppose to work at all. Not sure how your web page displays the data. Can you attach the HTML source code of the web page to this post?

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

    Re: Count same Div in the same webpage (dinamic)

    Hi Tarun

    Thanks for helping me. Ok, the code you will see is what is the current way of the page to display the Staff Member profiles.

    As you will se I attached the code for two different persons, but they have similar code details:

    class: DealerTeam_staff_content
    id: DealerTeamControlBrand_staff_content

    Now, what I would like to do is write a script that for each class or id present in the page, give me as result the content within that Div.

    I wrote the following code:

    Browser("Dealer Home").Sync
    Browser("Dealer Home").Page("Brand Cardiff - Dealer").Sync
    Browser("Dealer Home").Page("Brand Cardiff - Dealer").Image("menu_aboutus").FireEvent "onmouseover"
    Browser("Dealer Home").Page("Brand Cardiff - Dealer").Link("Our Team").Click
    Browser("Our Team").Sync
    Browser("Our Team").Page("Brand Cardiff - Our Team").Sync
    Sub ChildObjects_Example()
    Set oDesc = Description.Create()
    oDesc("html id").Value = DealerTeamControlBrand_staff_content
    Set Lists = Browser("Our Team").Page("Brand Cardiff - Our Team").ChildObjects(oDesc)
    NumberOfLists = Lists.Count()
    For i = 0 To NumberOfLists - 1
    Lists(i).Select i + 1
    DataTable("Text", dtGlobalSheet) = Browser("Our Team").Page("Brand Cardiff - Our Team").WebElement("Staff Box").GetROProperty("innertext")
    Next
    End Sub


    Believe it or not, I don't get any error, but I don't get even a result. The Globalsheet is not giving anything, it's empty.

    Thank you for your time.
    Attached Files Attached Files

  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: Count same Div in the same webpage (dinamic)

    Just missing some basic touch

    <font class="small">Code:</font><hr /><pre>
    Set oDesc = Description.Create

    oDesc("html tag").value = "DIV"
    oDesc("micclass").value = "WebElement"
    oDesc("html id").value = "DealerTeamControlBrand_staff_content"

    Set oDesc2 = Description.Create
    oDesc2("micclass").value = "WebElement"
    oDesc2("html tag").value = "DIV"

    Set allDealers = Browser("Browser").Page("Page").ChildObjects(oDesc )

    For i = 0 to allDealers.count -1
    Set details = allDealers(i).childObjects(oDesc2)
    print allDealers(i).GetROProperty("outertext")

    For j = 0 to details.count-1
    print details(j).GetROProperty("outertext")

    Next
    Next
    </pre><hr />

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

    Re: Count same Div in the same webpage (dinamic)

    Hi Tarun

    Thank you very much for your help! I had to twist the code you gave me just a little bit in order to get the results in my Local Sheet, and now it is working fine.

    Grazie mille!

 

 

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 12.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 02:34 AM.

Copyright BetaSoft Inc.