Issues with removing text from a webfield

Dear UIPath community,

I am experiencing an issue with removing text from a text box on a web page. I created a loop which takes a company code from an Excel row (company code.tostring), enters it into the website, looks for the data, scrapes the data and then is supposed to remove the company code and enter a new company code. In order to remove the company code I tried using type into: empty field with “” as type into field and sending a ctrl+a (with empty field box ticked also tried without this box ticked but still doesn’t work) and del hotkey. However, both don’t work as they don’t always remove the full company code - sometimes 00’s are left. Additionally, after entering the first company code it removes the company code fine but then on the second company code the removing does not work.

My current sequence:

Capture

Can anyone help me find a lean way of removing the company code in the text box?

1 Like

Use web-recording>> use Type_Into activity and indicate that text box and in type into activity tick mark the “Empty field” check box.

Let me know if this works out.

Best,
Shreyas

Hi Shreyas,

Thanks for your quick response, as stated above, I have tried that solution before, somehow it does not remove any of the text but just leads to accumulating the company codes see image below. So unfortunately that does not work.

Capture3

I have a doubt, does it work when you do it manually i.e., can you empty that field by using prompts ctrl+A and delete ?
Because it may be “read only” field or that text box might be coded in such a way that it might not be able to delete the content of the field.

Also, can u confirm me while u are using typeinto activity in Properties panel is the “simulate type” checked or un-checked?

Best,
Shreyas

if delete is not working, you can use one of below activities to accomplish the same-

  • type into activity
  • set text activity or
  • set web attribute activity

If none of the above works, then you can try injecting JS code to browser and set the value.

Hi Shreyas,

Yes the text in the field can be deleted. The type into activity in properties in the simulate type were checked, unchecking them did not resolve the issue.

Hi Madhavi,

Thaks for your reply, none of these options are working unfortunately. Could you please elaborate on injecting the JS code to browser and set the value, I am not sure if I understand what you mean by this. The thing is that my sequence has two if/then situations. For the first five company codes where a company code can be found, the data is scraped and added to an excel file and then the company code is removed and the next one is entered. However, at some point there are company codes which the website cant find, which in essence is not a problem, but this is where the deleting of the company codes becomes an issue. Eventhough this process is in principle the same for the first company codes, but somehow then it stops working, its also where the seeking of the company code and the data scraping stops working. See below images of my sequence, perhaps you guys know where the problem is? I’ve spent three days on this but cant figure it out.

26-Dec-18%202-08-02%20PM

This way worked for me

Hello @Merel, @shreyasshete, @Madhavi and @karthikeyuan_subrama,

I have a similar problem to @Merel as you can see here:

I try different solutions, unsuccessfully.
To summarize, I have a text field in a web application window (as you can see below) with a lot of paragraph and I need to remove one according to a condition. However, when I try to remove it, he doesn’t work.
I used get full text activity for the complete text (Variable1) and get text activity to my paragraph of interest (Variable2) and then I try different solution:
1- Assign Variable1 = Variable1.Remove(Variable2, “”) but the modification is do only in my variable1, not in the text field of the web page.
2- Assign Variable1 = Variable1.Replace(Variable2, “”), same result to the first one
3- Assign Variable3 = Variable1.Remove(Variable2, “”), same result to the first one
4- Send Hotkey with “ctrl + a” and then send hotkey with “back”, but he do on the web page, not in the text field of the web page, however it’s in a element scope activity (of text field)

So if you know an other issue to accomplish successfully this step of my process, that will be great.

Thanks.

Are you tried with type into once the required data is calculated into a variable?
if that doesn’t working, try injecting Javascript code to your web page and set the value.

Sure after to assign my variable I add a type into activity but I don’t know why, I can’t act in the text box.

Can you explain how can I inject Javascript code of the web page and set the value, please.

Here you go… https://www.uipath.com/kb-articles/inject-js-script
This has all references to Injecting Javascript.

In other words,
Did you check EmptyField in type into activity?

You can also try,

  1. Set text activity
  2. Use hot keys
    Copy variable value to clipboard, click on the field you want to replace the data, do Ctrl+A, Del, CTR + V

Hope this helps!

Sure I check Empty field in my type into. I tried too with send hotkey activity, I can to select with Ctrl + A after a click but I can’t to delete or cut to paste then my variable
I tested set text activity too, unsuccessfully. But, maybe the parameters was not perfect so I will check that before to use inject javascript.
I let you know.

Thanks for your help @Madhavi

When you say you can’t delete or cut to paste from variable, may i know what is the issue you are facing?

To set value to clipping region, use SetToClipboard activity and set your variable name in the Text property.
For deleting, you can send hot key of del or backspace.
Click ctrl+V

Refer

In fact, I can to select the text with “Ctrl + a” but when I add then a send hotkey with “Del”, “Back” or “Ctrl + x”, the bot doesn’t work as if I add only a send hotkey with “Ctrl + a”. So it’s very strange.
In addition, Send hotkey with “Ctrl + v” don’t work too.
And it’s the same with type into activity.

This is strange. Could you give this proof of concept project a go?

SendHotkeys.zip (11.6 KB)

This is how it should work by the principle.

The solution might work for you:

  1. Send Hotkey activity (without selectors) that does Ctrl + A
  2. Send Hotkey activity (without selectors) that does Back (Special Key needs to be checked in the properties of this activity)
  3. Use Type Into activity to type in your variable value with the proper selector for the field

If the text from the text box can be deleted manually without any robots, then this method simply needs to work at least for step 1 and 2.

If step 3 does not work, you can replace it with two more steps:
3. Use Set Clipboard activity to set your variable to clipboard
4. Send Hotkey activity (without selectors) that does Ctrl + V

In this case, it seems like it’s a matter of figuring out which approach is the best. Really difficult to do without access to the actual page :slight_smile:

1 Like

Thanks @loginerror, unfortunately I took that for both methos (as you can see below for the 1st method):

And “back” with send hotckey work on the page so instead off to delete the text, the bot go to the previous page. So I tried with “del” send hotkey, but no modification.
I precise that it’s possible to do all that manually, so I don’t understand why with the bot it’s nos possible in this case. Do you think that it could be due to a security or something like that?



In this case, I would try to build from a small example. Start by opening your page and doing actions within one Open Browser or Attach Browser activity. Let’s debug if the Element Scope is at fault here.

Here’s my suggestion. Have the website open with text selected and then run a bot that is only supposed to:

  1. Attach Browser activity to that open window
  2. Send Hotkey back as a special key with a selector pointed to the text box.

If this will work, we’ll go from there.

See updated example here:

SendHotkeys.zip (19.8 KB)

If you think you can save a static version of this page and send it as an attachment or in a private message, I might be able to quickly find the best approach :slight_smile:

The result is the same that before and I select the text field and here you are the selector and when I select with Uiexplorer. I have the impression of that there is not a lot of elements in the right part.

selector%20zone%20de%20texte
uiexplorer%20zone%20texte

Quick idea - what happens if you click on Source button?

Fingers crossed it changes the editing app into a simple, accessible text field.