Skip to content
This repository has been archived by the owner on Jul 31, 2018. It is now read-only.

Reuse app variable #63

Open
moden-py opened this issue Oct 25, 2015 · 3 comments
Open

Reuse app variable #63

moden-py opened this issue Oct 25, 2015 · 3 comments
Assignees
Labels

Comments

@moden-py
Copy link
Contributor

Reuse app variable for one process owned different top level windows.
One app may be used for all windows owned by one process. For instance:

from pywinauto.application import Application

app = Application().Start(cmd_line=u'"C:\\Windows\\system32\\notepad.exe" ')
notepad = app.Notepad
notepad.Wait('ready')
menu_item = notepad.MenuItem(u'&Help->&About Notepad')
menu_item.Click()
window = app.Dialog
window.Wait('ready')
button = window.OK
button.Click()

app.Kill_()

Now the same actions code looks:

from pywinauto.application import Application

app = Application().Start(cmd_line=u'"C:\\Windows\\system32\\notepad.exe" ')
notepad = app.Notepad
notepad.Wait('ready')
menu_item = notepad.MenuItem(u'&Help->&About Notepad')
menu_item.Click()

app2 = Application().Start(cmd_line=u'"C:\\Windows\\system32\\notepad.exe" ')
window = app2.Dialog
window.Wait('ready')
button = window.OK
button.Click()
button.Click()

app2.Kill_()
app.Kill_()

Restarting the same application is probably not the thing you expect.

@moden-py moden-py added the bug label Oct 25, 2015
@moden-py moden-py self-assigned this Oct 25, 2015
@moden-py
Copy link
Contributor Author

In case the second window opens after some action on the first one, you should refresh the objects tree to add new windows.
Before fix "Reuse app" issue, a "safe refresh" should be applied.
Now all the counters are reset after the object browser refresh.

@moden-py
Copy link
Contributor Author

Depends on #66

@GopinathB-Hexaware
Copy link

i download the code and how to run manually

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants