Level 3 Advanced Training, Assignment 2, looping through the work item pages

Looking for some suggestion on how to best loop through the work items pages.

Here is my current script setup:

  • In Main, TransactionNumber is initially set to 1.
  • Main invokes GetTransactionData with initial TransactionNumber along with outer arguments.
  • GetTransactionData checks if the page exists and returns the TransactionNumber as out_TransactionItem
  • The TransactionItem variable in Main stores the retured out_TransactionItem. At this point TransactionItem is 1.
  • Main then invokes the process workflow where it passes the above TransactionItem
  • Process workflow clicks and checks for the workitem page that is currently active, which in this case is the first page.
  • It then scrapes the data of type = WI4 and Status = Open. If it finds any, it adds it to the quieue item.

Now my dilemma is where do I tell the execution thread to go to the next page.

One idea i have is build a loop in the Main workflow.
For example: Here is the pseudo code
TransactionNumber = 1
TransactionItem = Get Transaction Data (TransactionNumber)
While (TransactionItem != String.empty)
Process Transaction(TransactionItem)
TransactionNumber = TransactionNumber + 1
TransactionItem = Get Transaction Data (TransactionNumber)

The reason I am reluctant to go this route is that it will change few flow in the Main workflow.
Wondering if there is a better way to loop through the pages. Any help on this is greatly appreciated.



have you tried exploring the data scraping activity? It gathers the items from each page and even navigates to the next page until the end

This should be included in Process.xaml, first if the page which needs to be scrapped has not been clicked do this


After that

Scrape the data in OnElementAppear then Add to queue



Can’t use it as you have to treat each page scrap as a separate transaction


I don’t think thats specifically required . Each Work Item is a transaction (Hash code generation,Updation etc)

But scraping data comes under get transaction data in my opinion

Yup, the data scraping activity works but for this particular exercise we are assuming that the next page button “>” is not available and we are to find another way to navigate to the next page.
Having said that, my understanding is that we use Get Transaction Data to get the transaction Item, ie the next valid page number, then we pass the page number /Transaction Item to the Process workflow which will then do the data scraping. So In my mind the looping has to occur in the Main workflow outside of Get Transaction Data and Process Workflows.

I can scrape the data on the first page, my challenge is how to tell work flow to go to the next page. Somewhere I have to do TransactionNumber = TransactionNumber + 1 until the Get Transaction Data returns an empty string for TransactionItem for a given TransactionNumber.

Process.xaml have a click activity with dynamic selector it will automatically click on next page after scraping the current page

That means the loop has to be build around that click. Right now in my implementation, it clicks, then it checks if the element exists and if the element exists it scrapes the table data and add queue items for the rows that matches the criteria. My concern in building the loop around the click is the edge case i.e. the last page +1 . The click will fail to find the element to click in that case.

I think i got to the root cause of the issue.
The looping is provided by default by the REFramework. So I don’t need to explicitly increase Transaction Number. The reason it was not clicking the new page was that my selector on the element Exist in Get Transaction Data had SPAN and changing it to LI worked. Thank you all for your feedback.

1 Like

I want to know where should be placed this click activity, before or after the on appear activity?

I found the answer by myself lol, it is in de walkthrough, click is before the On appear activity, but click activity should be also enclosed in the same Attach browser activity with the on appear.

1 Like