1

I Create a Sample for lunch whatsapp with appium and C# .NET

static void Main(string[] args)
        {
            Console.WriteLine("Hi");
            AndroidDriver<AndroidElement> driver;
            DesiredCapabilities capabilites = new DesiredCapabilities();
            capabilites.SetCapability("deviceName", "Google Nexus 5 - 5.0.0 - API 21 - 1080x1920");
            capabilites.SetCapability("platformversion", "5.1.0");
            capabilites.SetCapability("platformname", "Android");
            capabilites.SetCapability("appPackage", "com.whatsapp");
            capabilites.SetCapability("appActivity", "com.whatsapp.Main");
            driver = new AndroidDriver<AndroidElement>(new Uri("http://127.0.0.1:4723/wd/hub"), capabilites);
            //com.whatsapp:id/registration_phone
            driver.FindElement(By.Id("com.whatsapp:id/registration_phone"));
            Thread.Sleep(10000);
            driver.Quit();
        }

I start appium, I can get my device and I can see my device in ui automator viewer .

http://i.cubeupload.com/vWTznm.png

But when I Run My Program I get this Error on this Line :

http://i.cubeupload.com/ENGYvU.png

and I set PATH and ANDROID_PATH : ANDROID_PATH : C:\Users\user\AppData\Local\Android\sdk PATH : %PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools all of them are correct and true

I guess this problem becuse i have more than one SDK 1. for android studio : C:\Users\user\AppData\Local\Android\sdk 2. for eclipse : C:\android\sdk\android

How I can chose a specific SDK location for my C# program .

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
MoHaMmAd
  • 95
  • 1
  • 3
  • 13

4 Answers4

2

you can also go into Eclipse --> Run Menu--> Run Confiuguration -->Environment Tab--> ANDROID_HOME --> Give Path to the SDK folder

Also as other suggested set your path variable. Taken from https://www.java.com/en/download/help/path.xml

Windows Windows 10 and Windows 8

In Search, search for and then select: System (Control Panel)
Click the Advanced system settings link.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH

environment variable does not exist, click New. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK. Reopen Command prompt window, and run your java code.

Windows 7

From the desktop, right click the Computer icon.
Choose Properties from the context menu.
Click the Advanced system settings link.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH

environment variable does not exist, click New. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK. Reopen Command prompt window, and run your java code.

Windows Vista

From the desktop, right click the My Computer icon.
Choose Properties from the context menu.
Click the Advanced tab (Advanced system settings link in Vista).
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH

environment variable does not exist, click New. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK. Reopen Command prompt window, and run your java code.

Windows XP

Select Start, select Control Panel. double click System, and select the Advanced tab.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit. If the PATH

environment variable does not exist, click New. In the Edit System Variable (or New System Variable) window, specify the value of the PATH environment variable. Click OK. Close all remaining windows by clicking OK. Reopen Command prompt window, and run your java code.

vishal
  • 640
  • 1
  • 5
  • 21
  • Cool tip for n00bs like me: if you change your path and/or environment variables in your system, you need to shut down and restart Intellij (or I guess any IDE) so that it reloads the new path. Yay it may sound obvious, but it would have saved me 5 minutes of WTF. – Zoette May 31 '17 at 04:02
1

SET Environment variables in Eclipse(IDE) locally with ANDROID_HOME and then try to run...it worked fine for me

Rohit
  • 3,314
  • 1
  • 13
  • 15
  • Welcome to Stackoverflow. Good answer. The user may not be familiar with how to set environment variables in Eclipse. A more complete answer would point to more information such as the second answer [here](http://stackoverflow.com/questions/7048216/environment-variables-in-eclipse) – MikeJRamsey56 Oct 26 '16 at 01:37
0

You can write BAT file for starting appium process. Inside of this batch file write SET ANDROID_HOME = blabla, it will override system variable.

Oleksandr Loushkin
  • 1,479
  • 12
  • 21
0

Check if system32 is present as path variable

Tabish Javed
  • 917
  • 9
  • 12