If-Condition Check Element

Hey guys,

I would like to check if an UI-Element in SAP appears or not. Therefore I want to use an if-condition. Is it possible and if so, how would the command look like?

Regards and Thank you guys!

You could use Check App State activity. It has branches for cases when the target appears / does not appear.

@marco.roensch ,
Hii ,

Use an Element Exists Activity.Indicate the element.
The output of this activity will be a Boolean variable.
Then use If Activity ,pass the boolean variable in the if condition. Then you can proceed with then or else.

Regards,

Hi,

use below steps:

  1. Drag and drop the “Element Exists” activity onto your workflow.
  2. Indicate the SAP element you want to check by using the “Indicate on Screen” feature. Click on “Indicate on Screen” and select the SAP element you’re interested in.
  3. Set the “Output” property to a boolean variable (let’s call it elementExists).
  4. Now, you can use an “If” activity to check the value of elementExists. If it’s true, the element exists; if it’s false, the element doesn’t exist.

Hi @marco.roensch

  1. Drag an “Element Exists” activity into your workflow:
  • In UiPath Studio, go to the Activities panel on the left.
  • Search for “Element Exists” in the activities search bar.
  • Drag the “Element Exists” activity onto your workflow.
  1. Configure the activity:
  • Indicate the element you want to check by using the “Indicate on Screen” option. Click on it, and then select the element on the SAP application.
  • You can fine-tune the settings in the Properties panel, such as adjusting the timeout (maximum time to wait for the element) and specifying other options.
  1. Use the output:
  • The “Element Exists” activity outputs a Boolean variable. You can use this variable in an “If” activity to make decisions based on whether the element exists or not.

Refer the workflow for better understanding

Hope it helps!!

Hey guys,

Thank you, these answers are great! But I have the issue that the bot doesnt take the “else” path in case the ui element doesnt appear. It stops ans says “couldnt find the element”.
Do you have any advices?
@Parvathy @neha.upase @Jithesh_R @efelantti

Regards

Can you post a screenshot of your code? You shouldn’t get any exception from the Element Exists, as it should just set False to the output boolean if it doesn’t find the element.

A as tip, it would be a good time to start using the modern version of Elements Exists, which is the Check App State activity. Then you utilize Object Repository and more niceties that Classic activities don’t have :slight_smile: Then you wouldn’t also need the If, because the activity already contains branches for Element existing/Not existing scenarios.

Hi @marco.roensch

Just add the activities you want to run in right branch in case element doesn’t appear. Also, you can run in debug mode to check the path your bot is going

Cheers

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.