← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #660708]: Is there any work around ?

 

Question #660708 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/660708

Roman Podolyan posted a new comment:
Some time ago I was challenged to demo that I can run one and the same
code for two implementations of the app, Android and iOS (close business
logic but different dimensions and visualizations).  My solution to the
challenge (worked):

- I created a special class appdata , which holds all data related to particular app
-- inside the appdata class there are dictionary variables which are initialized with pairs "image_keyword":"image_disk_name"

Example A:  
______
class appdata_ipad:

    def __init__(self, wait_int = 1.7):

        self.main_reg_defw = 570
        self.main_reg_defh = 736

         self.keys_img = {"backspace": "ipad_keyboard_backspace.png", "1": "ipad_keyboard_1.png", "2": "ipad_keyboard_2.png"}
______

--  class doing the automation gets this or that concrete appdata class
as a parameter.

-- the code for the automation works not even with variables, but with
keys to some appdata dictionary.

Example B:
______
                self.try_click(self.appdata.keys_img['1'])
                self.try_click(self.appdata.keys_img['2'])
______


Python dictionaries can hold various objects, you can include images with offsets too (I did). The calling strings look a bit cumbersome, but with this approach I have all images in one place, and had one code running on completely different apps for different platforms.

Hope that helps.

You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.