How to log message what selector the bot actually saw?

Hi.

So I completed my automation locally, and proceeded to upload to Orchestrator. I then began testing and despite it working on my local machine, I cannot find a certain selector when I’m running the automation to a VM.

Is there a way for me to be able to console log into Orchestrator what the Bot is actually seeing for a selector?

Right now I just get the report of:

: Cannot find the UI element corresponding to this selector: <ctrl idx='2' name='System.Windows.Controls.TabItem Header: Content:' role='page tab' /><ctrl automationid='dataPresenter' /><ctrl name='Row 0' role='list item' /><ctrl idx='3' name='Item: &quot;test-job8-for-FCProject&quot;: 4@-&gt;CTMPROD-&gt;TEST-FC-AUTOMATION*' role='client' />

This does not help me a whole lot. I keep changing the selectors and re-testing locally, then try again for the VM and keep getting the can’t find selector error.

I would like instead for the BOT to tell me what selector it did see, so I can compare the two. Is this possible?

Thanks.

Kindly replace the dynamic part that is changing part with wildcards like *
with which we dont need to worry on each cycle and it will take any kind of selector
or if the issue still persists
and want to know the error simply we can place all the activities inside a try block of try catch activity and if any exception occurs it will go to catch block where we can have a log message activity mentioning like
"exception occured due to : “+Exception.ToString+” at :"+Exception.Source

Hope this would help you
kindly try this and let know for any queries
Cheers @rmckinnon

1 Like

That’s not what I want. I don’t want to receive the message of what selector it could not find. I want to receive this is what was found because I can’t check the selector in the VM.

Hi.

The problem is the bot doesn’t know what selector it was looking for, if the selector you used is wrong. It just doesn’t know, so it can’t tell you what it’s supposed to be.

But, what will help is if you know which activity failed. Then, you know exactly what step it failed on and you can identify which selector was wrong, so you can make the correction. To see the activity, you can use exception.Source in your Log Message with the message exception.Message.

Note: it is also good practice to include the retry number (from queue or localized), whether it was an App or Rule Exception, and which item it was currently processing when the error occured. That way there is no confusion on which item, which activity, which retry attempt, and what the error is.

Regards.

1 Like

Also Take a screenshot whenever an exception occurs, so you know what the screen looked like.

1 Like

@ClaytonM
More context for my situation. I know exactly what’s causing the error. I try to read the text of the column under status (So in this case “Ended Not Ok” ) image

I tried my best to make a more generic selector that can always read that Status,

.

I tested this method on my local machine. Works as expected.

I published my package to Orchestrator then ran the job on a VM, then quickly logged into the VM to watch the behavior. When I’m actually in the VM the automation also works as expected.

However, when I run the job on the VM unattended, the automation breaks on this Get OCR text activity. I’ve tried changing the selector multiple times (then test in local, then attended VM again), and no matter what this activity just keeps failing.

I was thinking maybe it’s a resolution issue when I’m running the bot unattended. So I made sure that the application I run is in full screen every time, but that still didn’t work…

How can I take a screenshot when the exception occurs also? :stuck_out_tongue:

Thanks.

That’s probably your best bet. You can use the Take Screenshot activity using a screenshot variable in the Output property. Then, use the Save Screenshot activity with that variable.

You can do that in the Catch of a Try/Catch. Also place a Retry activity after so the error is thrown again.

Selectors typically are not impacted by resolution. But, they can be impacted by Pop-ups or if the Window is a different size, which could happen in unattended.

Since you said it works in the VM environment while attended, it leads me to believe maybe the window looks differently for some reason.

1 Like

@ClaytonM Update. So I literally went into the the Robot settings in Orchestrator and changed the resolution to match my monitor.

I’ve performed all my unit tests on the unattended VM and everything works as expected now. But I’m probably going to get denied by the Orchestrator Admin as we have other automations running and likely share a robot. So now I’m very sure this is a resolution problem / window and not my selector.

So now the question is if I can modify my VM window without using this Robot setting, as I’m almost certain I won’t be allowed to actually do this.

Cheers.

Best practice is to use the 1920 w 1080 h, and also change depth to 32 for image-based automations. Additionally, you want LoginToConsole on No.

I would suggest working with your Orchestrator admin for those settings. Last I knew, the default resolution will run in 800 by 600, so even if you try to fix it in your code, some applications will struggle to work. You can use the Maximize Window activity, but the 800 by 600 is so small for some screens that you will need to use scrolling to find certain elements sometimes.