sikuli常見問題解決ppt課件_第1頁
sikuli常見問題解決ppt課件_第2頁
sikuli常見問題解決ppt課件_第3頁
sikuli常見問題解決ppt課件_第4頁
sikuli常見問題解決ppt課件_第5頁
已閱讀5頁,還剩14頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、Sikuli常見問題.常見問題 如何實現(xiàn)拖拽 如何操作下拉列表框 如何在腳本中運用中文 如何在log中顯示日期 如何將數(shù)字轉(zhuǎn)換成字符串 如何定義全局變量 Sikuli打不開怎樣辦. 如何更改匹配相識度 如何指定一個相對位置并點擊 如何設(shè)置鼠標挪動延遲 如何等待一個圖像的出現(xiàn) 如何獲得一個圖像的坐標.如何實現(xiàn)拖拽 ip = App(iPhone Simulator)ip.focus()ipw = ip.window()#ipw.highlight(2)bottom = 1318343141834.png # see commentmBottom = ipw.find(bottom)p = mBo

2、ttom.getTopLeft().above(10).right(15)hover(p)mouseDown(Button.LEFT)mouseMove(p.above(100)mouseUp(). while not ipw.exists (image-of-delete-button, 0): hover(p) mouseDown(Button.LEFT) mouseMove(p.above(100) # choose your stepping mouseUp() wait(1)click(ipw.getLastMatch() # should click delete button.

3、The only modification needed is to use below instead of downx1, y1, x2, y2 = (100, 100, 500, 600)start = Location(x1, y1)end = Location(x2, y2)stepX = 10 # adjust this as neededstepY = int(y2-y1)/(x2-x1)/stepX)run = startmouseMove(start); wait(0.5)mouseDown(Button.LEFT); wait(0.5)while run.getX() en

4、d.getX():run = run.right(stepX).below(stepY) # use below instead of downmouseMove(run)mouseMove(end)mouseUp().如何操作下拉列表框 switchApp(Safari)dd = find( )if dd: click(dd) # opens list sleep(0.5) # to avoid timing problems type(Key.DOWN) # here goes your navigation type(Key.ENTER)else: popup(Sorry, no dro

5、pdown found). you may find, that your dropdown entry is found even if the content is not exactly, what the image says.To test different situations, produce these situations and then use preview (click on the image in the IDE). Play around with the similarity slider. if you click ok, your image is tu

6、rned into a pattern object (pattern(image).similar(decimal between 0 and 1). You can use it directly (use instead of find():find(Pattern().similar(0.8) # the standard in the moment is 0.73this means: only find images with a similarity of at least 0.8This helped in the example to assure, that the dro

7、pdown was only clicked when showing: by relevancy.如何在腳本中運用漢字 請參考/dev/peps/pep-0263/ 處理方案: 在腳本文件的前面添加如下代碼: #!/user/bin/python # -*- coding: utf-8 -*- 必需放在腳本文件的第一行,試過.如何在log中顯示日期 處理方案: import datetime now = datetime.datetime.now() print now.strftime(%Y-%m-%d %H:%M:%S).如何將數(shù)字轉(zhuǎn)換成字符串 參考httpi

8、pseek.blog.51cto/1041109/788166 處理方案: str(數(shù)字).如何定義全局變量python有全變量,普通跟c里面是一樣的 bar = pythondef foo1(): bar = hello # 這里是部分變量 print(bar) # 打出hello,并且不會影響全局變量bar全局那個bar依然是python def foo2(): print(bar) # 打出python # 由于沒有聲明部分變量所以python會搜索全局的bar,這個bar是全局的 def foo3(): global bar # 通知python下面的bar是全局的bar = hell

9、o # 這里是全局變量 print(bar) # 打出hello,全局的bar曾經(jīng)改為hello不再是python了處理方案:在函數(shù)外面定義變量,然后在函數(shù)體內(nèi)用global聲明后在運用 .Sikuli打不開咋辦 參考 處理方案: On windows: Use Sikuli-IDE.bat to start sikuli Before delete the registry branch HKEY_CURRENT_USERSoftwareJavaSoftPrefsorgsikuliide.如何更改匹配相識度 參考/docx/globals.html#control

10、ling-sikuli-scripts-and-their-behavior 處理方案: Settings.MinSimilarity=小于1的數(shù)字 默許0.7.如何指定一個相對的位置,并點擊 參考 (Extending a Region) /docx/region.html#creating-a-region-setting-and-getting-attributes 處理方案: location =find(ii-1.png).right(50) hover(location) mouseDown(Button.LEFT) mouseUp(Button.LEFT) 或

11、者 Location=Pattern(“ii-1.png).targetOffset(100,0)參考/docx/pattern.html.如何設(shè)置鼠標挪動延遲 參考/docx/globals.html#controlling-sikuli-scripts-and-their-behavior 處理方案: Settings.MoveMouseDelay=數(shù)值 以s為單位,默以為0.5s.如何等待一個圖像的出現(xiàn)參考 img1 and img2 contain valid image filenamesweWait = 20 # max se

12、conds we want to waitwhile weWait 0: mImg1 = exists(img1,0) # see comment mImg2 = exists(img2,0) if mImg1 or mImg2: break # leave the loop if at least one found wait(1) weWait -= 1 # count down wait timeif not (mImg1 and mImg2): print images did not appear; exit(1)if mImg1: print image 1 appearedif

13、mImg2: print image 2 appeared- commentexists(img,0) does only one search and does not wait the standard 3 seconds, if image is not found. So for timing purposes you can calculate 0.5 seconds for every exists. So in your case it will last about 25 to 30 seconds, if n one of the images appears. So if 20 seconds is what you want, set weWait to an appropriate lower value

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論