Launch Message with Appium and Selenium (C#)

Hi There,
I’m a bit frustrated.
I’m only trying to open an app. actually open the Message app on Android.
The only thing I found a biyt helpful was the “Start Activitey” thread. BUT my driver does not contains the StartActivity class as shown: driver.StartActivity(“”, “.Foo”).

I need something to start with.
I can open the chrome and run tests on browser on my mobile. next step for me is using the mobile’s app.

1 Like

Define the appActivity and appPackage in DesiredCapabilities and also the URL.
It will open the message app on your android phone.
And to get appActivity and appPackage use command prompt.

Hi There,
How do I use the CMD in order to find appPackage and appActivity?

I have done the following under [Setup]

   DesiredCapabilities capabilities = new DesiredCapabilities();
           capabilities.SetCapability("device", "Android");
           capabilities.SetCapability("browserName", "chrome");
           capabilities.SetCapability("deviceName", "LG-G3");
           capabilities.SetCapability("platformName", "Android");
           capabilities.SetCapability("platformVersion", "5.0.1");
           capabilities.SetCapability("appPackage", "");
            capabilities.SetCapability("appActivity", "");
           _webdriver = new RemoteWebDriver(new Uri(""), capabilities, TimeSpan.FromSeconds(180));

To get the appActivity and appPackage use this command in adb shell:-

dumpsys window windows| grep -E 'mCurrentFocus|mFocusedApp' 

and press Enter.
It will give you this kind of result :

mCurrentFocus=Window{421bddc0 u0}
mFocusedApp=AppWindowToken{42171290 token=Token{420efc40 ActivityRecord{4210a3f0 u0}}}

In these lines appActivity and appPackage is already given you just have to copy and use as i did.

Here is the code snippet which works for me. :slightly_smiling:
I am opening the message app on my intex aqua r2 device using this script.


import org.openqa.selenium.remote.DesiredCapabilities;

public class MessageApp
static AndroidDriver driver;

public static void main(String[] args) throws MalformedURLException
	DesiredCapabilities capabilities = new DesiredCapabilities();
	capabilities.setCapability("deviceName", "AQUAR2");
	capabilities.setCapability("platformName", "Andriod");
	capabilities.setCapability("platformVersion", "4.2.2");
	capabilities.setCapability("appPackage", "");
	capabilities.setCapability("appActivity", "");
	driver = new AndroidDriver(new URL(""), capabilities);


If you’re still unable to understand then tell me your mail id then i will send you the links and videos for the same.

Thank you so much.
please send it to my mail.
[email protected]

problem is I’m using C# and I don’t have AndroidDriver.

These are my using and I’m probably missing something:

using System;
using OpenQA.Selenium;
using NUnit.Framework;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Remote;
using System.Collections.Generic;
using OpenQA.Selenium.Support.PageObjects;
using Appium.Interfaces.Generic;
using Appium.Interfaces.Generic.SearchContext;
using Appium.Interfaces;
using OpenQA.Selenium.Appium.Service;
using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Appium.Interfaces;
using OpenQA.Selenium.Appium;


I have a scenario where i do a registration on the app i am testing and it send a message to the registered mobile number. So my capabilities for App & Activities are set for the main app & not for the Messages app.
I am using the startActivity method of AndroidDriver to start the messages app. But when i provide as app & as activity as parameters, it fails to start the app because of permissions issues.

Can anyone help me out with this issue?


The workaround I found useful is using the notification bar and wait for the message to pop up there.

That’s what i am using in the interim, but i also need to test the scenario where multiple registration requests are sent across. In such a case, i will need to go through multiple SMS.
For one SMS, this workaround is working. But i need to find a way to launch the app.

I have one more question - is there a difference between how the app is launched by setting the driver capabilities and when using the startActivity method?

Same problem here. We should be able to start the actual messaging app as multiple messages can come in at once in my case.

Did anyone get to a solution to this problem?