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.

Trying to retrieve content from a Microsoft Word document results in COM Error

See original GitHub issue

Hi,

As apart of our tests we access the text content of a Microsoft Word document.

We do so by calling

driver.FindElementsByTagName("Edit")
or
driver.FindElementsByName("Page 1")
etc.

This had worked but recently we tried to use it and both method return zero items and on the WinAppDriver server we have the following message:

POST /wd/hub/session/DE94DF8D-67BB-40D4-A74D-FADF2F7CDFBF/element/42.67100/elements HTTP/1.1
Accept: application/json, image/png
Content-Length: 35
Content-Type: application/json;charset=utf-8
Host: 127.0.0.1:4723
User-Agent: selenium/3.141.0 (.net windows)

{"using":"tag name","value":"Edit"}

### SearchMultipleElements exception: Error HRESULT E_FAIL has been returned from a call to a COM component.

Anybody have any ideas what this is todo with? The rest of our test app works fine, we can open up Microsoft Word and click on buttons etc.

Something else to mention when I did a PageSource dump, I WAS able to see these items in the XML and I CAN see these Items using the Inspector.exe tool

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
DLightstonecommented, Feb 15, 2022

I took a different approach to testing Word applications.

I completely ignore the Word ribbon commands, and use Word Automation for all testing operations The key is to realize that the Application under test, and the testing application do not run concurrently. That is the testing application starts an event and CAN wait for the Application under test to respond.

0reactions
DLightstonecommented, Feb 16, 2022

@hicks86

re - When you say Word Automation are you referring to Microsoft UI Automation ?

No

see https://stackoverflow.com/questions/37062670/read-content-from-microsoft-word-files-in-c-sharp or https://docs.microsoft.com/en-us/previous-versions/office/troubleshoot/office-developer/automate-word-create-file-using-visual-c or https://www.gemboxsoftware.com/document/articles/c-sharp-microsoft-office-interop-word-automation

re - “So just to make sure I understand correctly, in situation like this (where WinAppDriver isn’t providing what we want), another strategy is to make use of the UI Automation or some other system to get what we want.”

I do not know UI Automation. If it gives you access to the information you want, use it If some other mechanism gives you access to the information you want, use it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resolve the problem "Word experienced an error ...
Solution. First, right-click the Word file that you have problems with, and click "Property". Click "Unblock", when done, click"OK". (Note: a properly-working  ......
Read more >
[Solved] Word Experienced Errors when Trying to Open the ...
The simplest way to fix the “Word experienced errors when trying to open the file” is by repairing the MS Office suits on...
Read more >
We Found Unreadable Content Error in Word: How to Fix
Click the menu button above the Open and Cancel button and select the Recover Text from Any File option. Click Open. Word will...
Read more >
2023 Solved: the Found Unreadable Content Error in Word
The error “Word found unreadable content in……” usually occurs when the particular Word file is corrupt or has been infected by malware. However, ......
Read more >
How to Fix the “Word experienced an error trying to open ...
When you get the “Word experienced an error trying to open the file” error, unblock your Word file, and your issue may be...
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