pywinauto icon indicating copy to clipboard operation
pywinauto copied to clipboard

Maintaining control identifiers in centralized location

Open NeJaiswal opened this issue 6 years ago • 12 comments

When desktop application is very large and has 10k identifiers,then how should one maintain and access then from centralized location (file) in python. Please give suggestions.

Earlier we were using QTP for automation which has its own utility of object repository... For pywinauto how can we create similar utility or how can we organize objects in one file and access them efficiently in script

NeJaiswal avatar Jun 26 '18 15:06 NeJaiswal

Hi @NeJaiswal not sure I fully understood your request because I've never used QTP. But I met the situation with 3k controls.

10k controls may cause huge performance issue when calling .print_control_identifiers(filename="<file name>"). As a workaround, it's possible to walk the hierarchy by using .children() (immediate children only) and .descendants() (the whole subtree as a plain list). More optimizations are planned, but it's medium priority.

We also have object inspector prototype: https://github.com/pywinauto/py_inspect but I personally still use Inspect.exe mentioned in the Getting Started Guide.

vasily-v-ryabov avatar Jun 29 '18 21:06 vasily-v-ryabov

@vasily-v-ryabov thanks for the response but what I wanted to achieve is let say I want to perform below actions in automation script: 1]Click on Button from Menu 2]Verify window is launched 3]Navigate to particular element in window and perform right click 4]dialog box will get launched now fill the detail there.

So to perform these actions we need to Search UI elements using control identifiers/auto_id etc. In ideal case we should have all identifiers in proper format/hierarchy to access it e.g. mainwindow.child_window(auto_id=1,control_type='button')

As per your solution to get this detail using inspector or printing control identifiers in files will not be ideal case for each time.In project framework I should have these details of all UI object stored beforehand so that same object will be used across entire framework(whenever need to access same UI object) and any changes to objects will require to perform change at one location.

Now the question is how to store these object details and how to call them in scrips.

Currently we have segregated all UI object window wise in each python file which looks like below:

sample.py class browser: self.window=main.child_window(title="BasketListView", class_name="SysListView32") self.playhist = main.child_window(title="PlayHistory Back Toolbar", class_name="ToolbarWindow32")

So that whenever we have to access window object in particular script we call- from sample.py import browser

which will provide us variable having all details require to perform action on that object. Currently Application is very large so its resulting in number of python files having UI element detail and too may classes for each window, is there any better way to get them stored in one file and access them from there?

NeJaiswal avatar Jul 01 '18 05:07 NeJaiswal

If I got it right, this is not automated. You have to assign UI element details to a variable your own way.

After watching short video about QTP object repo I got the idea. So print_control_identifiers() can be easily modified to produce Python module instead of plain text with the hierarchy. Thanks for detailed explanation!

vasily-v-ryabov avatar Jul 01 '18 08:07 vasily-v-ryabov

When will the pywinauto 0.7.0 get released?

NeJaiswal avatar Jul 01 '18 18:07 NeJaiswal

There is no exact deadline because it's a hobby project for out-of-office hours. We may consider adding this in 0.6.6 update (if it will make sense). 0.7.0 is targeted for "record-replay" for UIA backend and I hope it will be out this autumn.

vasily-v-ryabov avatar Jul 02 '18 13:07 vasily-v-ryabov

Hi , @vasily-v-ryabov ......as we are using pywinauto extensively in our automation project ,its a request if this issue also could get resolve on priority ......it would be pretty much added advantage.

NeJaiswal avatar Nov 26 '18 05:11 NeJaiswal

Hi @NeJaiswal if some task requires higher priority, some funding would be reasonable. There is "Donate" button or we can proceed on UpWork if it's suitable for you. With current priorities I would say February-March is realistic estimation.

I'm sorry if you don't like talks about money in context of open source software. But we really want to finish UIA Recorder Beta first, then improve consistency and implement this feature. And pywinauto==0.6.6 milestone is also not finished yet. We can further discuss it privately. My gmail can be obtained so: "vasily-v-ryabov".replace("-", ".").

vasily-v-ryabov avatar Nov 26 '18 10:11 vasily-v-ryabov

Pywinauto is an awesome project and you're always very present for your community @vasily-v-ryabov (here on Github and on StackOverflow), thank you for that. I wish some day donations will be sufficient so that the project grows even more.

ZoeThivet avatar Dec 21 '18 05:12 ZoeThivet

@ZoeThivet thanks a lot man!

vasily-v-ryabov avatar Dec 22 '18 17:12 vasily-v-ryabov

If I got it right, this is not automated. You have to assign UI element details to a variable your own way.

After watching short video about QTP object repo I got the idea. So print_control_identifiers() can be easily modified to produce Python module instead of plain text with the hierarchy. Thanks for detailed explanation!

@vasily-v-ryabov do you mean to say print_control_identifiers to .py file? or any specific format we can get the controls as a python module? , even we are in requirement of storing huge number of UI elements and should be maintained, looking for a generic solution , is there any update for this ,can you please help?

manjunathch149 avatar Dec 30 '20 14:12 manjunathch149

Hi @manjunathch149 not sure it should be .dump_tree(py_file="some.py"), maybe it will be separate method. Work on this issue is still not started. One of the problems I can see here is that .dump_tree() output doesn't guarantee 100% unique window specifications for all elements. This should be considered somehow in this method design and it may touch some internal architecture of the library. We decided to not include UI recorder into next major release, but this feature request is planned for 0.7.0. So any ideas are welcome. If you have any examples how it should look, let's discuss it.

vasily-v-ryabov avatar Jan 03 '21 15:01 vasily-v-ryabov

Hi @vasily-v-ryabov, I am trying to create a record and playback script in which the script will automatically return the control identifier when clicked(or any other mouse/keyboard activity) on the element. Is there a way to do this. I mean to playback the script, I need to have the element name and the element id.

Roboflex30 avatar Jan 09 '24 07:01 Roboflex30