"If else" Scenarios in Ui Vision? I'm new, how does it work? I can elaborate in the description

Lets say I create a bot, I run the bot.
It reaches a command like “click”. then it cant find the click. It when times out. and the bot stops.

I basicly want the bot to run a different series of commands after it cant find the thing its sposed to click. And then start the original series of commands from the start.

I hope this is descriptive enough. Let me know if I need to elaborate more.

Hi @Reilly_Fox

I had similar issue and what I’ve done was:

  1. I set timeout to less than the default time (10s)
  2. I ignored the timeout by using !errorignore (during the next step)
  3. Get button text to be evaluated if exists/was found

I hope this can help you and I also hope there could be more solutions because I am a beginner.

yeah sorry mate that doesnt explain anything relevant to my question

It is OK, I focused on the example and leaved the main question. Please forgive me.
Please take a look at:

Ok, thanks mate.

Got another question. I do have a bit of experience in coding here and there.

I feel abit confused because of ui visions ability to write bots with those premade lines that you add in and just edit the parameter. Instead of raw coding it.

Question: When implementing the if else statement, can this be done using the premade code line “elseif”? Or do I have to raw code it.

Because elseif conditions usually have a couple parameters needing set.

If this makes sense? Can provide pics if that description was confusing.

Hi again @Reilly_Fox
I used to use “elseif” uivision command.

Here an example: (click in Source view (Json) tab and paste the code below, so You can have something like what is in the image)

{
“Name”: “CheckIfElse”,
“CreationDate”: “2022-2-24”,
“Commands”: [
{
“Command”: “open”,
“Target”: “https://www.nytimes.com/”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “storeText”,
“Target”: “xpath=//*[@id=“masthead-bar-one”]/div[1]/div[1]/span”,
“Value”: “Todaysdate”,
“Description”: “”
},
{
“Command”: “if_v2”,
“Target”: “${Todaysdate}.includes(“Monday”)”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “alert(“Hello word! Today is Monday! \n Enjoy the day.”);”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “elseif”,
“Target”: “${Todaysdate}.includes(“Tuesday”)”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “alert(“Hello word! Today is Tuesday! \n Enjoy the day.”);”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “elseif”,
“Target”: “${Todaysdate}.includes(“Wednesday”)”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “alert(“Hello word! Today is Wednesday! \n Almost there.”);”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “elseif”,
“Target”: “${Todaysdate}.includes(“Thursday”)”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “alert(“Hello word! Today is Thursday! \n Iupi!”);”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “elseif”,
“Target”: “${Todaysdate}.includes(“Friday”)”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “alert(“Hello word! Today is Friday! \n Yes! We finaly here.”);”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”,
“Description”: “”
}
]
}

2 Likes

Have you looked into the Assert commands? To assert something exist or is visible? Then proceed with if_v2 based on that condition?

-Look for click button
-assertElement
-If_v2
-No _> #goto → Label
-Yes > continue

1 Like

Cool, I had a look at this code along with another couple other codes, thanks for the help, these examples were enough for me to understand how to use elseif commands :slight_smile:

Got my bot running the way I aimed to.

Thanks!