In my process I have to search a place, once I search the place a separate screen appears to enter a name. IF that name already exist a message above the ‘Type Into’ textbox will appear saying “Name already exists”, if the name does not exist it will continue with the process.
I have a Get Text for “Name already exists” output value = strError
For my IF statement I’ve used:
strError.Contains(“Name already exists”)
strError.Contains(“already”)
strError.Equals(“Name already exists”)
When the process is either true or false it always completes the ‘Else’ set of processes and never the ‘Then’. Any ideas as to why?
Still not resolved. If I leave it as strError.ToLower.Contains(“name already exists”) it only processes Else and if I do Not strError.ToLower.Contains(“name already exists”) it only processes Then.
if you wish you use Regex then :
Assign StrOutput = System.Text.RegularExpressions.Regex.Match(StrError,“(?<=\n).*”).Value
if you wish you use String.Split then :
Strsplit = String.Join(Environment.NewLine,StrError.Split({Environment.NewLine},StringSplitOptions.RemoveEmptyEntries))
Sorry for the delayed response. I understood the issue. The problem is
your input string contains New line
your input string doesn’t contains a value all the time ie., you will get null value.
If you use trim function it will throw error when you get null value, if you dont use trim then comparison fails. My suggestion follow the below steps and try
After extracting the string first validate the Null condition
Ex: IF string <> “” use the compare condition ie., string.toLower.trim(“name already exists”)
I had to do strError.ToLower.TrimStart.TrimEnd.Equals(“name already exists”) to get the process to use “Then” but now it doesn’t seem to use “Else” when the condition is False.
When the error appears after selecting submit it stays on the screen but if there is no error the screen will go away. I assumed once the screen disappeared, the bot not being able to find the error message would automatically go to the “Else” process but it is also using “Then”. I even selected ContinueOnError for the Get Text
I even tested it out to make sure it would work just using this condition strError.ToLower.TrimStart.TrimEnd.Equals(“name already exists”):
strError.ToLower.TrimStart.TrimEnd.Equals(“name already exists”) shows as True and uses Then process
Not strError.ToLower.TrimStart.TrimEnd.Equals(“name already exists”) shows as False and uses Else process.
for the above conditions I made sure the Error message would appear when testing but now that the error message is not appearing it is not following the correct process based on the condition