Using Refresh Browser in a Loop until Element appears

Hey Everyone,

Could really use some help with an issue I cant seem to solve. For quite a while I was using an Element Exists activity that would look for a picture on a webpage. If the picture existed then I knew there was a button that had not shown up yet. I then put the Element Exists inside a while loop and added a Delay as well as a Refresh Browser activity (pic below). I set the browser to refresh every 4 seconds to look for the button I needed. This was working flawlessly and then just stopped. No idea why or how. I’m now looking for help to get this working again.

Here is the original setup that was working:

Below are the properties for the element:

properties

One item to note: The element has an id associated with it that changes every time the screen refreshes. Below is a snip of indicating the element:

element

Due to this I altered the element so it wasn’t looking for the id:

Lastly here are all the values for the element:

values

@djkmod83

Welcome back to our UiPath community.

Can you please run the process in Debug mode and help us with exact error you are getting here. So that we can check and help you.

Thanks, the problem with the debug is it doesn’t error out. When the button appears, instead of breaking the loop it just continues refreshing while the button exists.

looks like the selector always exist, still it show in the interface or not, it can be a hidden selector but still exist, can you try picking another element which refer to the action you need?

regards!

Try to use WaitForReady.Complete instead of interactive and also you can try to find an image with image exists command or looks for visibility property in the image object.

1 Like

Thanks,

I tried the WaitForReady.Complete however that did not change the outcome, still kept refreshing. I can attempt the Image Exists I just know that sometimes it is not the most accurate. I am however interested in the visibility property.

Would this be the correct workflow for that?

If so I tested this last night and it did refresh a number of times but then it broke out. However the button I’m waiting for was not there but for some reason it still broke out of the loop.

Thanks for your help

EDIT: I do have the same Get Attribute activity just above the while loop not pictured.

Yes I thought about using another selector but there are only 3 elements i can potentially use there is the picture in question as well as another below it that is giving the same issue. There is a third element that shares the same text as the element when the button does show up but have refrained from using it because it is somewhat too similar.

and can you use image in your automation? i mean for check if image exist or text exist in the screen

I was just attempting the text exists as I saw your reply. This is the full element:

test

I did a Text Exists activity and ran it and it was working (refreshing) as expected however it then errored out and after attempting a debug it showed my variable was false. So for some reason it didn’t find the text even though it was still there.

This is what I am testing currently:

I did set the WaitForReady.Complete just in case that was the issue and ran into the same problem. It refreshes for a period of time then it changes the boolean to false when, in fact, it is not false.

I will attempt the Image Exists just to see.

Thanks

@djkmod83, on a comment above I saw you remove id from selector due to changes on it. Did you try to put it again, and put wildcards such as *?

@djkmod83 While loop stops when the condition is true. In your case when it finds the element. Also, Request for services will appear here is the button ? . If not why don’t you look for the button instead of this picture

I did, for some reason it doesn’t like wildcards

I did attempt this previously but it just dawned on me that I may have not changed my condition. The result before was it continued to refresh. I will attempt this again once I am able to retrieve the button element.

Ok I tried to reverse my setup and instead of looking at the element on the page i looked for the element that had not come up yet. However when I do this there is a 35 second delay before the screen refreshes. Any idea what would cause this? When I look for the element that is there it refreshes every 4 seconds (which is what I want)

@djkmod83 Can you tell me what are the activities that you kept before refreshing ?

Element Exists (Element im waiting for) > delay of 4 seconds > refresh browser.

These 3 are in a while loop with a condition set to “boolean=False”

EDIT: Prior to the while loop I have the same Element Exists which then points to my While loop. Exactly like the picture toward the top but using element exists instead of text exists

@djkmod83

  • Elements Exists : The default time out for this activity is 30 sec meaning if it does not find any element it will wait for that element upto 30 sec

  • Delay is total 4 sec

That is why after 34-35 sec it is refreshing the browser

If you want to avoid this you can reduce the time out of element exists activity to 10000 milli seconds which is equals to 10 sec. If you want to reduce 2- 3sec you can do that as well

This worked, it is now refreshing as I expect. Cant believe I missed the info about the 30 second delay. I’m running now and if all works well I’ll mark as solved.

Thanks Ushu!

@djkmod83 :slight_smile:

Switch to modern and use Check App State instead. It has a property that you can use to make it only identify the element if it’s actually visible.

Also, why are you refreshing repeatedly? Why aren’t you just waiting for the element to appear?