Error while getting ui element text

Hi All,

I am trying to generate random numbers using “https://www.random.org/” website and then storing the generated number in data table. There seems to be something wrong with the uielemnt. Can someone please help.

  1. opening browser and launching the url mentioned above
  2. clicking on generate button.
  3. once the number is generated trying to read the generated number and store it into a variable RandomNumber.

What I am getting into the variable is –
"Result:
The numbers generated by

"

When examined the source code of the page I can see the value picked is not tag value but something else. Please see here, the value of red highlighted tag should be captured but it is capturing the value of blue highlights

image

HI @swetha_pattabhi

Try the below selector. It works for me.

<html app='firefox.exe' title='RANDOM.ORG - True Random Number Service' />
<webctrl src='https://www.random.org/widgets/integers/iframe.php?title=True+Ra*' tag='IFRAME' />
<webctrl id='true-random-integer-generator-result' tag='SPAN' />

Let know how it goes

It looks like you have used firefox browser. I am looking for google chrome browser.

Try this for chrome

<html app='chrome.exe' title='RANDOM.ORG - True Random Number Service' />
<webctrl src='https://www.random.org/widgets/integers/iframe.php?title=True+Ra*' tag='IFRAME' />
<webctrl id='true-random-integer-generator-result' tag='SPAN' />

I am generting n number of time and trying to store in excel. Its picking value 55 everytime. Attached is my project
ExcelActivities.zip (12.4 KB)

please help

@swetha_pattabhi

I don’t see a problem there. It works fine in mine. Check below

In every iteration, it clicks on generate, and grabs the result without any issue.

weird. I dont see a reason why it doesnt work at my end. Everytime RandomNumber is null

I think I noticed where you are going wrong…

You have added the debug point on the Get Text activity. Just like I have done here

In both cases, the get text activity is highlighted in yellow, which means, it is not yet executed. That’s why that variable has a null value. Once it gets there, click on Step Into on the top ribbon to execute that activity. Then you will see the value :slight_smile:

Lahiru, Thank you for staying connected. I got my problem. I am using two sequences if you notice the problem. As i have not named the sequences when the variable RandomNumber is created its scope has been Sequence. It was supposed to be the outer sequence scope but it was actually inner sequence scope. I changed scope of variables and it worked fine.

1 Like

yep. I noticed that. But I don’t think that is making much of a difference because anyway you are assigning the value to a data table which is set to the outer most sequence. So by the time you get out of that loop, it is already available in the outer sequence :slight_smile:

Anyways… glad to hear it got sorted :slight_smile:

True, that shouldn’t be the problem. But its weird. In Debug mode i did step over and verified step by step it always had null values. So i changed scope of all variables to outer sequence.

1 Like

I know you probably have a reason why you’re using that website, but, in case anyone comes here that doesn’t know, UiPath can generate random numbers by itself using VB.net. Please see the documentation for the details: VBMath.Rnd Method (Microsoft.VisualBasic) | Microsoft Learn

Nitpicking at this point, but those numbers are pseudo-randoms. Still, this should suffice in almost all cases.

Hi @swetha_pattabhi,

Try with get text In place of get visible text to extract data
It will give exact result

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.