HI,
For the last week, i have been trying to get a simple test running from c# on a iOS device/simulator.
[TestClass]
public class UnitTest1
{
private AppiumDriver<AppiumWebElement> driver { get; set; }
[TestInitialize]
public void TestInitialize()
{
//Setting Capabilities
var capabilities = new DesiredCapabilities();
capabilities.SetCapability("platformName", "iOS");
capabilities.SetCapability("platformVersion", "8.1");
capabilities.SetCapability("platform", "Mac");
capabilities.SetCapability("deviceName", "iPhone 6");
//Connecting to Appium Server
driver = new IOSDriver<AppiumWebElement>(new Uri("http://xxx.xxx.xxx.xxx:4723/wd/hub"), capabilities);
}
[TestMethod]
public void TestMethod1()
{
System.Diagnostics.Debug.WriteLine("run");
var page = new PageModel();
var d = new AppiumPageObjectMemberDecorator(new TimeOutDuration(TimeSpan.FromSeconds(5)));
PageFactory.InitElements(driver, page, d);
page.Button.Click();
}
[TestCleanup]
public void TestCleanup()
{
driver?.Dispose();
}
}
With the following page model
public class PageModel
{
[FindsByIOSUIAutomation(Accessibility = "button2")]
[FindsBy(How = How.Id, Using = "button2")]
public IMobileElement<IOSElement> Button { get; set; }
}
but when this test runs instead of using the FindsBy or the FindsByIOSUIAutomation attributes to know what to search for, it does the following:
au.getElementsByAccessibilityId(‘<Button>
k__BackingField’) (from Appium log)
au.getElementsById(‘<Button>
k__BackingField’)
I have found out today (from trial and error) that if i change the property of the PageModel to a field
public class PageModel
{
[FindsByIOSUIAutomation(Accessibility = "button2")]
[FindsBy(How = How.Id, Using = "button2")]
public IMobileElement<IOSElement> Button;
}
everything works as expected…
au.getElementsByAccessibilityId(‘button2’)
Is this is a bug or by design?