MainMenu

Home 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

40 comments:

  1. Replies
    1. Great Article
      android based projects

      Java Training in Chennai

      Project Center in Chennai

      Java Training in Chennai

      projects for cse

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

      Delete
  2. 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

  3. 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
  4. 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
  5. Your articles really impressed for me,because of all information so nice.servicenow training in bangalore

    ReplyDelete
  6. 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
  7. 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
  8. Very useful and information content has been shared out here, Thanks for sharing it.salesforce developer training in bangalore

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

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

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

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

    ReplyDelete
  13. 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
  14. 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
  15. Easily, the article is actually the best topic on this registry related issue. I fit in with your conclusions and will eagerly look forward to your next updates. Roblox APK Chromebook Download

    ReplyDelete
  16. Wondering how to go about it? Here are some tips from the App development team that will help you choose the best mobile app development company for your business.

    tubemate.space

    ReplyDelete
  17. Many dog owners initially think that if they show their dog enough love and warmth, the dog will love them and obey them but this rarely React JS Training

    ReplyDelete
  18. There is so much technology that people do not know about when it comes to using their Blackberry cell phone.  this link

    ReplyDelete
  19. My brother recommended I would possibly like this blog. He was totally right. This publish truly made my day. You can not believe just how a lot time I had spent for this info! Thanks! Instapromote

    ReplyDelete
  20. I'm glad to see the great detail here!. cheap likes

    ReplyDelete
  21. In any case, there can be not kidding legitimate ramifications for organizations when their representatives or subsidiaries and advertisers utilize any of the mainstream internet based life discussions.https://www.instaentry.net/

    ReplyDelete
  22. Having your own cell phone is presently exceptionally basic for the individuals who have organizations, yet additionally in any event, for the individuals who are at home and at school.Iphone reparatur Kiel

    ReplyDelete
  23. I just put the link of your blog on my Facebook Wall. very nice blog indeed..”..: 안전놀이터추천

    ReplyDelete
  24. Amazing write-up! I’ll subscribe right now together with my feedreader software package!?- 안전놀이터

    ReplyDelete
  25. We are a group of volunteers and opening a new system in our community. Your web site provided us with valuable information to work on. You’ve done an impressive job and our entire community will be grateful to you. 먹튀검증


    ------------------------

    How do I know if a Wordpress theme supports a subscribe option? 청주출장안마

    ReplyDelete
  26. Youre so cool! I dont suppose Ive read anything like that just before. So nice to uncover somebody with some original thoughts on this subject. realy appreciate starting this up. this excellent website is a thing that is needed on-line, somebody with a bit of originality. valuable job for bringing new stuff to the net! 먹튀검증

    ReplyDelete
  27. Hi” your blog is full of comments and it is very active”  먹튀검증

    ReplyDelete
  28. Great Article… I love to read your QA outsourcing services articles because your writing style is too good, its is very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.

    ReplyDelete
  29. I like what you guys are up also. Such intelligent work and reporting! Keep up the superb works guys I have incorporated you guys to my blogroll. I think it’ll improve the value of my web site Kevin David Scam

    ReplyDelete
  30. I realize this is one of the most meaningful counsel for me. And i am vivacious studying your article. however have to commentary upon some standard matters, the internet site style is unmodified; the articles are invincible. thank you for the ton of actual and viable explicit. Whatsapp Marketing Software

    ReplyDelete
  31. Wonderful web journal. I appreciated perusing your articles. This is really an awesome read for me.
    I have bookmarked it and I am anticipating perusing new articles. Keep doing awesome!
    쏘걸


    ReplyDelete
  32. Hello
    I saw your post well. All posts are informative. I will come in frequently and subscribe to informative posts.
    May the world be healthy in an emergency with covid-19.
    That way, many people can see these great posts.
    I am also in the beginning, but I am running a small homepage.
    Please come and leave us your feedback
    My site address: 안전놀이터

    ReplyDelete
  33. Hello
    I saw your post well. All posts are informative. I will come in frequently and subscribe to informative posts.
    May the world be healthy in an emergency with covid-19.
    That way, many people can see these great posts.
    I am also in the beginning, but I am running a small homepage.
    Please come and leave us your feedback
    My site address: 안전놀이터

    ReplyDelete
  34. The interaction needs to be one to one, as the audience doesn't like to be part of a WhatsApp group. One-to-one communication makes them feel special and builds the trust of the customer in your brand. spiare Whatsapp a distanza

    ReplyDelete
  35. Nice Blog, When i was read this blog i learnt new things & it’s truly have well stuff related to developing technology, Thank you for sharing this blog. Need to learn software testing companies,please share.

    ReplyDelete
  36. It will be strongly suggested for the utilization of the WhatsApp marketing procedure, as this will cost you list exertion and cash contrasted with different methods for marketing. SMM Panel

    ReplyDelete