I’m brand new to Appium Studio, so if I’m missing something simple, please go easy on me.
Background:
I connected a real Android phone to my Mac and recorded a test for it using Appium Studio.
I took the code that Appium Studio generated and used it to create a test in Visual Studio.
Here’s a snippet of what it looks like:
…
protected AndroidDriver driver = null;
DesiredCapabilities dc = new DesiredCapabilities();
[SetUp()]
public void SetupTest()
{
dc.SetCapability("reportDirectory", reportDirectory);
dc.SetCapability("reportFormat", reportFormat);
dc.SetCapability("testName", testName);
dc.SetCapability(MobileCapabilityType.Udid, "118x87x9");
driver = new AndroidDriver<AndroidElement>(new Uri("http://localhost:4723/wd/hub"), dc);
}
[Test()]
public void TestUntitled()
{
driver.Swipe(564, 29, 523, 1594, 909);
driver.FindElement(By.XPath("xpath=//*[@id='settings_button']")).Click();
}
…
The driver.Swipe line works correctly and pulls down the top menu on my phone.
The settings_button then gets surrounded by a red box.
Then I receive the following error and the test fails:
System.InvalidCastException : Specified cast is not valid.
I have tried removing the ‘xpath=’ as I don’t normally use that in my VS tests.
I have tried finding the button via Id as well.
Can someone shed some light on what I’m doing wrong?
Mark