question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find WinForm Form Dialog triggered from Word Add-In

See original GitHub issue

Hello,

I’m using WinAppDriver driven by Appium, trying to test a Word Add-In WinForms application, currently running into an issue trying to locate a dialog that appears.

The issue: We have a Microsoft Word COM Add-In that has a button on it that we use to open up a Form Dialog (calling xxx.ShowDialog(this). We have been using the both sessions and the wordElement callingxxxSession.FindByName, xxxSession.FindByAccessibilityId, xxxSession.FindByXpath, and xxxSession.FindByClass but still cannot find it.

I have opened up Inspect.exe and can hover over the dialog and it will bring show properties of the Dialog (confirming the Name and AutomationId and other values like Children controls and it’s Ancestors), it does not show where it this element exists in the TreeView view of Inspect.exe which is on the left hand side.

Has anyone had this issue?

//This is how we are setting up the Sessions:
WindowsDriver<WindowsElement> driverWinWord;
WindowsDriver<WindowsElement> driverDesktop;
AppiumOptions optionsWinWord;
AppiumOptions optionsDesktop;

optionsWinWord = new AppiumOptions();
optionsWinWord.AddAdditionalCapability("app", "winword");
optionsWinWord.AddAdditionalCapability("appArguments", fileName);
optionsWinWord.AddAdditionalCapability("ms:waitForAppLaunch", "6");

driverWinWord = new WindowsDriver<WindowsElement>(new Uri(url), optionsWinWord);

optionsDesktop = new AppiumOptions();
optionsDesktop.AddAdditionalCapability("app", "Root");

driverDesktop = new WindowsDriver<WindowsElement>(new Uri(url), optionsDesktop);

var wordElement = driverWinWord.FindElementByClassName("OpusApp");

We have tried calling FindXXX within retry logic and tried using Appiums WebDriverWait technique in case it needed more time to find the element.

I have also looked at the PageSource of both of our sessions and cannot see the dialog in the XML, so I am pretty confident it isn’t a timing issue, just that WAD cannot see it (even though Inspect.exe sees it, but just doesn’t know where it is with regards to the rest of the controls on the desktop).

Any advice?

Let me know if you need some more information.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:22

github_iconTop GitHub Comments

2reactions
DLightstonecommented, Dec 21, 2021

It do not particularly like using Inspect or Accessibility Insights. Sometime it is necessarily to get the actual XML time synchronous with the execution of the testing code. (ie what Inspect see and what your test code sees may be different)

You can dump the session XML using

  public static void SaveSourceToFile(WindowsDriver<WindowsElement> session,
                                      string strFile)

  {
     bool bExists;      
      var source = session.PageSource;

     Assert.AreNotEqual(source.Length, 0);

     bExists = Utilities.OSFileUtilities.DoesFileExist(strFile);
     if (bExists)
     {
        Utilities.OSFileUtilities.DeleteFile(strFile);
     }

     System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
     System.Xml.XmlTextWriter w = new System.Xml.XmlTextWriter(strFile,
                                                              System.Text.Encoding.BigEndianUnicode);
     xmlDoc.LoadXml(source);

     xmlDoc.WriteTo(w);
     w.Close();

  }
0reactions
hicks86commented, Feb 15, 2022

Ah yes @DLightstone we have since moved away from trying to find it by name and do so via FindByClass() as well. Thank you again I have learnt a fair bit during this invetigation proces aswell!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to show a windows form as a Dialog into VSTO word ...
I have a VSTO Project (WinWord addin) using c#. The Project has only one window, it must be showed when click on some...
Read more >
Use the Office dialog API in Office Add-ins
Sign-in dialog with Microsoft identity platform in Word. The dialog box always opens in the center of the screen. The user can move...
Read more >
Troubleshooting Add-ins are missing in Office
Open Com Add-ins. Path: Outlook/Word/PowerPoint > File > Options > Add-ins > Com Add-ins > GO · If the add-in is enabled as...
Read more >
Dreamweaver CC: The Missing Manual: Covers 2014 Release
... 107–109 text-align property (CSS), 291 Text Area form element, 665–666, ... 436 Trigger Event property (dialog widget), 629 troubleshooting CSS ...
Read more >
Special Edition Using Microsoft Office Word 2003
TROUBLE TROUBLESHOOTING WHAT TO DO IF WORD DOES NOT PROPERLY DOWNLOAD A ... close pop - up windows to prevent unwanted advertising from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found