Switch activity issue

Hi,
I am working on a small project where I need to execute following task;

  1. Check if a dialog box appears while trying to save a client. I used element exists activity for this.
  2. If element exists, I set value of a variable to 1 else 0.
  3. Then in switch activity expression, condition is set to “‘variable’ mod 2”
  4. Then I set two cases:
    4.1. if case value is 0, execute a task.
    4.2 if case value is 1, execute different set of task.

But the problem is that, it is going with case 0 every time. Can anyone explain me how to get it solved please. Thanks

I think element exists activity always giving false value so it is setting to 0 check the element exists activity selectors

You don’t need to use an extra variable. Simply set your switch activity argument to Boolean and then create two cases, one for True and one for False. It might help debugging your the issue.

1 Like

Hi there @suwalruchan365,
As noted by @loginerror, it seems you are slightly over-complicating the problem, I would simply Switch on the Boolean value.

Alternatively, you could avoid using a Switch altogether, as there are only two outcomes, you can simply use an If statement.

Thanks in advance and have a fantastic day,
Josh

1 Like

Hi @Mr_JDavey,
I used if activity before. But the bot always executed true statement block only. If element exists is true, it executes true block statement. But if element exists is false, then it does not execute the else block statement and just stops the process there.
I don’t know what’s wrong with it.

Hi @MahalingPatil,
I just realized that element exists activity is not getting any selector for the given UI element. It’s a pop up error message that occurs if a client is already registered. In case, it shows up, I want bot to cancel client registration.

You are getting any error?

Hi @suwalruchan365

Element exist wait for an UI element to appear for default 3 seconds. In your case if the popup doesn’t not appear for the default 3 seconds, it will return boolean value false and move ahead.

So, please make sure popup doesn’t take more than 3 seconds to appear. If it takes more than that, increase the timeout for element exist activity.

Thanks