Lesson 6 practice 4


#1

Hi All,

Having problems with Lesson 6 practice 4

Basically you attach to yahoo finance

<html title='Commodities Futures - Yahoo Finance' />

Select last price for say something like gold gives you

<webctrl parentid='yfin-list' tag='TABLE' />
<webctrl idx='1' isleaf='1' tableCol='3' tag='TD' />

Now we want to be able to enter a commodity name and then have the correct price returned

We are told to select the TR selector node (so I go into UiExplorer asks me to select element on screen so I pick the gold price again which gives me

<webctrl parentid='yfin-list' tag='TABLE' />

I highlight the first TR node, nothing changes so I double click on it the selector changes to

<webctrl parentid='yfin-list' tag='TABLE' />
<webctrl css-selector='body&gt;div&gt;div&gt;div&gt;div&gt;div&gt;div&gt;div&gt;div&gt;div&gt;div&gt;div&gt;section&gt;div&gt;div&gt;div&gt;table&gt;tbody&gt;tr' idx='1' tag='TR' />

I follow the instructions and add the aaname node by ticking aaname box in right of UiPath Explorer, a window pops up saying

image

The selector tag has not changed

I remove css-selector tick in the box in UiPath Explorer and get another popup

image

and the selector code still hasn’t changed

There’s no aaname element to change and I still have the css-selector even though I unticked the css-selector tick box.

Apart from attaching to the yahoo finance page I don’t think anything has gone right on this.

Don’t know how to move forward at this point


#2

Right, So basically none of that was working for me and I didn’t understand how they had decided which node of the tree to pick the relevant fields to return a row based on a users input.

Here’s what I did.

First I went to UiExplorer and selected the price field from the commodity table. The selector raw looked like this.

<html title='Commodities Futures - Yahoo Finance' />
<webctrl parentid='yfin-list' tag='TABLE' />
<webctrl idx='1' isleaf='1' tableCol='3' tag='TD' />

The first 2 lines are good as they get us to the table the third line needs to be adjusted. we don’t want hardcoded numbers.

So lets get rid of idx/isleaf/tablecol and replace them with colName=‘Last Price’ (you can see that in the field list on the left hand side of the UiExplorer window.

That now gives us (which is defining which column to look for the data)

<html title='Commodities Futures - Yahoo Finance' />
<webctrl parentid='yfin-list' tag='TABLE' />
<webctrl tag='TD' colName='Last Price' />

That’s fine but we’ve removed the links to which row we are looking for by removing the numeric fields.

We know that we want to be searching by the commodity name so next I go to UiExplorer and select the name field for gold so I can examine that selector.

This gives me (if I include the aaname field and get rid of isleaf field (numeric hard coded constant which we don’t need)

<html title='Commodities Futures - Yahoo Finance' />
<webctrl parentid='yfin-list' tag='TABLE' />
<webctrl tag='TD' aaname='Gold' />

This unfortunately is not a very useful selector as what we really want is to define the row given a commodity name (in this case Gold).

However if we remember from the course notes we need to select the TR node from the visual Tree in UiExplorer (on the far left) .

if you select the TR node by DOUBLE CLICKING on it

image

(not just single clicking). It gives us

<html title='Commodities Futures - Yahoo Finance' />
<webctrl parentid='yfin-list' tag='TABLE' />
<webctrl css-selector='body&gt;div&gt;div&gt;div&gt;div&gt;div&gt;div&gt;div&gt;div&gt;div&gt;div&gt;div&gt;section&gt;div&gt;div&gt;div&gt;table&gt;tbody&gt;tr' idx='1' tag='TR' />

This has the tag TR which is going to give us the required row of the table
but it also has a lot of non useful info, so lets get rid of the css-selector and add the aaname field (this gets rid of the hardcoded numeric idx identifier).

<html title='Commodities Futures - Yahoo Finance' />
<webctrl parentid='yfin-list' tag='TABLE' />
<webctrl tag='TR' aaname='GC=FGold1,291.901:12PM EDT+2.50+0.19%222,566227,593' />

We can change the aaname field to *Gold* which is what we want to search for the *'s are wildcards that remove the need for date time specifics in the name

<html title='Commodities Futures - Yahoo Finance' />
<webctrl parentid='yfin-list' tag='TABLE' />
<webctrl tag='TR' aaname='*Gold*' />

The TR element is defining the row. The rest of the selector is the same as we had for retrieving the price.

<html title='Commodities Futures - Yahoo Finance' />
<webctrl parentid='yfin-list' tag='TABLE' />
<webctrl tag='TD' colName='Last Price' />

so if we add the TR (row) element to the price selector we have defined the row and the column we are interested in.

<html title='Commodities Futures - Yahoo Finance' />
<webctrl parentid='yfin-list' tag='TABLE' />
<webctrl tag='TR' aaname='*Gold*' />
<webctrl tag='TD' colName='Last Price' />

You can try this selector out to see that it retrieves the Gold price and then we will replace Gold with a variable containing the user defined input string to select any commodity (needs to be surrounded by double quotes)

<html title='Commodities Futures - Yahoo Finance' />
<webctrl parentid='yfin-list' tag='TABLE' />
<webctrl tag='TR' aaname='*"+commodityName+"*' />
<webctrl tag='TD' colName='Last Price' />

There is an issue to be aware of however. Sometimes the doublequotes are replaced by &quot; after editing and this will not work, so you need to go into the small selector text entry box in the properties pane

image

and replace the &quot; with " manually (don’t know why this bug exists seems like a major issue with creating selectors).

Anyway I hope this helps. If anyone thinks that there are changes needed to be made to this I’ll be happy to amend.

Here is the xaml

l6p4.xaml (6.8 KB)