Read CSV, search for on web and write to CSV


thanks… I’ve resolved this issue by using Chrome (need to install UiPath extension for that) instead of IE explorer… but encountered an another 2 problems:

#1 - how to adjust IF-ELSE when the decision is based only on a scraped text (using a special variable if no entry found… but in case any entry found, such variable has no input as the screen element does not exist)

#2 - how to write copied url link to csv file, right next to the searched text (the same csv file, one column with text to be searched and the result to be written to next column)?

Many thanks

#1. Hopefully I understand, but sounds like you want to adjust the condition for when the searched item is found and the screenscraped text used won’t exist. In that case, you can do a few things; you can initialize the ScreenScrap variable to “” with an Assign right before you Get Text, and set the Get Text “ContinueOnError” property to True with a smaller TimeoutMS property. The other thing you can check is if the variable is Nothing or isNot Nothing. For example, If Activity: If(ScreenScrap isNot Nothing, ScreenScrap.Contains("has not returned"), False)

However, simply initializing the ScreenScrap variable to “” might work for you.

Alternatively, you can check something else that identifies that the searched item was found rather than check if it is NOT found. But I supposed it depends on the purpose of your project.

#2. Assuming you have added the column to your data for the url (before running or with the Add Column activity), you can write the url to that column with an Assign activity. row("columnname") = url (replace “columnname” with the column or index you want to use

I hope this helps.


#1 - using just “” and it works… so this is solved, thanks

#2 - there’s still error… no matter if using “columnname” or index…

could it be caused by my For each row cycle?


Hey, can you post your Assign activity? Maybe there is a mistake. Try using both row(“column”) and row.Item(“column”) … the .item() may have an impact.
Also verify that the variable you are assigning to the column has a value before.


sure… I’ve tried to try all that you mentioned, but it doesnt work


I noticed you have row("1")
Keep in mind that if you use the column index, it must be a number, like row(1)
But, if you have a column named “1” then that would work.

Thanks for that, my fault… anyway, it did not work… I’ve rebuilt the workflow and used excel instead of csv file and the assign activities are working now

but still struggling with IF-THEN condition - if the page returns any entry, I need to copy and paste the URL, in case no entries found, I need to write “no match” to excel file… I see no other option how make this scenario work, just use scraping functionaly and compare it to the predefined string (based on what text is returned - eg no results, has found no entires, etc

and regarding the url, it is not updated when searching for next text - providing still the same url, and dont know why

Would you pls check my workflow?
Test_v02.xaml (24.3 KB)

That seems like it could be a timing issue like it’s pulling the url from the previous search. I would check if it only shows the first url for all items you search for or is it always the previous url for the items. If it’s the previous url, then it’s probably a timing issue. If it’s always the first url, then I am not sure, but I would check that the url at the top of the page is correct to rule out any things like it isn’t searching for the items correctly.


Your If condition looks wrong. If ScreenScrap contains anything then it’s never “nothing”. Typically, you will check if it is nothing before checking if it contains something.
For example,

If(ScreenScrap Is Not Nothing, ScreenScrap.Trim <> "", False)

The Logic I used here says that if the variable has a value, then check if it has a string that is not empty (.Trim <> “”). If the string has something in it, then it will be True and pull the url. If ScreenScrap has no value ( is Nothing), then it will be False and say “negative branch works”

I hope this helps. Regards.

Thank you, ClaytonM

I’ve been started thinking that my pattern used for differentiating if any entry on the page found, or not, is not working as desired…

how would you approach the situation when you need to search for some keyword on a page, and if any result found then copy the url / and if no result found then just write to output file “no match”… I mean basing on what criteria / parameter would you build the condition?

Issue with the selectors starts to occur

Many thanks for your help

I think you were on the right track for most part.

I typically will use Attach Window instead of Attach Browser (I’m not sure if one is better, but Windows have different activities that you can use with it too).

Also, you will want any actions associated with the window to be inside that scope. Like, you wouldn’t want to do a For loop that reattaches each time inside the loop, rather, Attach first then use the For loop to perform the actions for that window. —of course, this won’t always be the case depending on the process.

You also want to avoid embedding Attach activities inside other Attach activities, because the way they work is that they contain the first line of the full selector, so all activities inside will use a partial selector omitting the first line.

For the logic, you would want to probably look for a keyword or element that identifies that your search is finished (you don’t want it seeing the previous search result) —maybe getting the url is a way to do that. Then, look for a keyword or element that identifies that it is found, and if it that keyword or element was not found you can either A) assume it is not found or B) check for the not found text as verification. And, this all depends on how the site is and how it is when a search result is found.

All in all, example pseudocode might look like this:

Read Source from Excel
Add Columns if necessary
Invoke a Login workflow that Opens Browser if it isn't already logged in
Attach to Window
For each row // can possibly use a flowchart as the Body inside the For each for better design
    Initialize test strings to ""
    Input row item and execute search
    (optional) Find element or text that identifies search is complete for row item
    Find element/text or Get Text of a found result // set TimeoutMS accordingly
    If condition //using element, element isNot Nothing... using text, text.Trim<>"" or Not text.Contains("keyword")
        Get Attribute for url
        Assign row("Result") = url
        Assign row("Result") = "Not Found"
    Write Range of table to update file

So hopefully that brings up some good ideas. It’s actually similar to what you are trying to do. Apologies for not being able to provide you a solved workflow.


Hey ClaytonM,

thanks for that… I used Element Exists instead of Find Element and did a few changes and my WF finally works… however, could you pls help me with Do-While cycle condition?
when used the conditions separatelly, it works… but when used as combination, the iteration cycle does not stop in 95 (in case the Element.Equals(FALSE))… desired state is to stop Do-While cycle either if cycle variable is equaled 95 or the element been found (Element.Equals(TRUE))

Many thanks


If you want to stop when cycle = 95 or Element is True, then you need to think about it like this.
Loop “While” (cycle > 95 AND Element is False)

You want it to loop while those things are true.
Additionally, a Boolean variable is already True or False so you don’t need a .Equals()

So, condition should be like this:

Do While
Condition: cycle > 95 And Not Element

once Element becomes True, “Not Element” becomes false so it ends the Do While, because with “And” both sides need to be True or it is false and ends.

I hope that makes sense.


Thanks man! it works…

and one more question, I’ve prepared 3 different WFs that write results to the same excel file… so my intention is to run them in series (meaning once one completed, start running next one, and so on…) could it be done in community version?

I’m not really sure what features are not in the community version.

But, if you just Invoke each of your Workflows in order, it should do what you explained.

Big thank you ClaytonM for your guidance… I’ve finally successfully manage built and tested my WFs and everything works as expected