2017-05-31 71 views
1

我在eclipse中創建了一個maven項目。我嘗試的一個示例代碼是在我的物理設備上正常工作。要將我的測試用例上傳到AW控制檯,需要這個* -tests.jar文件。但是,這個文件是不是在我的項目創造如何獲取用於配置AWS設備場的Appium的* -tests.jar?

項目結構如下

My project hierarcy is given below

源代碼,我想也附在下面

基類

package ********; 

import io.appium.java_client.android.AndroidDriver;  
import java.io.File; 
import java.net.MalformedURLException; 
import java.net.URL; 


import java.util.concurrent.TimeUnit; 

import org.openqa.selenium.By; 
import org.openqa.selenium.remote.CapabilityType; 
import org.openqa.selenium.remote.DesiredCapabilities; 
import org.openqa.selenium.support.ui.ExpectedConditions; 
import org.openqa.selenium.support.ui.WebDriverWait; 
import org.testng.annotations.AfterTest; 
import org.testng.annotations.BeforeTest; 

public class ************* { 
    protected AndroidDriver driver; 
     protected WebDriverWait wait; 

     //before Test Annotation makes a java function to run every time before a TestNG test case 
     @BeforeTest 
     protected void createAppiumDriver() throws MalformedURLException, InterruptedException { 

       DesiredCapabilities capabilities = new DesiredCapabilities(); 
       capabilities.setCapability("deviceName", "ABCDEF"); 
       capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android"); 
       capabilities.setCapability(CapabilityType.VERSION, "5.0"); 
       capabilities.setCapability("platformName", "Android"); 
       capabilities.setCapability("appPackage", "**********); 
       capabilities.setCapability("appActivity", "********"); 
       capabilities.setCapability("unicodekeyboard", true); 
       capabilities.setCapability("resetkeyboard", true); 
       driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);   
       driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS); 
       WebDriverWait wait = new WebDriverWait(driver, 300); 
       wait.until(ExpectedConditions.elementToBeClickable(By.className("android.widget.FrameLayout"))); 
     } 

     //After Test Annotation makes a java function to run every time after a TestNG test case 
     @AfterTest 
     public void afterTest(){ 

     //quit the driver 
     driver.quit(); 
     } 

    } 
給出

Screen類

 package **********; 

     import io.appium.java_client.MobileBy; 

     import org.openqa.selenium.By; 
     import org.openqa.selenium.support.ui.ExpectedConditions; 
     import org.testng.annotations.Test; 


     public class QuickPay extends ************ { 
      /*--------------------------------Enter pin Starts---------------------------------*/ 

      //Enter 4 digit pin to login 
      @Test 
      public void T4a_Login() {  
       driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-1')]")).sendKeys("1234"); 
      } 


     /*--------------------------------Enter pin Ends---------------------------------*/ 


     /*QuickPay Starts*/ 

     /*--------------------------------Quick pay to Federal Bank Account starts---------------------------------*/ 

      //Click on quick pay 
      @Test 
      public void T5a_QuickpayF() {  
       driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-30')]")).click();  
      } 

      //Enter account number , Amount and click quick pay 
      @Test 
      public void T5b_QuickpayF() {  
       driver.findElement(By.xpath("//android.widget.EditText[contains(@resource-id,'ext-element-229')]")).sendKeys("10015000301404"); 
       driver.findElement(By.xpath("//android.widget.EditText[contains(@resource-id,'ext-element-236')]")).sendKeys("50"); 
       driver.hideKeyboard(); 
       driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-34')]")).click(); 
      } 

      //Click on confirm button 
      @Test 
      public void T5c_QuickpayF() {  
       driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-38') and @index='0']")).click(); 
      } 

      //Enter pin for Quick paya-Federal bank 
      @Test 
      public void T5d_QuickpayF() {  
       driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-45') and @index='1']")).click();  
       driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-46') and @index='2']")).click(); 
       driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-47') and @index='3']")).click(); 
       driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-48') and @index='4']")).click(); 
      } 

      //Click on home for redirect to Home page 
      @Test 
      public void T5e_QuickpayF() { 
       System.out.println("testtt"); 
       driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-60')and @index='0']")).click(); 
       System.out.println("rt"); 
      } 



     /*--------------------------------Quick pay to Federal Bank Account Ends---------------------------------*/ 

     } 

**PoM.xml** 

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.aws.appium</groupId> 
    <artifactId>appium-android-test</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>jar</packaging> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-jar-plugin</artifactId> 
      <version>2.6</version> 
      <executions> 
       <execution> 
        <goals> 
         <goal>test-jar</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-jar-plugin</artifactId> 
      <version>2.6</version> 
      <executions> 
       <execution> 
        <goals> 
         <goal>test-jar</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 
    <properties> 
     <appium.version>3.3.0</appium.version> 
     <testng.version>6.9.10</testng.version> 
    </properties> 

    <dependencies> 

     <!-- Appium --> 
     <dependency> 
      <groupId>io.appium</groupId> 
      <artifactId>java-client</artifactId> 
      <version>${appium.version}</version> 
     </dependency> 

     <!-- testng --> 
     <dependency> 
      <groupId>org.testng</groupId> 
      <artifactId>testng</artifactId> 
      <version>${testng.version}</version> 
      <scope>test</scope> 
     </dependency> 

    </dependencies> 

</project> 

回答

1

如果鍵入:

mvn -h 

你會得到幫助頁面的Maven打印到控制檯。重點關注:

usage: mvn [options] [<goal(s)>] [<phase(s)>] 

試圖在此之後:

mvn -DskipTests package 
+1

呀它的工作我嘗試以下步驟.. Thankzzzz – APJ

+0

漂亮,開心一點。繼續 – Emna

+1

可以請你幫我解釋一下關於Appium腳本的疑問 1.我上面試過的腳本是用正確的方式嗎? 2.完成quickpay後,我想要做下一個場景,那麼如何重定向到下一個課程來做下一個場景? – APJ

相關問題