How to use wildcard with variable inside a selector?

This query is with reference to Lesson 6 Practice 4, where it is required to pull data from a table row based upon user input. The walk through for this practice in academy is not satisfactory and does not help to get any results. I browsed many topics related to it and found this topic to be close to the solution but still it is not executing,

[Lesson 6 practice 4](http://Lesson 6 practice 4)

Here I will present my work based on the above topic in order to attain results, please correct me wherever possible.

  1. There is no “aaname” attribute for tag “TR”. as told in L6P4 walk through.
    Ui Explorer snapshot:
    image

You see the problem above? No “aaname” attribute is present for “TR”

  1. Below selector line for highlighting Table row containing desired user input value (stored in variable varComm) did not gave desired results, and because "“aaname” was not available I decided to go with “innertext” attribute.
    "<html title='Commodities Futures - Yahoo Finance' />
    <webctrl parentid='yfin-list' tag='TABLE' />
    <webctrl tag='TR' innertext='*"+varComm+"*' />
    <webctrl tag='TD' colName='Name' />"
    The wildcard does not work here it can be seen in error dialog during execution is interpreted as a value like *varComm*, so the program stops here. For example: varComm = “Silver” the interpretation will be *Silver*

  2. The last part would be pulling the “Last Price” of the commodity, so I wrote a selector for it below,
    "<html title='Commodities Futures - Yahoo Finance' />
    <webctrl parentid='yfin-list' tag='TABLE' />
    <webctrl tag='TR' innertext='*"+varComm+"*' />
    <webctrl tag='TD' colName='Last Price' />"

Sadly, I cannot reach to step-3 during execution.

I am a newbie just started few week back, and I am looking forward to learn and grow with the community. Any kind of correction or guidance will be very helpful to me.

Please help me to correct this exercise.
Feel free to ask for more details about the problem.

Thank You in advance!!

Hiii,

It might be easier to understand how you are actually using the variable in your code, maybe with a screenshot of your activity and properties.

This looks correct, however, it should be like this as an expression, not as a selector. By that, I mean, if you click edit selector, it should show you the “Expression Editor” not the “Selector Editor”. The text between the double quotes will be red and the variable will be black. So, if you do that correct, it looks good from my perspective.

If you need to know how to edit the selector as an expression, simply click inside the Selector property box, instead of using the 3 dots. After it is edited, though, the 3 dots will show the Expression Editor.

This may change in future versions with how variables can be implemented in selectors, and I’m on a 2018 version, so I’m assuming 2019 is similar with selector manipulation.

Hopefully this helps.

Regards.

1 Like

Thanks Calyton, for sharing your views. I would like to add that I am already using it as an expression.

Can you share a screenshot of the activity and properties that is giving you an error? Also, what the error looks like? And, as part of your own troubleshooting steps, output the entire selector string to a Message Box or Output console to validate that the string matches what UiExplorer gives you as a selector, in order to make sure your variable is coming in correctly.

Regards.

1 Like

@Roshan_Jha
Using inner text will not help i guess, I tried to use that before, i didnt work. You need to look for some other element.
Moreover, is that * need before and after? ‘"+varComm+"’ should be sufficient if you have varying varComm value which is changing each time, say in a loop.

It depends, but I would say, it’s a good practice to surround the value with wildcard on both sides. For example, if you look for an element that says “not found”. Potentially, the selector could change in the future to say “the search was not found” or spaces or period could be added like "not found ". Additionally, if you don’t want it to be case-sensitive, then you can use a selector value like '*ot *ound*', assuming it’s not possible for the value to ever be other words like “got round” :laughing:

1 Like

Instead of using innertext, use innerhtml.

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

This worked here.

Regards,

Bruno Costa.