How to Extract the text from a textfield using SIKULI in java application?

Asked by Deepak Kumar

HI Guys,

I am new to SIKULI, Could anyone please let me know how to extract values from text field using SIKULI script? If anyone can provide me the line of code that will be really appreciative?

Regards,
Deepak Kumar

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
David Scheele (david-scheele2) said :
#1

In what way "extract"?
If you can get the text highlighted (by clicking on if with sikuli or by tabbing into it it usually gets highlighted) you can just use the following:

type("c", KeyModifiers.CTRL)

to copy the highlighted text and

Env.getClipboard()

to do something with it.

For example:

type(Key.TAB + Key.TAB + Key.TAB) #selects the text field
paste(examplemailvar) #pastes a text into the field
type(Key.TAB + Key.TAB + Key.TAB) #selects the text field again, highlighting the text
type("c", KeyModifier.CTRL) #copies the highlighted text to clipboard
assert (Env.getClipboard() == examplemailvar), "E-Mail was not set" #compares the text to the one set before

Revision history for this message
Deepak Kumar (deepak-z-kumar) said :
#2

Thanks bro for quick turn around. Also could you please tell me why am i getting Env.getClipboard() in deprecated form?

Revision history for this message
David Scheele (david-scheele2) said :
#3

Sorry Deepak, but that I do not know. I'm not getting that error with the SikuliX 1.1.0 IDE. Maybe its because of the IDE you use.

Can you help with this problem?

Provide an answer of your own, or ask Deepak Kumar for more information if necessary.

To post a message you must log in.