How to get text extract text from Clipboard?

Asked by jeff radom

How to get text extract text from Clipboard? I've tried used Env but it say Deprecated. Please, any sample will have a lot. I need assert a result on a browser window using Java and Testng

Thanks

Jeff

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
Eugene S (shragovich) said :
#1

This should work:

text = Env.getClipboard()

Revision history for this message
jeff radom (jradom) said :
#2

Env method shows deprecated in my Java project. I use a Mac and my Java code in Eclipse looks like:
   s.doubleClick ("unit_200.png");
   s.type("c", Key.CMD);
   Thread.sleep(3000);
   String lineUnitPrice;
   lineUnitPrice = App.getClipboard();

A string on a Browser window is located but lineUnitPrice always empty or sometimes keep a value from previous runs. I've tried many other ways but still cannot get Clipboard values which I need for assertions

Thanks

Jeff

Revision history for this message
obiwan-92 (obiwan-92) said :
#3

Hello,
Try to replace s.type("c", Key.CMD)
by s.type("c", KeyModifier.CTRL)

Regards.

Revision history for this message
RaiMan (raimund-hocke) said :
#4

@obiwan
he is on Mac, so
s.type("c", Key.CMD)

is ok.

I guess a wait could help:

   s.doubleClick ("unit_200.png");
   s.wait(1);
   s.type("c", Key.CMD);
   s.wait(1);
   String lineUnitPrice;
   lineUnitPrice = App.getClipboard();

seems to be a typical situation where the GUI needs some time to get ready again.

Revision history for this message
jeff radom (jradom) said :
#5

Hi RaiMan

It looks like you are a real expert in Sikuli. I quite a few test cases while resolving several issues with your help. I used Selenium for several years in the past but see that we can use Sikuli for a set of Smoke tests. But we have several concerns if we can use at all after. Please, advise me what to do. So, these are our concerns:

1 We have several dozen web pages which we need to develop quick Smoke test suites
2 I have to cut few dozen images for clicking, navigation, verifications. For a whole thing I think I might have to have several hundreds images to use in my java code for all web pages. So, maintenance can be a potential costly thing
3 some but tins for example have slightly different style or size and in order to find images I had to use different images for pretty much the same thing
4 Browser window size (I use chrome for now ) is different sometimes we start tests and image locations failed to be found. Some of our pages use responsive design and it's not clear how and if this will work reliable on different monitors with different resolution , sizes, Mac, windows, Linux etc. from changing code We also plan to run eventually tests through CI using Jenkins on Mac but might soon switch to Linux

I've started to think that all of the above will not allow us to use Sikuli successfully and think if switching back to Selenium. Please, suggest what we can do. Generally speaking I'd like to know how to use Sikuli portability with different OSs, screen monitors

Thanks

Jeff

Sent from my iPad and will be short

> On Mar 6, 2014, at 11:56 PM, RaiMan <email address hidden> wrote:
>
> Your question #245098 on Sikuli changed:
> https://answers.launchpad.net/sikuli/+question/245098
>
> RaiMan proposed the following answer:
> @obiwan
> he is on Mac, so
> s.type("c", Key.CMD)
>
> is ok.
>
> I guess a wait could help:
>
> s.doubleClick ("unit_200.png");
> s.wait(1);
> s.type("c", Key.CMD);
> s.wait(1);
> String lineUnitPrice;
> lineUnitPrice = App.getClipboard();
>
> seems to be a typical situation where the GUI needs some time to get
> ready again.
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/sikuli/+question/245098/+confirm?answer_id=3
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/sikuli/+question/245098
>
> You received this question notification because you asked the question.

Revision history for this message
obiwan-92 (obiwan-92) said :
#6

Hello.

RaiMan is not an "expert" in Sikuli, he develops it. ;)

To answer to your questions:

Selenium is a tool who's dedicated to the web page, we don't have this restriction in Sikuli.

Whatever the tool you will choose, you can't expect to it to update itself, so obviously the cost of the maintenance have to be take in count.

In Sikuli, you have a tool, when you click on a image, to adjust the similarity. Did you try it ?

Sikuli analyse the images so it's dependent of the resolution, but normally it isn't dependent of the OS.

Hope it's help.

Reagrds.

Can you help with this problem?

Provide an answer of your own, or ask jeff radom for more information if necessary.

To post a message you must log in.