Need to take screenshots again after phone reboot

Asked by Riddhi

I am using sikuli and androidscreencast tools for testing an android tablet. It is working fine but I have to take the screenshots again if once i run the script and then reboot the phone and then if i try to run the same script.

Somehow the script does not able to identify the same buttons or screen portions which it was earlier easily identifying. The disadvantage here is i cannot give the script to anyone else to use who does not how to insert the sreenshot. Can i get any help on it.

I am using sikuli IDE 10.2 version for windows.

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
RaiMan (raimund-hocke) said :
#1

Could you make this simple test:

# start your tablet environment, so it is visible on the screen
reg = selectRegion() # select the visible area of your pad

img = "captured image of some button"

if reg.exists(img, 0):
    print img, "found"
else:
    print img, "not found"

save this script and run it. I should report "found"

Then restart the IDE and your pad and try again.

report what happened.

Revision history for this message
Riddhi (riddhik84) said :
#2

I tried the above solution in my script by adding the first line as select region. It is working properly now.

However I have one more question. I am very much confused giving the text boxes as a screen-shots. For ex if the screen contains more than one textbox, how to add the image?

Because the script types at wrong box sometimes if there are more than on boxes on one screen.

Thanks,
Riddhi

Revision history for this message
Riddhi (riddhik84) said :
#3

I can also send screen-shots and sample script if you require. do this community have option to attach files?

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

ok, what I did above is a principal best practice with Sikuli:

when ever possible, restrict the search for a visual object to a region, where it should be found. This increases speed and quality of search.

solutions for "more than one text box, that might be found":
- restrict the region before searching (use reg.find() or setROI())
- capture more of the surrounding area, which makes it unique
- use the geometry of your layout to calculate a click point based on other unique matches (preview -> target offset is some support in the IDE for that)

Attachements here are not possible. You might store your script/screenshot somewhere else and post a link here. Might be sufficient if you want to show your script.

If you want more specific help and tips, feel free to send me a direct mail with zipped attachments to my mail at https://launchpad.net/~raimund-hocke.

Revision history for this message
Riddhi (riddhik84) said :
#5

ok.
Thanks a lot for your prompt reply and guide on the method.

I have one more question.

Can I use sikuli script for two phones simultaneously?

The test scenario here for ex is:

From phone 1 i place a call and from phone 2 i receive the call.
I want to do the above repeatedly in loop of say 10 times.

So is it possible? Can i place a call from one phone and receive that call from another phone at the same time using this script?

Thanks,
Riddhi

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

I Suppose you have to different windows one for each phone on your screen side by side.

If it is possible to do the call generation on one phone and then afterwards the incoming call handling on the other phone, then this is no problem.

the principle script layout:

p1 = region-of-emulator-window1
p2 = region-of-emulator-window2

for i in range(10): # repeat the following 10 times

   with p1: # all subsequent actions happen in window of phone1
      click(number-entry)
      paste("123456789") # phone number
      click(dial-button)
      # might be some more to do

   with p2: # all subsequent actions happen in window of phone2
      while not exists(sign-for-incoming-call):
          wait(1)
      # will wait forever if no call is coming in
      click(button-accept)
      # might be some more to do

   pass # now the 2 blocks are repeated

the pass statement is simply a "no-operation" in Python, that assures correct indentation/dedentation as a placeholder.

If you have to jump from one phone to the other in between it is a bit more complicated, but principally the same:
- p1 dials
- p2 waits and accepts
- p1 check acceptance realized
- p2 do something
- p1 and check
- p2 end call
- p1 check end call realized

The with: construct is a convenience, to block functions together, that act on the same region, so you do not have to qualify the functions with its region - e.g.
p1.click()
p2.click()

Principally it is possible to have the workflow on each phone in threads, that are running in parallel. This might give you more flexibility, but you would have to synchronize the use of mouse and keyboard, since only one thread may use it at one time.

Sounds interesting in general ;-)

Can you help with this problem?

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

To post a message you must log in.