MainMenu

Home Core Java Overview Maven Tutorials

Tuesday, 20 June 2017

Appium Automate Whatsapp in Andriod



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);
}
}

Code Description :- As usual you have to create desired capability object & then set capabilities for device version, name, platform etc.
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 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);
List list = driver.findElements(By.className("android.widget.RelativeLayout"));
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

17 comments:

  1. Guys, I have the feeling that somebody’s spying on my phone locations and social media using a phone tracker. A good friend of mine told me a lot about these apps, especially about https://www.hoverwatch.com. Unfortunately, people often cross the line of someone’s privacy and the worst thing is that they understand it, but still they continue doing what they feel they need to do.

    ReplyDelete

  2. After reading this web site I am very satisfied simply because this site is providing comprehensive knowledge for you to audience.
    Thank you to the perform as well as discuss anything incredibly important in my opinion. We loose time waiting for your next article writing in addition to I beg one to get back to pay a visit to our website in



    Selenium training in Chennai
    Selenium training in Bangalore
    Selenium training in Pune
    Selenium Online training

    ReplyDelete
  3. This application can be found in the 'My Accounts' section on T-Mobile's web page. Once you're downloaded the application it will run in the background without you having to do anything to it. It will kill any application that is not being used to free up the phone and keep a consistent speed.
    gerald winata gozali

    ReplyDelete
  4. Your articles really impressed for me,because of all information so nice.servicenow training in bangalore

    ReplyDelete
  5. These provided information was really so nice,thanks for giving that post and the more skills to develop after refer that post.opennebula training in bangalore

    ReplyDelete
  6. I gathered a lot of information through this article.Every example is easy to undestandable and explaining the logic easily.openstack training in bangalore

    ReplyDelete
  7. Very useful and information content has been shared out here, Thanks for sharing it.salesforce developer training in bangalore

    ReplyDelete
  8. This is really an awesome post, thanks for it. Keep adding more information to this.vmware training in bangalore

    ReplyDelete
  9. thank you so much for this nice information Article, Digitahanks for sharing your post with us.WEBMETHODS training in bangalore

    ReplyDelete
  10. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful. PEGA PPRC training in bangalore

    ReplyDelete
  11. I have read your blog its very attractive and impressive. I like it your blog.Informatica Training in Bangalore

    ReplyDelete
  12. Great post!I am actually getting ready to across this information,i am very happy to this commands.Also great blog here with all of the valuable information you have.Well done,its a great knowledgez. IMSBI Training in Bangalore

    ReplyDelete
  13. Post is very useful. Thank you this useful information.

    Upgrade your career Learn Oracle Training from industry experts gets complete hands on Training, Interview preparation, and Job Assistance at My Training Bangalore.

    ReplyDelete