In this video I will demonstrate the Get Clipboard building block
Using the clipboard can solve some types of automation challenges that is hard to solve with image and text recognition.
The example I’m gonna show in this video, is reading some text in a situation where OCR could have difficulties: black text in a field with a dark grey background. Some systems use the grey background to indicate that the field is not editable, so it is a problem I have seen in real life scenarios.
I have created a small demo web page, that includes a field and a label.
The field is non-editable and has a dark-grey background. On top of this I have added the value “1100550011”,which OCR could read as some l’s, o’ and s’es taken the dark background into consideration.
Instead of using OCR to get the value from the field, I’ll select the text, send a CTRL+C – which is a copy command in windows – and then use the Get Clipboard building block to get the value from the clipboard.
I’ll start by adding a Find Image building block and capturing the field label. I’m including just the leftmost pixel of the field.
I’m using this building block to get the position where the text starts, so I’ll adjust the image position by moving the cross hair into the field.
Now that we have a position where the field starts, we can add a Drag Mouse building block to select the text in the field.
I’ll wire up the position from the image to the start position of the Drag Mouse building block.
- Wire up the position from the start position
I’ll add an Offset Position building block to define the end position for the drag operation.
I’m capturing an offset value that will move the position from the start of the field to the end of the field.
And then I’ll connect the offset position to the end position of the Drag Mouse.
Running this should put the mouse pointer at the start of the field and then select the text in the field.
Let’s run the case.
Voila. Text selected.
The next thing is to use a Type Text building block to send a “CTRL-C” to copy the selected text to the clipboard.
I’m activating “Capture” to add the “CTRL-C” combination into the text field.
The last things to do is to get the clipboard back, and write this as a message to the activity log.
- Add Get Clipboard
- Add Log Message
- Wire up text with message
Now the text selected should be copied to the clipboard and then printed in the log.
Let’s run the case.
As we can see, the number was correctly returned from the clipboard.
In this video I demonstrated how to use the Get Clipboard building block to get values from an application into the workflow in Leaptest.
This ends this video.