Sikuli's official address: http://www.sikuli.org
First download the Sikulix jar package: https://launchpad.net/sikuli/sikulix/1.1.0
Java-doc:http://nightly.sikuli.de/docs/index.html
Official website Usage Introduction: http://www.sikulix.com/quickstart.html
Demand:
1. Open Baidu Map
2. Switch cities to Zhengzhou
3. Using the Ranging tool
4. Measuring the distance between the Greentown Park-Zhengzhou Botanical Garden
Pre-order work:
1. Import jar Package: Sikulixsetup-1.1.0.jar
2. Run the jar package in CMD. Java-jar Sikulixsetup-1.1.0.jar, the startup will download Sikulixapi.jar if the appropriate option is selected. Otherwise it will be error: Libs to export not found on above classpath:/SIKULIXLIBS/MAC/LIBS64
3. The following prompt will appear after successful startup
4., i.e. the starting position to be used in the code, the end position
Next we write the code:
PackageCom.sikuli;ImportJava.io.File;ImportJava.util.concurrent.TimeUnit;Importorg.openqa.selenium.By;ImportOrg.openqa.selenium.WebDriver;ImportOrg.openqa.selenium.chrome.ChromeDriver;ImportOrg.openqa.selenium.safari.SafariDriver;Importorg.sikuli.script.FindFailed;ImportOrg.sikuli.script.Pattern;ImportOrg.sikuli.script.Screen;/** * @authorQiaojiafei *@versioncreated: April 5, 2016 6:43:55 * class Description*/ Public classTestsikuli { Public Static voidMain (string[] args) {//TODO auto-generated Method StubTestbaidumap (); } /*** @Title: Testbaidumap * @Description: TODO *@returnvoid *@throws */ Private Static voidTestbaidumap () {//TODO auto-generated Method StubWebdriver Dr =NewSafaridriver (); Dr.manage (). window (). Maximize (); Dr.manage (). Timeouts (). Implicitlywait (10, Timeunit.seconds); Dr.manage (). Timeouts (). Pageloadtimeout (10, Timeunit.seconds); Dr.get ("http://map.baidu.com/"); //Open City selection drop-down boxDr.findelement (By.id ("Tool-container")). Findelement (By.id ("Ui3_city_change")). Findelement (By.tagName ("a")). Click ();//. Findelement (By.tagname ("em")). Click (); //Select H ProvinceDr.findelement (By.id ("Selcityletterlistid")). Findelement (By.linktext ("H")) . Click (); //Select ZhengzhouDr.findelement (By.id ("Selcityplacelistid")). Findelement (By.linktext ("Zhengzhou")) . click ();; //Open the Tool drop-down boxDr.findelement (By.id ("Tool-container")). Findelement (By.xpath ("//i[text () = ' tool ']") . Click (); //Select RangeDr.findelement (By.id ("Boxul")). Findelement (By.xpath ("//i[text () = ' ranging ']") . Click (); Screen Screens=NewScreen (); String Frompng= "/users/qiaojiafei/documents/qiaojiafei/jarfile/sikuli/testphoto/from.png"; String Topng= "/users/qiaojiafei/documents/qiaojiafei/jarfile/sikuli/testphoto/to.png"; Pattern from=NewPattern (frompng); Pattern to=NewPattern (topng); Try { if(Screen.find (from)! =NULL) {Screen.click (from); } if(Screen.find (TO)! =NULL) {Screen.click (to); } screen.doubleclick (); } Catch(findfailed e) {//TODO auto-generated Catch blockE.printstacktrace (); } } }
Selenium and Sikulix working with Web pages