MainMenu

Home Core Java Overview Maven Tutorials

Wednesday, 5 July 2017

Data Driven Framework in Appium for android



For Video Tutorial : Move on Youtube Channel


Note : Select the playlist as per your need & move with number sequence


Data Driven Framework in Appium:

For Video : CLICK HERE For Part1




Hello Friends,
In this tutorial we will discuss how to create Data Driven Framework in appium for Android.

It is very similar as we created in Selenium for any web application.

Click Here

for selenium data driven framework.

Suppose we have below scenarios/Task to automate on Android to add multiple contacts in android :-

Our Scenarios will be as below :
1).Open Android dialer
2).Click on contacts
3).Click on create contacts
4).Enter Name
5).Enter Mobile Number
6).Click save button
7).Click on home Button


We will write the code in eclipse to achieve the objective.

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import org.apache.poi.ss.usermodel.DataFormatter;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidKeyCode;
import io.appium.java_client.remote.MobileCapabilityType;
public class Newtest2
{
static AndroidDriver driver;
XSSFWorkbook wb;
static XSSFSheet sheet;
FileInputStream fis;
@BeforeTest
public void g() throws IOException
{
File src = new File("D:\\study material\\Selenium Final complete\\Appium software\\contactsdata\\contact_data.xlsx");
fis = new FileInputStream(src);
wb = new XSSFWorkbook(fis);
sheet = wb.getSheetAt(0);
}
@Test
public void main() throws MalformedURLException, InterruptedException
{
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "LYF");
capabilities.setCapability(MobileCapabilityType.VERSION, "6.0.1");
capabilities.setCapability(MobileCapabilityType.PLATFORM, Platform.ANDROID);
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Andriod");
capabilities.setCapability("appPackage", "com.android.dialer");
capabilities.setCapability("appActivity", "com.android.dialer.DialtactsActivity");
File file = new File("C:\\Users\\cchauhan\\Downloads\\New Appium\\src\\apk file\\.apk");
capabilities.setCapability("apk", file.getAbsolutePath());
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
for(int i =121 ; i<131; i++)
{
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.findElement(By.id("Contacts")).click();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.findElement(By.id("Create new contact")).click();
List list = driver.findElementsByClassName("android.widget.EditText");
String data = sheet.getRow(i).getCell(0).getStringCellValue();
list.get(0).sendKeys(data);
//WebElement Name = driver.findElement(By.name("Name"));
//Name.sendKeys("csc");
driver.pressKeyCode(AndroidKeyCode.ENTER);
Thread.sleep(3000);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
DataFormatter formatter = new DataFormatter();
String val = formatter.formatCellValue(sheet.getRow(i).getCell(1));
list.get(1).sendKeys(val);
//WebElement number = driver.findElement(By.name("Phone"));
//number.sendKeys("9718632008");
driver.findElement(By.id("Save")).click();
Thread.sleep(5000);
driver.pressKeyCode(AndroidKeyCode.HOME);
Thread.sleep(3000);
driver.manage().timeouts().implicitlyWait(7, TimeUnit.SECONDS);
List list2 = driver.findElements(By.className("android.widget.TextView"));
list2.get(5).click();
}
}
}



Tags :-

Data driven framework in appium,

How to create data driven framework in appium

Code for data driven framework in appium,

Example of data driven framework in appium

5 comments:

  1. The development of artificial intelligence (AI) has propelled more programming architects, information scientists, and different experts to investigate the plausibility of a vocation in machine learning. Notwithstanding, a few newcomers will in general spotlight a lot on hypothesis and insufficient on commonsense application. Machine Learning Final Year Projects In case you will succeed, you have to begin building machine learning projects in the near future.

    Projects assist you with improving your applied ML skills rapidly while allowing you to investigate an intriguing point. Furthermore, you can include projects into your portfolio, making it simpler to get a vocation, discover cool profession openings, and Final Year Project Centers in Chennai even arrange a more significant compensation.


    Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account.

    ReplyDelete