1
votes

I am working on the Automation of loading an image file in "Oracle VM Virtual box" to create a virtual machine using Pywinauto in python. I am able to automate the installation of Virtual Box software & after that able to launch the exe also shown in the image

VM Tool GUI

But after that I am not able to do any GUI operation on "Oracle VM VirtualBox Manager" (e.g.Selecting File Menu or click New button) automatically using Pywinauto. I have attached the snapshot of Inspect tool for Oracle VM Virtual box

Inspect Tool VM VirtualBox

Below is the code which I am trying to run

>>> from pywinauto import application
>>> app=application.Application()

>>> app.start(r"C:\Program Files\Oracle\VirtualBox\VirtualBox.exe")
<pywinauto.application.Application object at 0x000001D671679BA8>

>>>app['Oracle VM VirtualBox Manager']['New']
<pywinauto.application.WindowSpecification object at 0x000001D670FB9CC0>

>>> app['Oracle VM VirtualBox Manager']['New'].click()

After executing click command shown above I am getting error

Error:

Traceback (most recent call last):
  File "C:\Program Files\Python37\lib\site-packages\pywinauto\application.py", line 246, in __resolve_control
    criteria)
  File "C:\Program Files\Python37\lib\site-packages\pywinauto\timings.py", line 453, in wait_until_passes
    raise err
pywinauto.timings.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    app['Oracle VM VirtualBox Manager']['New'].click()
  File "C:\Program Files\Python37\lib\site-packages\pywinauto\application.py", line 352, in __getattribute__
    ctrls = self.__resolve_control(self.criteria)
  File "C:\Program Files\Python37\lib\site-packages\pywinauto\application.py", line 249, in __resolve_control
    raise e.original_exception
  File "C:\Program Files\Python37\lib\site-packages\pywinauto\timings.py", line 431, in wait_until_passes
    func_val = func(*args, **kwargs)
  File "C:\Program Files\Python37\lib\site-packages\pywinauto\application.py", line 210, in __get_ctrl
    ctrl = self.backend.generic_wrapper_class(findwindows.find_element(**ctrl_criteria))
  File "C:\Program Files\Python37\lib\site-packages\pywinauto\findwindows.py", line 87, in find_element
    raise ElementNotFoundError(kwargs)
pywinauto.findwindows.ElementNotFoundError: {'best_match': 'New', 'top_level_only': False, 'parent': <win32_element_info.HwndElementInfo - 'Oracle VM VirtualBox Manager', Qt5QWindowIcon, 68992>, 'backend': 'win32'}

In Inspect tool it is showing that Oracle VM VirtualBox Manager window "Is Keyboard focusable" is false & there is no Automation ID for these controls.

Please suggest me the commands to perform buttons click automation on this GUI. I am new to python & not able to understand what should I do next.

1
Please format the question so it can be easily readable your codeGourav Joshi
Hi Gourav, I am new to SO, do not know exactly how to format the question. I tried my best to represent the code readableVarRa

1 Answers

0
votes

If you're using Inspect.exe, you must use Application(backend="uia") as an entry point. This is described in the Getting Started Guide.

Default backend is "win32", so it can be used if Spy++ can see this button (I suppose the answer is "no").