How do we use the ForLoop object to loop through a dynamic website that is not an HTML table?
Currently, there is a tree navigation that was interrogated on the site that I would like to loop through. There is a Div with a class called "tree" and under this Div, there are multiple Divs with the class called "treerow". I have created a container for the Div with class "tree" and want to loop through "treerow". There is not a set number of "treerow" divs that will populate. For each of the "treerow", the plan is to grab the value of the span element so I could do a value comparison. What would an example of this automation look like in Pega Robotics?
So within this div class "tree", the 1st span has the class "treeRow". I am trying to get to the 2nd span that does not have a class but within this span, there is a div class "treeRow". Then loop within the span class "treeBranch", I am trying to loop through each div class "treeRow" and get the value of the span that has a unique fieldname attribute. In this case, I would be looping to get the values - "Item 3" and "Item 4". Keep in mind that the "treeRows" within this "treeBranch" is dynamic so in some cases, the number of "treeRows" would change within this "treeBranch". The setup of this site is complicated and any help is greatly appreciated.
You would enable UseKeys on the TreeRow object you have interrogated. You would call the GetClones method of the TreeRow and pass that to a ListLoop. This will likely be in order, but has no specific contract to be, so you would need to discern the order by using a value within the TreeRow. If one doesn't exist, it may not be possible to guraentee the order, but you can certainly access all of the elements still. Coming out of the ListLoop, you would extract a proxy which would represent one of the TreeRow controls. From here, you can grab the value of the corresponding "fieldName" to get the data you need.
I am not sure what you mean by dynamic in regards to the "fieldname". In this case, you are iterating the TreeRow. You could then evaluate whatever is beneath it. If you would like to do this with some C# and parse out the InnerHTML of the "Tree", then you can certainly do that. That wouldn't be anything specific to Pega Robotics though. You would get more information searching for parsing HTML with C#.
I tried passing GetClones to ListLoop and when I extracted the proxy, I got a webControlProxy. When I used a messageDialog to see the result, it only gave me the name of the field I interrogated. Not sure how I could go about this.
That webControl is an instance of the TreeRow. If you grab any properties of it or its children, they would normally have a key fitting appear on them. Out of the ListLoop, they will inherit that key from the webControl since it is one single clone in the collection.