Selenium and Sikulix working with Web pages

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.