谁能支持我这个案子?
我在具有类似配置的2台机器中安装相同的步骤。但是一台机器可以运行导入AutoItLibrary时,一台机器出现故障。
查看乘车日志 - 错误显示:
20190322 16:34:04.751 [WARN]: Importing test library "AutoItLibrary" failed
Traceback (most recent call last):
Initializing test library 'AutoItLibrary' with no arguments failed: com_error: (-2147221008, 'CoInitialize has not been called.', None, None)
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\robotide\lib\robot\running\testlibraries.py", line 167, in _get_instance
return libcode(*self.positional_args, **dict(self.named_args))
File "C:\Python27\lib\site-packages\AutoItLibrary\__init__.py", line 84, in __init__
self._AutoIt = win32com.client.Dispatch("AutoItX3.Control")
File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 108, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 85, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
File "C:\Python27\lib\site-packages\robotide\spec\librarymanager.py", line 87, in _fetch_keywords
return get_import_result(path, library_args)
File "C:\Python27\lib\site-packages\robotide\spec\libraryfetcher.py", line 24, in get_import_result
lib = robotapi.TestLibrary(path, args)
File "C:\Python27\lib\site-packages\robotide\lib\robot\running\testlibraries.py", line 54, in TestLibrary
lib.create_handlers()
File "C:\Python27\lib\site-packages\robotide\lib\robot\running\testlibraries.py", line 100, in create_handlers
self._create_handlers(self.get_instance())
File "C:\Python27\lib\site-packages\robotide\lib\robot\running\testlibraries.py", line 159, in get_instance
self._libinst = self._get_instance(self._libcode)
File "C:\Python27\lib\site-packages\robotide\lib\robot\running\testlibraries.py", line 169, in _get_instance
self._raise_creating_instance_failed()
File "C:\Python27\lib\site-packages\robotide\lib\robot\running\testlibraries.py", line 314, in _raise_creating_instance_failed
% (self.name, args_text, msg, details))
20190322 16:34:05.048 [INFO]: Found Robot Framework version 3.1.1 from C:\Python27\lib\site-packages\robot.
20190322 16:34:05.048 [INFO]: Started RIDE 1.7.3.1 using python version 2.7.14 with wx version 4.0.4 in win32.
我有同样的问题,并使用32位库测试然后工作。
@echo off
setlocal
set "jsfile=%temp%\autoit3x_comtest.js"
(
echo try {
echo oAutoIt = new ActiveXObject("AutoItX3.Control"^);
echo }
echo catch (e^) {
echo WScript.Echo("Catch: " + e^);
echo WScript.Quit (1^);
echo }
) > "%jsfile%"
set "system=System32"
if /i not "%PROCESSOR_ARCHITECTURE%" == "x86" (
set "system=SysWOW64"
)
echo Using: %system%
"%SYSTEMROOT%\%system%\cscript.exe" //nologo "%jsfile%"
if not errorlevel 1 (
echo No error detected.
goto :done
)
>nul 2>nul net session
if errorlevel 1 (
if not exist "AutoItX3.dll" if not exist "AutoItX3_x64.dll" goto :done
echo Require to run as admin to register any dlls.
goto :done
)
if exist "AutoItX3.dll" (
echo Register AutoItX3.dll
for %%A in ("/u" "") do (
"%SYSTEMROOT%\%system%\regsvr32.exe" /s %%~A "AutoItX3.dll"
)
)
if exist "AutoItX3_x64.dll" if exist "%SYSTEMROOT%\SysWOW64" (
echo Register AutoItX3_x64.dll
for %%A in ("/u" "") do (
"%SYSTEMROOT%\System32\regsvr32.exe" /s %%~A "AutoItX3_x64.dll"
)
)
:done
del "%jsfile%"
我怀疑AutoItX3.dll没有注册,这会输出一个COM错误。
上面的代码是批处理文件,因此您可以将其保存为例如autoitx_comtest.cmd
。它使用JScript来尝试加载AutoItX3.Control
对象。如果它失败并且脚本以管理员身份运行,它将注册dll(如果存在于目录中)。
AutoitLibrary通常只提供32位dll,即AutoItX3.dll
。如果您还需要64位,请将AutoItX3_x64.dll
添加到要注册的目录中。如果安装了AutoIt3,则可能已经安装了dll注册的dll。
如果安装了Python 64位,那么AutoItX3_x64.dll
可能需要使用AutoItLibrary,因为64位可执行文件不能使用32位dll,反之亦然。
注意:如果您知道如何使用regsvr32
注册dll,那么您可以使用它而不是批处理文件。
为了与使用旧版本3.3.6.0的AutoItX3.dll
的AutoItLibrary兼容。我可以推荐使用archived versions中的dll并下载autoit-v3.3.6.0-sfx.exe来获取dll。在最新的AutoItX版本中,删除了一些方法,例如RegRead
。此外,AutoItLibrary作者可能不支持3.3.6.0以外的任何版本。
如果您安装了最新的AutoIt安装程序,则可能需要取消注册这些dll并确保注册的3.3.6.0 dll兼容。我不确定您是否可以在同一系统上同时注册不同版本的dll。
最新版本的AutoItX dll可能运行良好,但文档中列出的AutoItLibrary关键字,如Reg Read
,Reg Write
和其他一些可能无法使用,因为这些方法已从最新版本中删除。
最新vs兼容性,您的选择。