Dynamically Trim Whitespace from scraped text from webpage (empty or not)

Hi guys,

I’m sure there’s a simple solution to this but can’t just seem to figure it out :frowning:

I want UiPath to scrape different elements from a webpage but 90% of these texts (if available) comes with a lot of trailing whitespace. Sometimes, the element that needs to be scraped is empty.

Is there a way to get uipath to dynamically trim these elements (empty or not) as I find that it throws an error if the text value is empty using the Trim function.

*** Also worth adding that these texts can change based on an extensive block of IF statements (up to 28). so I’m really just looking for the simplest/cleanest way to do this without adding more IF statements to handle each trim function to each of the 63 variables that does not come up empty - if that makes sense :smiley: ***

Thanks in advance! :slight_smile:

1 Like

can you share an input example please?

Hey @ceceliaa34

Initialize all the variables to String.Empty

After this you can use the Trim function as required.

Sorry, But it was not clear on the 63 variables part what you are trying to explain.

Hope this helps.

Thanks
#nK

@ceceliaa34 , For this we would require more info about what you are doing and What is the Optimal Solution you are Expecting?

Do you want to reduce the Number of If Blocks, the Number of Variables?

For Reducing the number of variables we could use a Dictionary type variable to store each value.

Again it depends on the scenario.

1 Like