Note: @VikramVI I logged the issue as you can see above but I have closed it as duplicates existed. My problem still exists though and still would like some discussion.
I am able to locate and interact with an element using a custom method in one area of the application I am testing, but receive an error using an almost identical method in other parts of the application. Here is the method that works:
public IWebElement GetMenuElement(int index)
{
try
{
return driver.FindElement(By.XPath(
string.Format("//XCUIElementTypeApplication[1]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]" +
"/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]" +
"/XCUIElementTypeTable[1]/XCUIElementTypeCell[{0}]/XCUIElementTypeButton[1]", index)));
}
catch (Exception e)
{
Debug.WriteLine("Failed to GetMenuElement(" + index + ") in " + this.ToString());
throw e;
}
}
This selects a button from a small list of buttons within a hamburger menu and does so flawlessly. The following method attempts to do essentially the same thing (however, in a larger list of elements) and throws an error.
public IWebElement GetProductQuickCartElement(int index)
{
try
{
return driver.FindElement(By.XPath(
string.Format("//XCUIElementTypeApplication[1]/XCUIElementTypeWindow[1]/XCUIElementTypeOther[1]" +
"/XCUIElementTypeOther[1]/XCUIElementTypeOther[2]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]" +
"/XCUIElementTypeOther[1]/XCUIElementTypeTable[1]/XCUIElementTypeCell[{0}]/XCUIElementTypeButton[1]", index)));
}
catch (Exception e)
{
Debug.WriteLine("Failed to GetProductQuickCartElement(" + index + ") in " + this.ToString());
throw e;
}
}
Here is the error I am receiving:
XCTRunner[1068]: Enqueue Failure: UI Testing Failure - Failure fetching attributes for element <XCAccessibilityElement: 0x608000248a30> Device element: Error Domain=XCTestManagerErrorDomain Code=13 "Error copying attributes -25202" UserInfo={NSLocalizedDescription=Error copying attributes -25202} <unknown> 0 1
A full copy of the test logs can be seen here. Note that at line 496 it successfully uses the first method to locate an element.
I have tried using the workarounds mentioned here: https://github.com/facebook/WebDriverAgent/issues/372 and https://github.com/facebook/WebDriverAgent/pull/369; and while changing the XCUIElement+FBIsVisible.m
file to always return NO
eliminated the error, the driver was still unable to find the element and got stuck in a loop of POST requests.
I would appreciate any help anyone may be able to offer in this area because while I have ways of working around this, these methods speed up my tests significantly (which is why I created them) and I would like to be able to continue using them.