Satish Michael
Satish Michael

Reputation: 2015

Pywinauto - taking 10 seconds to perform an operation

I'm using pywinauto to try and automate a windows application and I'm noticing each operation takes about 10 seconds to perform. It works but it is slow, and given this is the first time I'm using pywinauto, I may be doing something wrong.

Any help will be much appreciated version 0.6.4

self.main_wnd_spec.wait(wait_for='ready', timeout=50)
create = self.main_wnd_spec.child_window(title='Create', control_type="Window")

import time
start_time = time.time()
    type_= ComboBoxWrapper(create.child_window(
        title="Type:", auto_id="27651", control_type="ComboBox")
    )
    type_.select(1)
    print("--- %s seconds ---" % (time.time() - start_time))

start_time = time.time()
    severity= EditWrapper(create.child_window(title="Severity:", auto_id="27653", control_type="Edit"))
    severity.SetEditText('1')
    print("--- %s seconds ---" % (time.time() - start_time))

output

--- 10.8264000415802 seconds ---
--- 10.514400005340576 seconds ---

Control Identifiers

 Dialog - 'Create'    (L604, T269, R1317, B772)
 ['Dialog', 'Create', 'Create Dialog']
 child_window(title="Create", control_type="Window")
  | 
  | ComboBox - 'Type:'    (L740, T334, R1165, B355)
  | ['Type:2', 'ComboBox', 'Batch class:ComboBox', 'ComboBox0', 'ComboBox1']
  | child_window(title="Type:", auto_id="27651", control_type="ComboBox")
  |    | 
  |    | Static - 'Type:'    (L3, T3, R405, B18)
  |    | ['Type:3', 'Static2', 'Batch class:Static2']
  |    | child_window(title="Type:", control_type="Text")
  |    | 
  |    | Button - 'Open'    (L1149, T335, R1164, B354)
  |    | ['Button', 'Open', 'OpenButton', 'Button0', 'Button1', 'Open0', 
         'Open1', 'OpenButton0', 'OpenButton1']
  |    | child_window(title="Open", auto_id="DropDown", control_type="Button")
  | 
  | Edit - 'Severity:'    (L1247, T334, R1278, B354)
  | ['Edit', '', 'Severity:Edit', 'Edit0', 'Edit1', '0', '1']
  | child_window(title="Severity:", auto_id="27653", control_type="Edit")

Upvotes: 1

Views: 1753

Answers (1)

Satish Michael
Satish Michael

Reputation: 2015

I have figured out why searches were taking more than 10 seconds. I am answering my own question for folks who don't want to go through the comments for the answer.

As per Vasily Ryabov comment, when you create a wrapper object, the search starts from root, and in my case, the root had more than 8500 descendants, When I managed to decrease the number of descendants through the app, the search time dropped to

--- 1.2239999771118164 seconds ---
--- 0.9530003070831299 seconds ---

Upvotes: 2

Related Questions