I have just started learning Appium
testing using C#
. I made simple program using Visual Studio to just open app from Emulator.
When I run my code I am getting this error
Message: System.UriFormatException : Invalid URI: The Authority/Host could not be parsed. TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
This is my code
public class UnitTest1
{
private AndroidDriver<AndroidElement> driver;
private DesiredCapabilities capabilities;
[SetUp]
public void InItDriver()
{
capabilities = new DesiredCapabilities();
capabilities.SetCapability("PlatformName", "Android");
capabilities.SetCapability("deviceName", "Pixel_API_27:5554");
capabilities.SetCapability("appPackage", "com.sisapp.in.tulip");
capabilities.SetCapability("appActivity", "SplashActivity");
driver = new AndroidDriver<AndroidElement>(new Uri("https:127.0.01:4723/wd/hub"), capabilities);
}
[Test]
public void Test1()
{
Assert.IsNotNull(driver);
System.Threading.Thread.Sleep(2000);
}
[TearDown]
public void CloseTest()
{
driver.Quit();
}
}
Note: I did not installed anything like Appium Server in my machine.
These packages I have installed in my project. How can I solve this issue?
You must install and start Appium server in your pc. Then you will be able to run appium test.
Steps to install appium server
install appium server from cmd using:
npm install -g appium
To start appium server:
appium -a 127.0.0.1 -p 4723 --session-override
In your code code instead of Uri try to use URL. Also change your url as follow:
driver = new AndroidDriver(new URL("https://127.0.0.1:4723/wd/hub"), capabilities);
Edit: Above issue is going to solve by this workaround regardless what other issues you are getting :).