Sunday, 30 July 2017

How to scroll in appium



For Video Tutorial : Move on Youtube Channel


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


Hello Friends,
In this tutorial, we will discuss how to scroll down the application in appium.
As we know that ScrollTo("") does not work in new release of appium, so here is new method
The method is simple just use the Dimension class.
Get the size of screen & define the start & end of scroll.
Below is sample code, which will open the whatsapp & scroll it.

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
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.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.JavascriptExecutor;
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 io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
public class GetwhatsappContacts
{
AndroidDriver driver;
List list;
File src;
XSSFWorkbook wb;
XSSFSheet sheet;
XSSFRow row1;
String gn;
@BeforeTest
public void g() 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.whatsapp");
capabilities.setCapability("appActivity", "com.whatsapp.Main");
File file = new File("C:\\Users\\cchauhan\\Downloads\\New Appium\\src\\apk file\\base.apk");
capabilities.setCapability("apk", file.getAbsolutePath());
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
Thread.sleep(2000);
}
@Test
public void j() throws InterruptedException
{
Thread.sleep(4000);
Dimension dimensions = driver.manage().window().getSize();
Double screenHeightStart = dimensions.getHeight() * 0.99;
int scrollStart = screenHeightStart.intValue();
Double screenHeightEnd = dimensions.getHeight() * 0.2;
int scrollEnd = screenHeightEnd.intValue();
driver.swipe(0,scrollStart,0,scrollEnd,5000);
Thread.sleep(1000);
}
}


Thanks :)

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

Sunday, 2 July 2017

Computer Technical Tips

Basic Technical Tips



How To Make Pendrive Bootable for Windows 7

How to Make Pendrive bootable for window 7



For Video :-

Click Here

Step. 1:English :Open your command promt with “Run as administration” option
Hindi :(विंडो स्टार्ट बटन पर क्लिक करे और सर्च बॉक्स मे cmd लिखे और फिर राइट क्लिक करे “run as administration” ऑप्षन को सेलेक्ट करे).

Step. 2:English :Write command Diskpat and hit enter
Hindi :(अब कमॅंड लिखे DISKPART और एंटर बटन दबाए)

Step. 3:English :Write command list disk and hit enter
Hindi :(कमॅंड लिखे list disk और एंटर बटन दबाए)

Step. 4:English :Now your usb device will appear with status size etc.
Hindi :(यहा पर आपकी Pendrive का स्टेटस और साइज़ दिखय देगा)

Step. 5:English :Write command select Disk 1 and hit enter
Hindi :(कमॅंड लिखे select disk 1 और एंटर बटन दबाए)

Step. 5.5:English :Write command Clean and hit enter
Hindi :(कमॅंड लिखे Clean और एंटर बटन दबाए)

Step. 6:English :write command Create partition primary and hit enter
Hindi :(कमॅंड लिखे Create partition primary और एंटर बटन दबाए)

Step. 7:English :Write command Select partition 1 and hit enter
Hindi :कमॅंड लिखे Select partition 1 और एंटर बटन दबाए

Step. 8:English : Write command Active and hit enter
Hindi :कमॅंड लिखे Active 1 और एंटर बटन दबाए

Step. 9:English :Write command Format fs = ntfs quick and hit enter and wait to get it 100 percent
Hindi :कमॅंड लिखे Format fs = ntfs और एंटर बटन दबाए और इसके 100 % तक होने का इंतज़ार करे.



Step. 10:English :Write command Assign and hit enter
Hindi :(कमॅंड लिखे Assign और एंटर बटन दबाए)

Step. 11:English :Write command Exit and hit enter and you will exit from diskpart
Hindi :(कमॅंड लिखे Exit और एंटर बटन दबाए, अब आप diskpart से बाहर अपनी C या D ड्राइव मे आ जाएँगे)

Step. 12:English :Now go to your local system drive where you have window 7 setup folder.
command to switch between drive Drive_Name: and hit enter i.e. D:
commmond to comeout from folder cd.. and hit enter
command to select folder cd folder’s name first later and press TAB and select your folder.
for example: if i am in C drive in command prompt and i wanna to go in D drive to select my folder Test
then my command will be :
D: and enter // to move in D drive
D T and Tab //to select the folder Test
Hindi : (अब अपने कंप्यूटर की उस drive मे जाए जहा पर window 7 का setup है)
drive मे switch करने के लिए command prompt पर DriveName: लिखे और एंटर बटन दबाए जैसे की D:
फोल्डर से बाहर आने के लिए cd.. command को टाइप करके एंटर बटन दबाए
फोल्डर मे जाने के लिए cd foldername का पहला letter लिख कर TAB बटन दबाए और अपना Folder सेलेक्ट करे.

Step. 13:English :After selecting your window 7 setup folder write command CD BOOT i.e. D:\windows 7\boot>
Hindi :Window 7 setup फोल्डर मे पहुचने के बाद command CD boot टाइप करे इससे आप window 7 ke boot को सेलेक्ट कर लेंगे


Step. 14:English : Now write the command BOOTSECT.EXE/NT60 D: if your drive is D
Hindi :कमॅंड लिखे BOOTSECT.EXE/NT60 D: जहा पेर D आपकी pendrive का नाम है यदि ड्राइव का नाम D नही है तो जो नाम है वो लिखे



Step. 15:English :Now copy all the files(by selecting CTRL+A) of window 7 folder into your pendrive
Hindi :अब अपनी कंप्यूटर की विंडो 7 के सेटप फोल्डर को ओपने करे, window 7 के फोल्डर मे ctrl+a कमॅंड को प्रेस करके सारी फाइल सेलेक्ट करे और इसे pendrive मे पेस्ट कर दे.

Congratulation your pendrive is bootable now…….
Step 16:-Now plugin the pendrive to you computer and restart your computer

Step 17 :As soon window start, press F12 button or Fn+F12 button together.

Step 18 : Select the USB Boot option

Step 19 :Windows loading will get started & then select the Install Now option.

Step 20 :Under Device option select the driver & click the format link/button, selected drive will be formatted

Note : Before complete windows installation if your computer restart then remove your pendrive & insert it when window start will glimpse.

Thanks :)

Tags :

How to make pendrive bootable for windows 7

pendrive ko bootable kaise banae

pendrive ke window 7 kkaise upload kare

prndrive se system kaise format kare