SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 10 of 10
  1. #1
    Member
    Join Date
    Sep 2006
    Location
    NYC
    Posts
    257
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Do Until Loop question

    I am trying to find the simplest way to write a loop where it searches the values of a weblist until it finds a particular value.

    This is what I have so far but it doesn't work

    sSender = Browser("Browser").Page("Page").Frame("Frame").Web List("Dropdown").GetItem(i)
    senderCount = Browser("Browser").Page("Page").Frame("Frame").Web List("Dropdown").GetROProperty("items count")
    Do Until sSender = "MyValue"
    For i=1 to senderCount
    datatable.SetCurrentRow(i)
    datatable("Actual_Value",dtglobalsheet) = sSender
    Next
    Loop

  2. #2
    SQA Knight
    Join Date
    Jun 2008
    Posts
    2,612
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0

    Re: Do Until Loop question

    Well for one thing this needs to be inside your loop so it will iterate the value being checked.

    sSender = Browser("Browser").Page("Page").Frame("Frame").Web List("Dropdown").GetItem(i)

    Looks like you're currently iterating through your datatable rather than the weblist which doesn't match what you're asking for.

  3. #3
    Member
    Join Date
    Feb 2002
    Location
    Toledo, Ohio USA
    Posts
    262
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Do Until Loop question

    [ QUOTE ]
    Well for one thing this needs to be inside your loop so it will iterate the value being checked.

    sSender = Browser("Browser").Page("Page").Frame("Frame").Web List("Dropdown").GetItem(i)

    Looks like you're currently iterating through your datatable rather than the weblist which doesn't match what you're asking for.

    [/ QUOTE ]


    Yeap - Nouse has it right. Your code would look like:



    senderCount = Browser("Browser").Page("Page").Frame("Frame").Web List("Dropdown").GetROProperty("items count")
    Do Until sSender = "MyValue"
    For i=1 to senderCount
    datatable.SetCurrentRow(i)
    sSender = Browser("Browser").Page("Page").Frame("Frame").Web List("Dropdown").GetItem(i)
    datatable("Actual_Value",dtglobalsheet) = sSender
    Next
    Loop

    Good luck!

  4. #4
    SQA Knight
    Join Date
    Jun 2008
    Posts
    2,612
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0

    Re: Do Until Loop question

    That's still very odd. Can get into an infinite loop if "MyValue" is not present.

    Should initialize sSender before entering the loop.

    The Do Until loop is pointless as nothing iterates there. It's all inside the For loop.

  5. #5
    Member
    Join Date
    Sep 2006
    Location
    NYC
    Posts
    257
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Do Until Loop question

    [ QUOTE ]
    [ QUOTE ]
    Well for one thing this needs to be inside your loop so it will iterate the value being checked.

    sSender = Browser("Browser").Page("Page").Frame("Frame").Web List("Dropdown").GetItem(i)

    Looks like you're currently iterating through your datatable rather than the weblist which doesn't match what you're asking for.

    [/ QUOTE ]


    Yeap - Nouse has it right. Your code would look like:



    senderCount = Browser("Browser").Page("Page").Frame("Frame").Web List("Dropdown").GetROProperty("items count")
    Do Until sSender = "MyValue"
    For i=1 to senderCount
    datatable.SetCurrentRow(i)
    sSender = Browser("Browser").Page("Page").Frame("Frame").Web List("Dropdown").GetItem(i)
    datatable("Actual_Value",dtglobalsheet) = sSender
    Next
    Loop

    Good luck!

    [/ QUOTE ]

    When I tried this, it gets stuck in an infinite loop even though "MyValue" is there. It seems like it is not recognizing "MyValue"

  6. #6
    SQA Knight
    Join Date
    Jun 2008
    Posts
    2,612
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0

    Re: Do Until Loop question

    Still not quite sure what you're attempting but this is my guess based on what you've given.

    <font class="small">Code:</font><hr /><pre>
    senderCount = Browser("Browser").Page("Page").Frame("Frame").Web List("Dropdown").GetROProperty("items count")
    sSender = ""
    exitCounter = 0
    Do Until sSender = datatable("Actual_Value",dtglobalsheet)
    sSender = Browser("Browser").Page("Page").Frame("Frame").Web List("Dropdown").GetItem(exitCounter)
    exitCounter = exitCounter +1
    If exitCounter &gt; senderCount then
    Reporter.ReportEvent micFail, datatable("Actual_Value",dtglobalsheet), "Not Found"
    Exit Do
    End If
    Loop
    </pre><hr />

    Blah still messy. This should just be a For loop since you have a fixed length in my opinion.

  7. #7
    Member
    Join Date
    Sep 2006
    Location
    NYC
    Posts
    257
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Do Until Loop question

    [ QUOTE ]

    Blah still messy. This should just be a For loop since you have a fixed length in my opinion.

    [/ QUOTE ]
    You're right, this is quite messy. Would you mind helping me out with the code for the For loop? I'm having trouble getting it to look for the "MyValue" value within the weblist.

    This is my failed attempt:

    senderCount = Browser("Browser").Page("Page").Frame("Frame").Web List("Dropdown").GetROProperty("items count")
    For i=1 to senderCount
    sSender = Browser("Browser").Page("Page").Frame("Frame").Web List("Dropdown").GetItem(i)
    datatable.SetCurrentRow(i)
    datatable("Actual_Value",dtglobalsheet) = sSender
    Do Until sSender = "MyValue" or i=30
    Loop
    Next

  8. #8
    SQA Knight
    Join Date
    Jun 2008
    Posts
    2,612
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    1 Thread(s)
    Total Downloaded
    0

    Re: Do Until Loop question

    Is this what you're trying to do?

    Loop through the Weblist
    Write every value in the weblist to the datatable until you get to the string "MyValue"?

    If so, then this:
    <font class="small">Code:</font><hr /><pre>
    senderCount = Browser("Browser").Page("Page").Frame("Frame").Web List("Dropdown").GetROProperty("items count")
    For i=1 to senderCount
    sSender = Browser("Browser").Page("Page").Frame("Frame").Web List("Dropdown").GetItem(i)
    datatable.SetCurrentRow(i)
    datatable("Actual_Value",dtglobalsheet) = sSender
    If sSender = "MyValue" Then
    Exit For
    End If
    Next
    </pre><hr />

  9. #9
    Member
    Join Date
    Sep 2006
    Location
    NYC
    Posts
    257
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Do Until Loop question

    [ QUOTE ]
    Is this what you're trying to do?

    Loop through the Weblist
    Write every value in the weblist to the datatable until you get to the string "MyValue"?

    If so, then this:
    <font class="small">Code:</font><hr /><pre>
    senderCount = Browser("Browser").Page("Page").Frame("Frame").Web List("Dropdown").GetROProperty("items count")
    For i=1 to senderCount
    sSender = Browser("Browser").Page("Page").Frame("Frame").Web List("Dropdown").GetItem(i)
    datatable.SetCurrentRow(i)
    datatable("Actual_Value",dtglobalsheet) = sSender
    If sSender = "MyValue" Then
    Exit For
    End If
    Next
    </pre><hr />

    [/ QUOTE ]

    Yes, that was exactly what I was looking for. Thanks Nouse!

  10. #10
    Member
    Join Date
    Feb 2002
    Location
    Toledo, Ohio USA
    Posts
    262
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Do Until Loop question

    Looks like you two went back and forth for a while - sounds like most Requirements discussions I've been in, r.e. "Do you mean this, or this?"


    Glad to hear you got the resolution you needed.

 

 

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.40 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.71%
vBulletin Optimisation provided by vB Optimise v2.7.1 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.3.0 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 02:30 AM.

Copyright BetaSoft Inc.