Hello Friends,
In this session, we will discuss that how to automate Andriod "Whatsapp" application.
For Video :- Click Here
For Video Tutorial : Move on Youtube Channel
Note : Select the playlist as per your need & move with number sequence
Here is the Sample code :
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Platform;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
public class Whatsapp
{
public static AndroidDriver driver;
public static void main(String[] args) throws MalformedURLException
{
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\\Appiumpure\\apk\\com.whatsapp-1.apk");
capabilities.setCapability("apk", file.getAbsolutePath());
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
}
}
After that you must set the capability for app package and app activity.
How to find app package & app activity
Now create the object of File & give the path of apk file.
set the capability for file
. Now run the code & verify that you application is launched.
Another example to send bulk message on whatsapp.
Automate Whatsapp using appium
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;
public class Whatsapp
{
public static AndroidDriver
public static void main(String[] args) throws MalformedURLException
{
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\\Appiumpure\\apk\\com.whatsapp-1.apk");
capabilities.setCapability("apk", file.getAbsolutePath());
driver = new AndroidDriver
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
List
for(int i = 0; i<=list.size(); i++)
{
list.get(i).click();
driver.findElement(By.className("android.widget.EditText")).sendKeys("to find pleasure be a good person");
driver.findElementByName("Send").click();
driver.findElementByName("Navigate up").click();
}
}
}
Tags :
How to automate whatsapp | Code to automate andriod whatsapp |
Appium tutorial to automate whatsapp | Appium tutorial to automate installed app |
No comments:
Post a Comment