SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Member
    Join Date
    Apr 2008
    Posts
    65
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Set Next Row in functions

    I am trying to set next row on my global sheet from inside a public function. When I try this it does not set to the next row correctly. It goes to the next row but it still reads the 1st line of data. If I pull the code out and run it from outside the function it works correctly.

    Thanks in advance.

  2. #2
    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: Set Next Row in functions


    one of these will work for you.
    Datatable.GetSheet("SheetName").SetNextRow
    Datatable.GetSheet("SheetName").SetCurrentRow(RowN um)

    Thanks,
    Ashok

  3. #3
    Member
    Join Date
    Apr 2008
    Posts
    65
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Set Next Row in functions

    I tried the following:

    Datatable.GetSheet("SheetName").SetNextRow
    Datatable.GetSheet("SheetName").SetCurrentRow(RowN um)

    It still only inputs the 1st row of data in the function I am calling. I am using a Do Until loop to loop through my datatable until current row count is equal to max row count. Does QTP not like this inside a function?

  4. #4
    Member
    Join Date
    Apr 2009
    Location
    San Diego
    Posts
    413
    Post Thanks / Like
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Set Next Row in functions

    Silly question but how are you passing in the rowcount to the function? Can you add the code to the post?

  5. #5
    Senior Member
    Join Date
    Jan 2000
    Location
    USA, CA
    Posts
    1,998
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Set Next Row in functions

    Do not do it in Global sheet.
    Rows there have different purpose:
    Each row in Global sheet represent Iteration of Test Case.
    That's why QTP doesn't listen your code to set rows, QTP has his own priorities to do that. Nobody else.
    QTP passed them one by one , executing whatever is located in the local sheet.
    With your loop, you've just messed up Iteration strictire.

    Do your task in local sheet. QTP gives you full control on rows, switching them, counting them... whatever you want.

    Janna

  6. #6
    Member
    Join Date
    Feb 2009
    Posts
    62
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Set Next Row in functions

    I guess you should use "Global" instead "SheetName" in :
    Datatable.GetSheet("SheetName").SetNextRow

  7. #7
    Senior Member
    Join Date
    Jan 2000
    Location
    USA, CA
    Posts
    1,998
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Set Next Row in functions

    NO.
    GetSheet Function requires SheetName as parameter and
    doesn't work with "Global" sheet, as I've explained in my post.

    Janna

  8. #8
    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: Set Next Row in functions

    This works for me...

    GlobalRows = DataTable.GetSheet(dtGlobalSheet).GetRowCount
    For i = 1 to GlobalRows

    datatable.SetCurrentRow(i)
    'Yada yada yada
    Next

  9. #9
    Senior Member
    Join Date
    Jan 2000
    Location
    USA, CA
    Posts
    1,998
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Set Next Row in functions

    For how many Iterations?
    And what is purpose of this code?
    Let's say: you've passed first Iteration. It works.
    Next Iteration will go to the second row of Global sheet
    and will do the same (executing your loop...).
    Then it will happen with every row in Global sheet.
    (Unless you've set RunOneRowOnly in DataTable configuration)
    Is is what do you want?
    If so. It is very-very bad design.
    Explaining why:
    Global sheet is named Global not just because they wanted this name. It is descriptive. It is designed to spin general project data (or some kind of general data). No coded loop is required. QTP will loop Iterations automatically, according rows in Global sheet.
    Let's say: in Global you have: Users, UserIDs, UserAccounts and so on. No matter how many of them. Sometime you need just one, next would be ten, other day: it would be thousand. It depends on your settings (managed from another script or INI, or whatever).
    And what do to with etch User is defined in Local (or Named) sheet. It might be even 2 or 3 such a sheets - depending on complicity and presictability of your initial design...
    Then QTP - very easy, without any work around will pass every row from Global sheet and execute your codes for Local sheet, doing what you need to process for every User.
    That's how QTP designed DataTables.
    That's how it works.
    Try on little project - what I mean.
    You'll get it.
    Janna

  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: Set Next Row in functions

    I agree I wouldn't ALWAYS do the looping as I mentioned, but I can see a particular need to do so.

    For example, I am extracting the data from a web table at RUNTIME and pulling that data (including creation of parameters, etc.) into the Globalsheet.

    This data needs to be available and used both within the current action as well as possible called actions. So as I pull in the data, I don't always know how many rows of data will be returned.

    Therefore, I use a count of the rows in the global sheet to define how many times I do xx or yy.

    It's not perfect, but it works for me and my particular needs - and would seem to solve the poster's immediate issues.

 

 
Page 1 of 2 12 LastLast

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 8.82%
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 10:19 PM.

Copyright BetaSoft Inc.