I can go back to 1.6.0 for the time being, but I don’t want to be forced to use an older version if I don’t have to. Any help would be appreciated.
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;
}
}
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.
Currently, my workaround is to not use my custom methods and instead get the entire list of elements in the various locations in a List<> using the “ClassName” attribute and selecting one by index. This is incredibly slow though as some of the lists are very large.
I ran into the same issue waiting for a object to appear when loading the Apple maps. I added a wait (sleep), and it seems to work. Possible racine issue?
try {Thread.sleep(4000);}catch (Exception e) {}
It seems to happen when my //xpath is really long.
When I got the error I was checking if a Dialog Message existed, and my work around was to use the message text on the dialog box instead of the long xpath. It’s a pain because the message text changes depending on inputs.
I’m using the WDA that comes with Appium 1.6.3 and locally applied the patch mentioned above. It is not committed as part of the WDA project yet so you’ll need to navigate to the pull request and get the code from there, or copy-paste it yourself from the GitHub thread.