I need an advise from those who have more experience on automating a window desktop application.
I cannot automate a test in a certain form because I believe it cannot be done as Win Inspect cannot really see them. I will show you 2 images below what I meant by this.
this image is an example where I CAN automate the button Close using the following BDD, because Win Inspect can see it.
Scenario Outline: IP120929-00060 - I Check Button
Then Button "Close" Is Displayed
the image below is an example where I CANNOT automate the button Close using the same BDD & test definition (and method), because (I believe) Win Inspect cannot see it (however the properties of that element in question can be viewed)
Scenario Outline: IP99999_DEL_ME-00099 - I Check Button
Then Button "Close" Is Displayed
The Test Definition/Binding for that BDD is:
[Then(@"Button ""(.*)"" Is Displayed")]
public void ThenButtonIsDisplayed(string button)
{
var proc = $"Then Button {button} Is Displayed";
if (CombinedSteps.OutPutProc(proc, OutputLevel.Then))
{
if (Helpers.Button.**Displayed**(button, 3))
{
CombinedSteps.Success();
return;
}
}
CombinedSteps.Failure(proc);
}
public bool **Displayed**(string button, int timeout = 3, string windowName = "")
{
DebugOutput.Log($"Proc - Displayed {button} {timeout} '{windowName}' CurrentPage = {CurrentPage.ToString()}", OutputLevel.Procedure);
if (windowName != "")
{
DebugOutput.Log($"We need to narrow down by window");
return DisplayedByWindow(button, windowName, timeout);
}
var buttonId = CurrentPage.GetElement(button);
if (buttonId == null)
{
DebugOutput.Log($"Did not find a mention of that element in forms Element Factory, ");
return false;
}
var buttonLocator = buttonId.Locator;
DebugOutput.Log($"Find Element by {buttonLocator} ");
if (!JustOneButtonToPress(buttonLocator))
{
var currentPageName = CurrentPage.Name.ToLower();
currentPageName = currentPageName.Replace(" page", "");
var buttonInWindowElement = GetButtonElementInWindow(currentPageName, button);
if (buttonInWindowElement == null)
{
DebugOutput.Log($"Even in window I'm failing to find {button} {currentPageName}");
return false;
}
DebugOutput.Log($"Found in the window - it will click the first that fits under the window");
return buttonInWindowElement.Displayed;
}
DebugOutput.Log($"Got the locator of {buttonLocator}");
var buttonElement = SeleniumUtilities.GetElement(CurrentPage.GetElement(button).Locator, timeout);
if (buttonElement == null)
{
DebugOutput.Log($"Did not find a mention of that element in form");
return false;
}
DebugOutput.Log($"It exists {buttonElement}");
return buttonElement.Displayed;
}
the code will always return buttonElement as null for the Create Curves window form
Its frustrating thing trying to make this works, so my question to know better and have more experience, is this a limitation of the Desktop Application I am testing or is there another way around this? Is it better to ask the Developer to change something about it in the Application?
I have tried to map the 'Close' button in question using it's ID, Name and/or XPath - but all to no avail
any guidance on this would be much appreciated.
Cheers.

