Search code examples
c#iosselenium-webdriverappium

Getting error 'xargs' is not recognized as an internal or external command. While running appium test for iOS through Windows


When I run the Appium test for the below code

using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Interfaces;
using OpenQA.Selenium.Appium.MultiTouch;
using OpenQA.Selenium.Interactions;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Appium.iOS;
using NUnit.Framework;

namespace Hof.Mobile.Tests.UIAutomation
{

    [TestFixture()]
    public class TestAppium
    {
        public static IWebDriver driver = null;

        [TestFixtureSetUp]
        public void SetUp()
        {
            DesiredCapabilities capabilities = new DesiredCapabilities();

            capabilities.SetCapability("browserName", "Safari");
            capabilities.SetCapability("deviceName", "iOS");
            capabilities.SetCapability("platformName", "ios");
            capabilities.SetCapability("udid", "<<my udid >>");

             driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4723/wd/hub"), capabilities, TimeSpan.FromSeconds(180));
        }  

        public void OpenHomePage()
        {
            driver.Navigate().GoToUrl("http://url");
            Console.WriteLine("Page title is : " +driver.Title);
            //Assert.IsTrue(driver.Title.Equals("test")," Sorry , the website didnt open!!");
        }

        public void AssertTitle(string title)
        {

            Assert.IsTrue(driver.Title.Equals(title),"Title doesn't match!!");
        }



        [TearDown]
        public void End()
        {
            driver.Dispose();
        }
    }
}

On connecting my iPad device with Windows, I get this error:

System.InvalidOperationException : A new session could not be created. (Original error: Command failed: 'xargs' is not recognized as an internal or external command, operable program or batch file.) (33)

The same code is running perfectly for Android phones when I change the respective parameters, but it is not working for iOS.


Solution

  • You cannot automate iOS devices using Appium on Windows because you need XCode and XCode does not come for Windows but only for MAC.

    So basically, you need to run Appium on Mac if you want to automate iPad or iPhone.

    Limitations of Appium

    Appium is great tool but it has some limitations and it depends on automation engines. So here:

    • If you run Appium on Windows, you can automate only Android apps.

    • If you run Appium on Mac, you can automate both Android and iOS apps.

    A more detailed explanation can be found in this article of mine. There is a table which describes what I just told you in the central part of the article's body.