Search code examples
c#visual-studioappiumappium-android

ERROR: The requested URL could not be retrieved Appium


I am trying to creat an Appium framework to test a real android device plugged into my computer.

TestBrowser.cs

[TestClass]
public class UnitTest1
{
    //create instance for appium driver
    AppiumDriver<AndroidElement> _driver;

    [TestMethod]
    public void TestBrowser()
    {
        DesiredCapabilities cap = new DesiredCapabilities();
        cap.SetCapability("deviceName", "Xiaomi MI 5");
        cap.SetCapability("platformVersion", "8.0.0");
        cap.SetCapability("platformName", "Android");
        cap.SetCapability("udid", "6d8d73n2");
        cap.SetCapability("fullReset", "True");
        cap.SetCapability(MobileCapabilityType.App, "Browser");

        _driver = new AndroidDriver<AndroidElement>(new Uri("http://0.0.0.0:4723/wd/hub"), cap);
        _driver.Navigate().GoToUrl("http://www.google.co.uk");
        _driver.FindElementByName("q").SendKeys("Appium");
        _driver.FindElementByName("q").SendKeys(Keys.Enter);

    }
}

When I run my test I am getting the following error:

ERROR: The requested URL could not be retrieved

It seems to error out at

_driver = new AndroidDriver<AndroidElement>(new Uri("http://0.0.0.0:4732/wd/hub"), cap);

This is new to me and I'm just trying to set up a basic test to build upon.


Solution

  • Stupid answer, but maybe You miss-typed your port, default is 4723 not 4732.

    _driver = new AndroidDriver<AndroidElement>(new Uri("http://0.0.0.0:4723/wd/hub"),
    

    Appium

    I know it is same, but try also:

    http://127.0.0.1:4723/wd/hub

    Hope this helps,