環境建置
- Python
- Java Run Time
- Jython
- Easy Install & pip
- 環境變數 PATH 設定:[python], [python]\Scripts, [jython]\bin, [jre]\bin
- RobotFramework
- wxPython
- RIDE
- Robot Framework Library
- Sikuli
前置作業
- 啟動 Sikuli Remote Server
jython SikuliRemoteLibrary.py
執行測試
以下測項為 "登入 yahoo 信箱",與 Sikuli 相關的 Keyword:
- Object Exists
- Click Object
*** Settings ***
Documentation Integrating Selenium, Sikuli into Robot Framework
Test Setup
Test Teardown
Library Selenium2Library 15 # Selenium library
Library Remote http://localhost:${port} # Sikuli
Library OperatingSystem
Library Screenshot
*** Variables ***
${url} http://mail.yahoo.com # Yahoo mail URL
${browser} ff # Browser
${user_name} user_name # User name
${password} password # Password
${port} 8270 # Default port number for the remote server
${similarity} 0.8 # Used in Sikuli image comparison
${timeout} 20 # Time to wait for objects
*** Test Cases ***
login To Yahoo Mail Test Case
[Setup] Login To Yahoo Mail ${user_name} ${password}
# click next
${img_path} Get Image Path next.png
Click Object ${img_path} ${timeout} ${similarity}
# verify image 'try a new code'
Wait Until Page Contains enter the code ${timeout}
${img_path} Get Image Path next.png
Object Exists ${img_path} ${similarity} ${timeout}
[Teardown] Tear Test Down
*** Keywords ***
Login To Yahoo Mail
[Arguments] ${user} ${pass}
[Documentation] This keyword logs user into Yahoo mail
Open Browser ${url} ${browser}
Maximize Browser Window
Wait Until Page Contains Element username
Input Text username ${user}
Input Password passwd ${pass}
Click Button signin
Wait Until Page Contains Element login
Tear Test Down
Run Keyword If Test Failed Take Screenshot
Close All Browsers
Get Image Path
[Arguments] ${image_name}
${img_dir} Join Path ${CURDIR} imgs
${img_full_path} Join Path ${img_dir} ${image_name}
[Return] ${img_full_path}
沒有留言:
張貼留言