Home » excel » ruby – Watir Excel call not working on virtual machine

ruby – Watir Excel call not working on virtual machine

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have a watir test that downloads some information from a web app to an Excel file, and I then open the file to confirm the contents. On my dev box everything works fine, but the scheduled automation runs (via Hudson) always fail attempting to open the Excel file. I have checked that the correct version of AutoITX3.dll is registered on both machines (Ruby 1.8, Watir 1.6.5). No other versions of AutoITx3 are registered on either machine. The error on the Hudson box is the one expected if the dll is NOT registered, but it is present in regedit in the same location as on my dev box. Both machines are WinXP.
Running the test manually on the Hudson box results in the same error — unknown OLE server: ‘Excel.Application’ HRESULT error code:0x800401f3 Invalid class string.

I searched for similar errors and saw one instance where running on a virtual machine had caused similar problems, but only if the VM window was closed. I don’t think this is a code error since it runs on the dev box. Any suggestions for debugging this?

TIA,
Sabrina

How to&Answers:

I find the use of Excel to be an antipattern in test automation. I know a lot of people like it, but if you’re using that for automation then there are simpler ways to go about it. Consider using CSV with FasterCSV for the automation tests and checking anything into version control which I’m assuming you’re using.

IMHO, you should only use Excel when a human is involved – i.e. you may a series of tests defined in CSV, but you edit them in Excel, save back and then diff against what’s in a source control system, storing it as CSV.

Excel is useless to diff, so it doesn’t store well in a source repo, there’s no reason to install it on a CI box when CSV will do and do better.

That’s my 2 cents anyhow. 🙂

Cheers,

Charley

Answer:

I would do another search for the issue and leave Watir out of it. I can find several issues for 0x800401f3 associated with FoxPro, Perl, and Oracle.

Answer:

Have a look at this article http://support.persits.com/show.asp?code=PS01032622

It names the possible causes for your error code.

bq. This error means that either the component has not been registered on the server or the ProgID passed to the Server.CreateObject method is misspelled. On Windows 2003 and XP, it may also mean a permission problem on a system registry key.

I think for you the last one is relevant:

bq. On Windows 2003 and XP, it may also mean a permission problem on a system registry key.

BTW, I googled for “:0x800401f3 Invalid class string.” and this was the first result.

Answer:

What are you trying to test?

  1. That user can open downloaded file with Excel? How do you verify that automatically? With screen shot?
  2. Or that some data is in the file? In that case I would verify contents of the file with something like roo.

Answer:

I finally figured it out. What I thought was a working Excel install on the remote machine was instead the free Excel reader, which does not have the API hooks WIN32OLE looks for in the registry. Installed the full Excel program and now everything works. I knew the Universe would be consistent!