I am trying to use the Find Element activity to look for a specific element on a web page and then depending on if it exists or not do something. I am struggling with the If activity though as no matter what type of VB script I put into the Condition field, I can’t seem to get it to work properly. It seems like it will always choose the “Then” side as if the condition is true and never choose the “Else” side even when the element doesn’t exist on the site.
Is it because Find Element activity creates the variable as a UIElement and not Boolean? If it is, is there a way to change the variable type to Boolean?
did you try to use Element Exists activity? It returns boolean output.
I did try Element Exists, but the element I’m looking for doesn’t always exist on the page…if it doesn’t exist then the workflow errors out and does not continue onto the next step.
yes buddy you can use find element activity for this, but there are some reason to go for other activities like
- when a find activity is you will get the uielement as output variable and you can validate in if condition like this out_uielement.IsValid which would give you a boolean value but, the thing is i would suggest to go for element exists.
The reason is if find element does not find the element it would lead to exception and stop the workflow and you annot even go for validation whether element ocured or not
but if we use element exists it would give us a boolean as true or false means element is there or not rather wont stop the workflow even if theelement doesnot appear…so that you can validate that boolean output with the if condition and proceed further on
Thats the reason buddy why we need to use element exists instead of find element
Hope this would help you
If it does not always exist it should not be a problem to use Element Exist, as it produces only True or False. Then you can use Flow Decision point to decide which path to take, whether this element exists or not.
I appreciate the help…when I use the Element Exists activity and the element does not exists I get this error:
Source: Click ‘DIV’
Message: Cannot find the UI element corresponding to this selector:
Exception Type: UiPath.Core.SelectorNotFoundException
An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
UiPath.Core.SelectorNotFoundException: Cannot find the UI element corresponding to this selector: ----> System.Runtime.InteropServices.COMException: Cannot find the UI element corresponding to this selector:
- at UiPath.UiNodeClass.FindFirst(UiFindScope scope, String nodeID)*
- at UiPath.Core.UiElement.FindFirst(FindScope scope, Selector selector)*
- — End of inner ExceptionDetail stack trace —*
- at UiPath.Core.Activities.ScopeActivity.OnFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)*
- at System.Activities.Runtime.FaultCallbackWrapper.Invoke(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)*
- at System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)*
This is why I thought I had to use the Find Element activity since it has an option to continue on error, but the Element Exists activity does not.
@s3vn Selector might changing please check selector once. you can also try image exists activity which returns Boolean value as output.
To be more clear, I am trying to use UIPath to check our Service Desk ticketing queue for unassigned tickets. If it sees an unassigned ticket it will assign the ticket to itself so it can work on it. The selector seems to work every time that the “Unassigned” status appears on a ticket in the bot’s ticketing queue, but if no tickets are unassigned, I receive the error I posted above.
@s3vn Try once image exists activity, it might be useful for you.
Buddy if possible can i see the selector of element exists buddy, usually element exists wont throw any error on not able to find the element and if that throws error it must be because of selector only buddy…thats why
enable the first three attributes on the right top
like aaname, class, colName
add that to the selector and check whether it is valid or not
Then run buddy, hope this would help you
@Palaniyappan that worked!! Thank you so much!
Cheers buddy @s3vn
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.