Get text on a webpage with no error but unexpected results happened

activities

#1

Hello everyone, I have this confusing problem and hope anyone could help me.

I need to get a piece of information on a webpage and I need to iterate this for many times in my process. In every iteration firstly open a new webpage and then get text which I know the exact selector information save as a variable. And I use Try Catch so that if cannot get the right text, the Continue Activity works to make sure the process goes directly into the next iteration. You can find my UiPath code down below.

After several tests, the process works fine until this time when I made the whole process iterate for 50 times and I got 2 wrong results out of 50 results,which is the 20th and the 32th result. These two wrong texts happened to be exactly equals to the text before it, which means the 20th result equals to the 19th and the 32th result equals to the 31th.

I think the problem is during the 20th and 32th iteration, the Get Text activity worked without error but didn’t get any information for some reason, so it didn’t go into Catch and instead save the last iteration result into variable. However I can’t figure out the reason why this could happen. I doubt whether it is because the jam of the webpage but I think jam would cause the error of Get text activity. I wonder if I should use Get visible Text activity instead of Get Text.

I really hope anyone could help me with this confusing problem. Thank you so much!


image


#2

@RoseFeng
Try adding a simple delay. It might be that the process goes a bit to far and saves wrong result from the previous page.


#3

In every iteration the process would close the webpage after get text. So I think it would be possible to get the previous page’s information. I will try add a delay before get text and test more to see if this problem happen again. Thank you so much!


#4

Closing the webpage is best protection against an issue I was thinking about. It makes the problem a bit more tricky to debug without knowing specifics.

One more advise would be to clear the variable right after saving it (or giving it another default name). This way you will clearly see when the issue happens.


#5

I agree with your input, and I have added an Assign activity to assign the variable to a default value at the end of every iteration right after I encountered this problem. I just runned another test and “unfortunately” I didn’t have this kind of mistake so I still don’t know the exact reason. Thank you so much for your help!