I am trying to load FlaUI
libraries using pythonnet
. The code is able to load the FlaUI.UIA3.dll
. However, importing FlaUI.UIA3
namespace fails.
Here is my code,
import clr
import sys
dll_path = 'C:\\Users\\amit_tendulkar\\.nuget\\packages\\flaui.core\\3.2.0\\lib\\net45'
dll_path2 = 'C:\\Users\\amit_tendulkar\\.nuget\\packages\\flaui.uia3\\3.2.0\\lib\\net45'
sys.path.append(dll_path)
clr.AddReference('FlaUI.Core')
sys.path.append(dll_path2)
clr.AddReference('FlaUI.UIA3')
from FlaUI.Core import Application
from FlaUI.Core.Conditions import ConditionFactory
from FlaUI.Core.Tools import Retry
from FlaUI.UIA3 import UIA3Automation
from FlaUI.UIA3 import UIA3PropertyLibrary
The error I am getting is below (using command python sample.py
),
Traceback (most recent call last):
File ".\ToadApp.py", line 12, in <module>
from FlaUI.UIA3 import UIA3Automation
ModuleNotFoundError: No module named 'FlaUI.UIA3'; 'FlaUI' is not a package
If I don't include the FlaUI.UIA3
library then I am able to Launch the application with Application.Launch('software.exe')
.
Here is the content of my directory containing FlaUI3.UIA3.dll
,
C:\Users\amit_tendulkar>dir C:\Users\amit_tendulkar\.nuget\packages\flaui.uia3\3.2.0\lib\net45
Volume in drive C has no label.
Volume Serial Number is 8692-D75E
Directory of C:\Users\amit_tendulkar\.nuget\packages\flaui.uia3\3.2.0\lib\net45
25-01-2022 22:28 <DIR> .
25-01-2022 22:28 <DIR> ..
17-07-2020 02:05 105,472 FlaUI.UIA3.dll
17-07-2020 02:05 28,095 FlaUI.UIA3.xml
2 File(s) 133,567 bytes
Dotnet version (using Windows 10),
C:\Users\amit_tendulkar>dotnet --version
6.0.101
Looks like FlaUI.UIA3.dll
has dependency on Interop.UIAutomationClient.dll
.
Updating the code to the below solved my issue.
import clr
import sys
flaui_core_path = 'C:\\Users\\amit_tendulkar\\.nuget\\packages\\flaui.core\\3.2.0\\lib\\net45'
flaui_uia3_path = 'C:\\Users\\amit_tendulkar\\.nuget\\packages\\flaui.uia3\\3.2.0\\lib\\net45'
interop_uiautomation_path = 'C:\\Users\\amit_tendulkar\\.nuget\\packages\\interop.uiautomationclient\\10.18362.0\\lib\\net45'
sys.path.append(flaui_core_path)
clr.AddReference('FlaUI.Core')
sys.path.append(interop_uiautomation_path)
clr.AddReference('Interop.UIAutomationClient')
sys.path.append(flaui_uia3_path)
clr.AddReference('FlaUI.UIA3')
from FlaUI.Core import Application
from FlaUI.Core.Conditions import ConditionFactory
from FlaUI.Core.Tools import Retry
from FlaUI.UIA3 import UIA3Automation
from FlaUI.UIA3 import UIA3PropertyLibrary