UIElement is no longer valid

I am having this problem too. Very, very frustrating.

I had this issue too… only way to solve this …you have use image activities or finding a unique selector

guys, any help with this error message.

UI Path relies very much on selectors, which helps identify objects at run time. This is why this property is very important. Some considerations to fix this.

  1. Check for usage of specific values. For example, if your property contains a name/value such as aaname=‘Contract 28322’, replace 28322 with an “*” to allow any contract. If not, unless your contract is 28322, it will not find it. Use UI Explorer to your help.

  2. Like someone said above, increase the Delay after/Delay Before settings. If you hover your mouse over delay after/Delay Before property you will be able to see the default value. 30000 = 30 secs. This is default in some cases and 300 is default in some. So you really need to make a determination of what the delay should be. In some cases, Timeout seconds needs to be set. Therefore, there isn’t one quick fix for all cases.

Some hints:
Use your judgment on how long a page refresh can happen.

Consider server delays.

Look for elements to appear in next page refresh, before you continue your process. Use ElementExists, Find Elements etc to fine tune. Use Try catch to capture timeout or any other exception.

A lot of times, when you use containers several properties are by defaulted from it. As you know, these container information are added by default when you recording using Desktop recording.

If you use container within container and your logic takes you in and out, selectors may change. For example, if you have a Attach Browser container and you use a Try catch within it, any exception that occurs will take you into one of the 'catch’s that handles it. If you have attached another Attach Browser container in there, unintentionally, partly because you attempted a fix by recording again and copy/pasted that sequence in here, then it will not find your object you referenced in the out container. I know it sounds confusing but you really have to pay attention to what can possibly go wrong. As much as possible, try to perform all activities within a sequence. If delays don’t work, use while loops to wait until certain element appears. For example, when you download files, the standard windows notification that pops up with “Open, Save, Save As” dialog marks the completion of download. Here timeouts will not work.

Hope this helps someone.

1 Like

I am having this problem trying to select an item from a drop down menu in excel. Basically, I am using UiExplorer to try to get the selector for an item in the drop down menu. I hit ‘indicate element’, use the 3s timer (F2) to open up the drop down, then click the item to select it. UiExplorer fails to get any selector and returns the “UiElement is no longer valid” error popup instead. The reason seems to be that when you click the menu item, UiExplorer pops back into the foreground and causes the excel drop down menu to collapse, so the element is not available anymore to query. For example, try to click “Design->Format->Autofit columns” from excel and you will get this problem.

Does anyone know the solution for this?

Thanks,

@pduffy have you tried the Select Item activity. This is usually the preferred method for dropdowns. It doesn’t always work, though, then I can see why you’d want to use a Click.

Hi ClaytonM. Yes I tried that, but it throws that the element is not supported.

If you are trying to use Excel features, I would recommend using the Alt-key combo in a TypeInto. For example, Autofit Columns would be “[k(ralt)]hoi” with a delaybetweenkeys at like 20
image

I did try to click it as an element and saw what you are talking about. I think it’s UiExplorer doing it, so you can still do it if you do it from within the Click activity rather than UiExplorer.

I still prefer the Alt-key TypeInto method though, which is super fast (if you set delayBefore and After to 0). Using click can have problems in my experience where for example the buttons change around or are unreliable.

Regards.

Thanks Clayton, yes this is how I worked around Excel issues in the past (Alt key). I was having the selector problem in both UiPath and UiExplorer, but just before you replied I got it to work from UiPath… maybe it’s an intermittent issue(?) There were two of us here hitting the same issue. It is now working on my machine. The other guy managed to get a valid selector now but the click activity doesn’t have any effect on it for him (works for me). Very strange behaviour… will try to get to the source of it here.

Thanks a million for your replies!! :slight_smile:

1 Like

Sometimes parent scope is losing the state (there are many reasons for that like asynchronous processing on the web page etc) and even working selectors fail intermittently so if you want to increase the chance of your selector to work, consider using full selectors for your activity, instead of using partial.

This has resolved my intermittently failing selectors issue.

Myself and a collegue had this issue on a get text. We had noticed that the error message was coming up before the application opened, so we tried putting a delay in and that had worked.

This thread still doesnt have a solution…Any luck from UI path team? @I am clueless about how to resolve this.
@loginerror

1 Like

Hi @Vidya_Srinivasan

Given it is an older topics, would you mind creating a new one with the information about your particular instance of the issue?

Please include as much information as possible about your environment, feel free to reference this topic on what that means:
Forum FAQ - Information to provide when reporting a bug

This piece of information greatly helped me.
In my Robot, i click on print button and a new page opens up with the pdf save and print options. This is where I was having the element issues. I put the ctrl + F5 hotkey before doing anything on the website, and it fixed the issue for me. My program ran smoothly with not even a single instance of this issue after that. This solution is very specific to my case and I don’t know if it would help others.
Hope this is helpful. Cheers.

Hi,
I am having the same problem while trying to click one button “The UiElement is no longer valid”
Clearing the cache from IE didn’t work.

Not sure if this is a general solution, but I found that it solved the problem when checking “simulate type” at least in one case.

If you have this problem with a click activity, create a “Do While” loop and put “Element Exists” within the do while, assigning the boolean output to a variable. Beneath that (but still in the do while loop) put an if statement - if element exists = true, click else do nothing.
The condition for the Do While loop should be element exists = false

Hello I know I am a bit late but I too encountered this problem.

I found a workaround this problem.
As others (@whyyouandi, @jcarr79 @vvaidya to mention some) have figuerd out it has something to do with the cache or the website. I don’t now what caused the error exacly.

But here is my workaround:

I just wrapped the Acitvities like Click, Type into etc. in some Attach Browser Activites. So as wrapping every Activity is probably overkill it worked for me.

I suspect because every time the Attach Browser Activity is used, the selectors are newly loaded.

If this worked for you too, let me know or vote the answer.

Could you please clarify more on this? like how it can be implemented in UiPath