1: Download maven;
1.0: Set the environment variables for maven:
1.1: Set up Maven local repository;
In the downloaded Maven folder to find the Apache-maven-3.3.9/conf folder under the settings.xml file, modify localrepository for the computer as a random folder as a local repository;
2, start using MAVEN to create a new Java project; (The first time you need to download a plugin, it takes a long time)
In Terminal input:
mvn archetype:generate-dgroupid=-dartifactid=-darchetypeartifactid=maventest -dinteractivemode=false
View Code
And then it's going to look like a file was generated.
2.1: Run first, make sure that it can run normally;
In the terminal input
CD to your newly-created Java Project MVN CLEANMVN test
3: The next step is to get started on the topic:
3.1 Edit the Pom.xml file first, add Appium Run library dependencies and build test cases;
<dependencies> <dependency> <groupId>org.testng</groupId> <ar Tifactid>testng</artifactid> <version>6.8</version> <scope>test</scope > </dependency> <dependency> <GROUPID>ORG.SELENIUMHQ.SELENIUM</GROUPID&G T <artifactId>selenium-java</artifactId> <version>2.42.2</version> </dependency > <dependency> <groupId>com.google.code.gson</groupId> <artifactid> ;gson</artifactid> <version>2.1</version> </dependency> <dependency> <groupId>io.appium</groupId> <artifactId>java-client</artifactId> <version>1.7.0</version> </dependency> </dependencies>
View Code
<build> <plugins> <plugin> <groupid>org.apache.maven.plugins</groupid > <artifactId>maven-surefire-plugin</artifactId> <version>2.12.4</version> <configuration> <includes> <include>maventest/*. java</include > </includes> </configuration> </plugin> </plugins> </ Build>
View Code
Specific
3.2:
Start writing test scripts: Create a new Java file under the Src/test/java/maventest folder;
Packagemaventest;Importio.appium.java_client. Appiumdriver;ImportOrg.junit.After;ImportOrg.openqa.selenium.remote.CapabilityType;Importorg.openqa.selenium.remote.DesiredCapabilities;ImportJava.io.File;Importjava.io.IOException;ImportJava.net.URL;Importjava.util.Arrays;ImportJava.util.HashMap;Importjava.util.List;ImportOrg.testng.Assert;ImportOrg.testng.annotations.DataProvider;Importorg.testng.annotations.Test;ImportOrg.junit.AfterClass;ImportOrg.junit.BeforeClass;Importorg.junit.runners.Parameterized;Importorg.testng.annotations.Parameters; Public classNewtest {PrivateAppiumdriver driver; @org. Testng.annotations.BeforeClass Public voidSetUp ()throwsException {//setting Automation-related parametersDesiredcapabilities capabilities =Newdesiredcapabilities (); Capabilities.setcapability (Capabilitytype.browser_name,"Safari"); Capabilities.setcapability ("PlatformName", "ios"); Capabilities.setcapability ("DeviceName", "IPhone 6"); Capabilities.setcapability ("Platformversion", "9.3"); Capabilities.setcapability ("App", "Safari"); //InitializeDriver =NewAppiumdriver (NewURL ("Http://127.0.0.1:4723/wd/hub"), capabilities); Thread.Sleep (10000); } @Test Public voidTestcase_webapp () {Driver.get ("Http://baidu.com"); } @After Public voidTearDown ()throwsException {Driver.closeapp (); }}View Code
This code is a simple example of starting the iphone simulator, opening the Safari browser, opening the Baidu link
3.3 In the terminal input MVN test, you can see the iphone simulator opened, opened Baidu page;
?? : Generally if there is a problem, is generally dependent on the version of the library, only need to change a dependent version of the library to be good;
Appium + maven +jenkins Basic Primer II new MAVEN Java project