I have an automation where I must input an Identifier from an excel sheet into a web page and then return the values needed from the webpage back to the original Excel. The automation works perfect however, if the identifier doesn’t produce a result in the webpage then I need a way to return empty fields and not just break the automation. I’m not sure what or how to write the necessary condition based on the result of the search.
To handle cases where the identifier from the Excel sheet does not produce a result in the web page, you can use a combination of conditional statements and error handling in your UiPath automation. Here’s a step-by-step approach:
-
Read the Identifier from Excel:
- Use the ‘Read Range’ or ‘Read Cell’ activity to extract the identifier from the Excel sheet.
-
Input Identifier in Web Page:
- Use a ‘Type Into’ or similar activity to input the identifier into the web page.
-
Search and Check for Results:
- Implement activities to perform the search on the web page.
- After the search, you need to check for results. You can do this by using the ‘Element Exists’ activity or another method to determine if the expected result is present on the web page.
-
Conditional Statement for Results:
- Use an ‘If’ activity to check the condition. If results are found, proceed to extract and return the values as planned.
- If no results are found, you can add an ‘Else’ branch to handle the case where the search didn’t produce any results.
-
Handling No Results:
- Within the ‘Else’ branch, you can set variables or perform actions to indicate that no results were found, or to return empty fields back to the Excel sheet.
-
Writing Results to Excel:
- After processing, use the ‘Write Range’ or ‘Write Cell’ activity to write the results (whether they are actual data or empty fields) back to the Excel sheet.
Here’s a simplified example of the workflow:
- Read Identifier from Excel
- Input Identifier in Web Page
- Perform Search on Web Page
- If (Results Found)
- Extract Data from Web Page
- Write Data to Excel
- Else
- Set Empty Fields or Appropriate Indicators
- Write Empty Fields or Indicators to Excel
By using this approach, you can handle cases where the web page search doesn’t yield results and still continue with the automation, ensuring that empty fields or indicators are returned to the Excel sheet instead of breaking the process.
Read Excel Data
For Each Row in Excel Data
Input Identifier into Web Page
Try
Extract Data from Web Page
Catch
Handle Exception (e.g., set variables to empty or log error)
End Try
Check Extracted Data
Write Data to Excel
End For Each
If String.IsNullOrEmpty(extractedText)
Set extractedText to Empty or Placeholder Value
End If
How would I write a condition based on the result of the search?
This is the expected result…
This is the unsuccessful result…
The issue is, there is no “Show All Vehicle Details” Button. Any ideas for checking whether the button exists before moving forwards?
Hi
Use Check App state activity in modern design and select valid selector for the
Error Text : 0
Thank you
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.