RegExp not selecting the FullName item I expected
I have a script, where i am trying to find and click a menu item, on a device in the BitBar cloud. Application is written in Flutter if any of that makes any difference.
I have a RegExp part of my script that needs to target the Menu item 'Cornice' and touch it. Unfortunately on this menu as the Menu title name is also Cornice this confused my script so i switched to looking at the FullName attribute.
The top Menu title FullName attribute is:
Mobile.Device("Apple iPad 10.2\" 9th A2602 15.2").Process("uk.co.rpssoftware.designer.anglian").FindElementByAccessibilityId("Cornice")
The Menu item, i want to touch, FullName attribute is:
Mobile.Device("Apple iPad 10.2\" 9th A2602 15.2").Process("uk.co.rpssoftware.designer.anglian").FindElementByAccessibilityId("Cornice\n")
So the difference is that the one i want to touch has '\n' at the end
This is my adjusted code to get my issue across
function RegExpDebug()
{
var
menuName,
parentLevel,
searchPattern,
target;
propertySearch = "FullName";
menuName = "FindElementByAccessibilityId\(\"Cornice\\n\"\)";
searchPattern = "regexp:" + menuName + "*";
Log.Message("PropertySearch = " + propertySearch);
Log.Message("MenuName = " + menuName);
Log.Message("SearchPattern = " + searchPattern);
parentLevel = Aliases.Device.process;
Refresh_Appium_Content();
target = parentLevel.Find(propertySearch, searchPattern, 20000);
Log.Message("target = " + target.FullName);
if (target.exists)
{
target.Touch();
}
}
And this is the output from the logs. For some reason the target found and touched, is always the top menu option, rather than the menu item with FullName ending '\n'.
Can anyone offer any advice.