Get Text Keeps Using Previous Stored Variable, how to delete

I am doing a search on a web site for several items. Depending on the item the search may return 1 search result, 2 search results or many search results. I am using Get Text to copy the description of the first three search results and set the property to Continue on Error to True. On items that have 2 search results or less it is copying the description from the previous item above. I think its using the variable from the previous item instead of recognize that their is no description and leaving it blank. See sample below, for the second item “Red Delicious Apple” it only has 2 search results. It should leave cell D3 blank but instead it copies cell D2.

How can I make it leave cell D3 blank since their are only 2 results?
Can I make it type something when Get Text errors out?

@ricardoxh

I believe the selector is not dynamic

Inorder to make it dynamic, can you share the selectors of the two?

Thanks

First look for the selector
Second before get text just assign variable to nothing
For ex:-

GetTextVar=Nothing

1 Like

Hello,

I believe that you are using an incorrect activity to search for your elements.

Use Find Children Activity for all elements.

This activity is the correct one when it comes to reading one or more elements.

Then just loop the elements found and get the properties you want to use in your exel.

@Srini84, see the selector below. I cant make it too much dynamic because I only want the first three results. Each Get Text is for each different search result Firs(1) search result, Second(2) search result and Third(3) search result. Each selector is idx=‘1’, idx=‘2’, idx=‘3’.

See below another example, if the first search for “Green Apple” returns three descriptions and “Red Delicious Apple” returns only two description then when it gets to Description 3(F3) it copies the previous description above or uses the same variable from the last search.

But if it searches for “Red Delicious Apple” first from the start which only has 2 search results it does what I want it to do. It leaves Description 3(F2) blank and goes on to the next one. But it only works if the previous search was also blank.

I just want it to leave it blank or allow me to enter something like “Not Found”, how can I do that? May be I need to use Find Children Activity instead but the search items have different index, would it work? @Jorge_Cavalcante

If you are looking for three set results(there or not), and are assigning the text to variables, what are the variables called? If they are static variables, just initialize (set = “Not found”) the variables at the beginning of the for each activity so the values are cleared before you get the text.

Side note- are the results in a table? Perhaps try getting the table with data scraping and then use a loop to go through that table to get the key info you need.