I'm trying to get a text from a textfield with Get Text, but in some cases this field is optional and the robot crashes because it doesn't have anything in the field.
You have multiple options. It's hard to say which one fits best you so here is a pool of possible solutions:
when NOT using the Modern Design, you can easily use the Element exists
activity, self explaining
if you use the Modern Design and miss old activities like Element exists
, go to the filter dropdown and select Show Classic
, this way you are now also able to choose Element exists
you could also wrap such failing activities into a Try Catch
, then your process wont fail, but a Try Catch
should always be the last way out
when using the Modern Design, you can try Find Element
, if the returned object is empty you know that it was not found, make sure to set a proper Timeout here, otherwise you wait for 30 seconds
but on your case it could be better to use an Image exists
or Find Image Matches
as you said you are looking for text in a textfield, just inverse it and look for an empty textfield, and if you have no matches all is fine
But to be honest, I would go for the Element exists
. Give this a try, but be aware that in the future this activity might be replaced by something else and your process will need a little bit of rework.