mardi 24 octobre 2017

How to Scroll a list to perform an iteration flow of app using appium?

i need to perform a large list of account closing.The list of 200 accounts which is available as a drop down.only 6 accounts will be available on screen at a time ,for others need to scroll down.How can i perform it using Appium scripting. The flow i tried and sample source code i tried is given below

package ******;

import java.util.List;
import io.appium.java_client.MobileBy;
import io.appium.java_client.android.AndroidElement;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.Test;


public class QuickPay extend ********{  



     @Test
     public void T1a_Landingpage() {

        public void  scroll(int i){
            do{
                size = driver.manage().window().getSize(); //Get the size of screen.
                System.out.println(size);                     
                int starty = (int) (size.height * 0.80);//Find starty point which is at bottom side of screen.
                int endy = (int) (size.height * 0.20);  //Find endy point which is at top side of screen.            
                int startx = size.width / 2; //Find horizontal point where you wants to swipe. It is in middle of screen width.     
                System.out.println("starty = " + starty + " ,endy = " + endy + " , startx = " + startx);     // int startx = size.width;
                driver.swipe(startx, starty, startx, endy, 3000);//Swipe from Bottom to Top.
                //Thread.sleep(2000);   
                }                                    

                 //AAD Closing starts
                     driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-1')]")).sendKeys("1111");
                     driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-tab-5')]")).click();                   

                     for(int i=1;i<10;i++){
                         driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-18')]")).click();                    
                         driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-input-5')]")).click();
                         do{
                             if (driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-simplelistitem-"+i+"')]")) != null){

                                 driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-simplelistitem-"+i+"')]")).click();
                                }
                             else{
                                    scroll(i);
                                }i++;
                             }
                         driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-simplelistitem-"+i+"')]")).click();                         
                         driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-input-6')]")).click();
                         driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-simplelistitem-3')]")).click();                     
                         driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-30')]")).click();                    
                         driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-31')]")).click();                    
                                       driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-37') and @index='1']")).click();  
                         driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-37') and @index='1']")).click();
                                     driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-37') and @index='1']")).click();
                                    driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-37') and @index='1']")).click();
                                   driver.findElement(By.xpath("//android.view.View[contains(@resource-id,'ext-button-49')]")).click();

             }

Aucun commentaire:

Enregistrer un commentaire