[sikuli]-python脚本的一个简单例子

def setUp(self):
  openApp("/Applications/jEdit.app")
  wait(, 20000)
  close = ()
#  if find(close):
#    click(close)

def tearDown(self):
  closeApp("jEdit.app")
  untilNotExist(, 20000)


def test_textarea_add_del_by_key(self):
  type("hello world") 
  assertExist() 
  type("a",KEY_CTRL) 
  type("\n") 
  assertNotExist()

def test_textarea_add_del_by_menu(self):
  type("hello world") 
  assertExist() 
  click() 
  click() 
  type("\n")
  assertNotExist()

def test_new_tab_by_key(self):
  type("n",KEY_CTRL) 
  assertExist(Pattern().similar(0.95)) 

def test_new_tab_by_menu(self):
  click()
  click()
  assertExist(Pattern().similar(0.95)) 

def test_new_tab_by_toolbar(self):
  click()
  assertExist(Pattern().similar(0.95)) 


def _verify_find(self):
  sleep(0.5)
  type("hello") 
  type("\n")
  click(Pattern().similar(0.90)) 
  assertExist(Pattern().similar(0.94)) 
  type("\b")
  assertExist()


def test_find_by_key(self):
  type("a long hello world\n") 
  type("f",KEY_CTRL) 
  self._verify_find()

def test_find_by_menu(self):
  type("a long hello world\n") 
  click()
  click()
  self._verify_find()

def test_find_by_toolbar(self):
  type("a long hello world\n") 
  click() 
  self._verify_find()


def test_textfield_on_toolbar(self):
  type("a long hello world\n") 
  assertExist() 
  type("f",KEY_CTRL) 
  assertExist(Pattern().similar(0.85))
  type("hello") 
  assertExist() 



def test_toolbar_print_dialog(self):
  click() 
  assertExist() 
  click() 


def test_menu_submenu(self):
  click() 
  click() 
  assertExist() 
  type("test") 
  click() 
  click() 
  click() 
  click() 
  click() 
  click()
  assertExist()

def test_scrollbar(self):
  for i in range(1,50):
    type("line %d\n" % i)
  tail = Pattern().similar(0.92)
  wait(tail, 10000)
  assertExist(tail)
  thumb_at_top = Pattern().similar(0.98)
  assertNotExist(thumb_at_top)
  dragDrop(, [0, -1000])
  assertExist(thumb_at_top)
  assertNotExist(tail)
  assertExist(Pattern().similar(0.92))
  dragDrop(Pattern().similar(0.90), [0, 1000])
  assertExist(tail)

def test_quit(self):
  type("test") 
  type("e",KEY_CTRL) 
  type("q",KEY_CTRL) 
  click() 
  assertExist(Pattern().similar(0.90)) 

 

你可能感兴趣的:(sikuli)