Hello,
I am trying to do a catch formula with the click element but it is saying that the formula is invalid. Does click element not work with the catch formula?
Thank you!
Hello,
I am trying to do a catch formula with the click element but it is saying that the formula is invalid. Does click element not work with the catch formula?
Thank you!
Hi @echapman,
Yes, you are correct. {catch} cannot be used with {click} command.
Can you explain more what you are trying to do? So I can recommend if there is a better alternative.
You can use the click command with a maximum delay to wait for the element to appear.
{click: selector=selector; maxdelay=5s}
Or you can check with {site} command to make sure the element exists and then trigger the condition.
Here's an example of how we did that in the past in a related query: "Click element" for website toggle selection to always be in "On" position. - #6 by Gaurang_Tandon
And as Vinod mentioned, we would be glad to understand a bit more of what you are trying to do ![]()
Thank you! We are just having an error where a button is coded a specific way for one of our agents but coded differently for the rest of our agents. Instead of creating a whole new folder I was hoping to just code a catch error so that if that click element pulled the error for the 1st agent who's coding is different it would do the other click element coding.
Great. The example Gaurang shared will be the perfect way to handle your problem.
In addition to the {catch} trick shared above, you can also try to combine the selectors for two different {click} commands by using a comma. For example, if the first command is this:
{click: selector=s1}
And the second command is this:
{click: selector=s2}
Then the combined command would be:
{click: selector=s1, s2}
This will click on the first element on the page that matches either s1 or s2. This trick works when not going across iframes.
OH thank you I will try this!
it looks like that still doesn't work when the 1st selector is not an option on the page. it pulls an error instead.
so for example
This coding is used on our agents view of our system{click: frame=top; selector=#finesse_gadget_2 |> #completeTask}
This coding is used for the managers view of our system{click: frame=top; selector=#finesse_gadget_1 |> #completeTask}
But they are they same button visually. The agent button does not pull on my system and instead pulls an error since it's not there. Is there a way around that?
Thank you for confirming. The selectors have the |> symbol which indicates it is traversing iframes, which means my "trick" with the comma separator won't work as is. Please try out the original catch() suggestion and let us know if it works for you.
I'm not sure if that catch suggestion will work since the button pulls the same website information when I use the website command. So if I use the catch error on that button it will pull the same text for both codings. I did try that before as I thought of the same thing but it just said yes on both since it pulls the same text
Sorry, I didn't understand. Are both the buttons present on the page at the same time when you run the snippet? Or, are they not present on the page initially and then they become visible some time after you have run the snippet?
only one button will be available at a time for each person as it is the same button just coded differently for some reason. So for me to use the button on my page it is coded as the finesse gadget 1 and the finesse gadget 2 button does not pull at all., for another person to use the same button on their screen, it is finesse gadget 2.
Just to clarify, this is the snippet we're suggesting using the catch() function:
{if: catch({site: text; frame=top; selector=#finesse_gadget_2 |> #completeTask}, "NO") <> "NO"}
{click: frame=top; selector=#finesse_gadget_2 |> #completeTask}
{else}
{click: frame=top; selector=#finesse_gadget_1 |> #completeTask}
{endif}
If this does not work for you, please also try this custom command I made (assuming "only one button will be available at a time"):
{click: frame=top; selector=:is(#finesse_gadget_1, #finesse_gadget_2) |> #completeTask}
If this also doesn't work for you, please email me at gaurang@blaze.today so I can figure out the correct selector.
I think this actually worked beautifully! Thank you so so much!!
would I be able to build this code for other buttons as well with the same concept?
Glad to know it worked
It would depend on the specific HTML coding. These things can really vary on a case by case basis.