Added Revision and some other minor cleanup
This commit is contained in:
parent
1e1eea4f5d
commit
bc3c410aa3
@ -1,17 +1,18 @@
|
|||||||
"""Automate WinRAR evaluation copy
|
"""Automate WinRAR evaluation copy
|
||||||
|
|
||||||
We hit a few dialogs and save XML dump and
|
We hit a few dialogs and save XML dump and
|
||||||
screenshot from each dialog.
|
screenshot from each dialog.
|
||||||
|
|
||||||
Specify a language at the command line:
|
Specify a language at the command line:
|
||||||
0 Czech
|
0 Czech
|
||||||
1 German
|
1 German
|
||||||
2 French
|
2 French
|
||||||
|
|
||||||
More then likely you will need to modify the apppath
|
More then likely you will need to modify the apppath
|
||||||
entry in the 't' dictionary to where you have
|
entry in the 't' dictionary to where you have
|
||||||
extracted the WinRAR executables.
|
extracted the WinRAR executables.
|
||||||
"""
|
"""
|
||||||
|
__revision__ = "$Revision$"
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -22,112 +23,112 @@ folders = ['wrar351cz', 'wrar351d', 'wrar351fr']
|
|||||||
|
|
||||||
# translations for each language
|
# translations for each language
|
||||||
t = {
|
t = {
|
||||||
'apppath' : (
|
'apppath' : (
|
||||||
'c:\.temp\wrar351fr\winrar.exe',
|
'c:\.temp\wrar351fr\winrar.exe',
|
||||||
'c:\.temp\wrar351d\winrar.exe',
|
'c:\.temp\wrar351d\winrar.exe',
|
||||||
'c:\.temp\wrar351cz\winrar.exe'
|
'c:\.temp\wrar351cz\winrar.exe'
|
||||||
),
|
),
|
||||||
|
|
||||||
# Buy Licence Dialog
|
# Buy Licence Dialog
|
||||||
'Buy Licence' : (
|
'Buy Licence' : (
|
||||||
"Acheter une licence pur winRAR",
|
"Acheter une licence pur winRAR",
|
||||||
"Bittekaufensieeine",
|
"Bittekaufensieeine",
|
||||||
"Zakuptesiprosm"),
|
"Zakuptesiprosm"),
|
||||||
'Close' : (
|
'Close' : (
|
||||||
"Fermer",
|
"Fermer",
|
||||||
"Schleissen",
|
"Schleissen",
|
||||||
"Zavrit"),
|
"Zavrit"),
|
||||||
|
|
||||||
# Options->Configure menu items
|
# Options->Configure menu items
|
||||||
"Options->Configure" : (
|
"Options->Configure" : (
|
||||||
"Options->Configuration",
|
"Options->Configuration",
|
||||||
"Optionen->Einstellungen",
|
"Optionen->Einstellungen",
|
||||||
"Moznosti->Nastaveni"),
|
"Moznosti->Nastaveni"),
|
||||||
|
|
||||||
# Configure/Options dialog box
|
# Configure/Options dialog box
|
||||||
'Configure' : (
|
'Configure' : (
|
||||||
"Configuration",
|
"Configuration",
|
||||||
"Einstellungen",
|
"Einstellungen",
|
||||||
"Nastaveni"),
|
"Nastaveni"),
|
||||||
|
|
||||||
# personalise toolbar buttons button
|
# personalise toolbar buttons button
|
||||||
'Buttons' : (
|
'Buttons' : (
|
||||||
"Boutons",
|
"Boutons",
|
||||||
"Schaltflachen",
|
"Schaltflachen",
|
||||||
"Vybrattlacitka"),
|
"Vybrattlacitka"),
|
||||||
|
|
||||||
# Personalize toolbars dialog
|
# Personalize toolbars dialog
|
||||||
'PeronnaliseToolbars' : (
|
'PeronnaliseToolbars' : (
|
||||||
"Peronnalisation de la barre doutils",
|
"Peronnalisation de la barre doutils",
|
||||||
"Werkzeugleisteanpassen",
|
"Werkzeugleisteanpassen",
|
||||||
"Vybertlaciteknastrojovelisty"),
|
"Vybertlaciteknastrojovelisty"),
|
||||||
|
|
||||||
# create profile button
|
# create profile button
|
||||||
'CreateDefaultProfile' : (
|
'CreateDefaultProfile' : (
|
||||||
u"Creerleprofilpardéfault",
|
u"Creerleprofilpardéfault",
|
||||||
"Standardfestlegen",
|
"Standardfestlegen",
|
||||||
"Vytvoritimplicitni"),
|
"Vytvoritimplicitni"),
|
||||||
|
|
||||||
# create profile dialog box title
|
# create profile dialog box title
|
||||||
'ConfigureDefaultOptions' : (
|
'ConfigureDefaultOptions' : (
|
||||||
"Configurer les options de compre...",
|
"Configurer les options de compre...",
|
||||||
"Standardkomprimierungs",
|
"Standardkomprimierungs",
|
||||||
"Zmenaimplicitnichnast..."),
|
"Zmenaimplicitnichnast..."),
|
||||||
|
|
||||||
# context menu's button
|
# context menu's button
|
||||||
"ContextMenus" : (
|
"ContextMenus" : (
|
||||||
"Menus contextuels",
|
"Menus contextuels",
|
||||||
"Optionenimkontextmenu",
|
"Optionenimkontextmenu",
|
||||||
"Polozkykontextovehamenu"),
|
"Polozkykontextovehamenu"),
|
||||||
|
|
||||||
# context menu's dialog
|
# context menu's dialog
|
||||||
"contextMenuDlg" : (
|
"contextMenuDlg" : (
|
||||||
"Rubriques des menus contextuels",
|
"Rubriques des menus contextuels",
|
||||||
"OptionenindenKontextmenus",
|
"OptionenindenKontextmenus",
|
||||||
"Polozkykontextovehamenu"),
|
"Polozkykontextovehamenu"),
|
||||||
|
|
||||||
# file->exit menu option
|
# file->exit menu option
|
||||||
"File->Exit" : (
|
"File->Exit" : (
|
||||||
"Fichier->Quitter",
|
"Fichier->Quitter",
|
||||||
"Datei->Beenden",
|
"Datei->Beenden",
|
||||||
"Soubor->Konec"),
|
"Soubor->Konec"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_winrar_dlgs(rar_dlg, x):
|
def get_winrar_dlgs(rar_dlg, x):
|
||||||
rar_dlg.MenuSelect(t["Options->Configure"][x])
|
rar_dlg.MenuSelect(t["Options->Configure"][x])
|
||||||
|
|
||||||
optionsdlg = rar_dlg.app[t['Configure'][x]]
|
optionsdlg = rar_dlg.app[t['Configure'][x]]
|
||||||
optionsdlg._write("Options_%d.xml"%x)
|
optionsdlg._write("Options_%d.xml"%x)
|
||||||
optionsdlg.CaptureAsImage().save("Options_%d.png"%x)
|
optionsdlg.CaptureAsImage().save("Options_%d.png"%x)
|
||||||
optionsdlg[t['Buttons'][x]].Click()
|
optionsdlg[t['Buttons'][x]].Click()
|
||||||
|
|
||||||
contextMenuDlg = rar_dlg.app[t['PeronnaliseToolbars'][x]]
|
contextMenuDlg = rar_dlg.app[t['PeronnaliseToolbars'][x]]
|
||||||
contextMenuDlg._write("PersonaliseToolbars_%d.xml"%x)
|
contextMenuDlg._write("PersonaliseToolbars_%d.xml"%x)
|
||||||
contextMenuDlg.CaptureAsImage().save("PersonaliseToolbars_%d.png"%x)
|
contextMenuDlg.CaptureAsImage().save("PersonaliseToolbars_%d.png"%x)
|
||||||
contextMenuDlg.OK.Click()
|
contextMenuDlg.OK.Click()
|
||||||
|
|
||||||
|
optionsdlg.TabCtrl.Select(1)
|
||||||
|
optionsdlg[t['CreateDefaultProfile'][x]].Click()
|
||||||
|
|
||||||
|
defaultOptionsDlg = rar_dlg.app[t['ConfigureDefaultOptions'][x]]
|
||||||
|
defaultOptionsDlg._write("DefaultOptions_%d.xml"%x)
|
||||||
|
defaultOptionsDlg.CaptureAsImage().save("DefaultOptions_%d.png"%x)
|
||||||
|
defaultOptionsDlg.OK.Click()
|
||||||
|
|
||||||
|
optionsdlg.TabCtrl.Select(6)
|
||||||
|
optionsdlg[t['ContextMenus'][x]].Click()
|
||||||
|
|
||||||
|
anotherMenuDlg = rar_dlg.app[t['contextMenuDlg'][x]]
|
||||||
|
anotherMenuDlg._write("2ndMenuDlg_%d.xml"%x)
|
||||||
|
anotherMenuDlg.CaptureAsImage().save("2ndMenuDlg_%d.png"%x)
|
||||||
|
|
||||||
|
anotherMenuDlg.OK.Click()
|
||||||
|
|
||||||
|
optionsdlg.OK.Click()
|
||||||
|
|
||||||
|
|
||||||
optionsdlg.TabCtrl.Select(1)
|
|
||||||
optionsdlg[t['CreateDefaultProfile'][x]].Click()
|
|
||||||
|
|
||||||
defaultOptionsDlg = rar_dlg.app[t['ConfigureDefaultOptions'][x]]
|
|
||||||
defaultOptionsDlg._write("DefaultOptions_%d.xml"%x)
|
|
||||||
defaultOptionsDlg.CaptureAsImage().save("DefaultOptions_%d.png"%x)
|
|
||||||
defaultOptionsDlg.OK.Click()
|
|
||||||
|
|
||||||
optionsdlg.TabCtrl.Select(6)
|
|
||||||
optionsdlg[t['ContextMenus'][x]].Click()
|
|
||||||
|
|
||||||
anotherMenuDlg = rar_dlg.app[t['contextMenuDlg'][x]]
|
|
||||||
anotherMenuDlg._write("2ndMenuDlg_%d.xml"%x)
|
|
||||||
anotherMenuDlg.CaptureAsImage().save("2ndMenuDlg_%d.png"%x)
|
|
||||||
|
|
||||||
anotherMenuDlg.OK.Click()
|
|
||||||
|
|
||||||
optionsdlg.OK.Click()
|
|
||||||
|
|
||||||
|
|
||||||
# get the languages as an integer
|
# get the languages as an integer
|
||||||
x = int(sys.argv[1])
|
x = int(sys.argv[1])
|
||||||
|
|
||||||
@ -148,4 +149,5 @@ rar_dlg = app._window(title_re = ".* - WinRAR.*")
|
|||||||
get_winrar_dlgs(rar_dlg, x)
|
get_winrar_dlgs(rar_dlg, x)
|
||||||
|
|
||||||
# exit WinRar
|
# exit WinRar
|
||||||
|
time.sleep(.5)
|
||||||
rar_dlg.MenuSelect(t['File->Exit'][x])
|
rar_dlg.MenuSelect(t['File->Exit'][x])
|
||||||
|
@ -1,70 +1,79 @@
|
|||||||
# GUI Application automation and testing library
|
# GUI Application automation and testing library
|
||||||
# Copyright (C) 2006 Mark Mc Mahon
|
# Copyright (C) 2006 Mark Mc Mahon
|
||||||
#
|
#
|
||||||
# This library is free software; you can redistribute it and/or
|
# This library is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU Lesser General Public License
|
# modify it under the terms of the GNU Lesser General Public License
|
||||||
# as published by the Free Software Foundation; either version 2.1
|
# as published by the Free Software Foundation; either version 2.1
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This library is distributed in the hope that it will be useful,
|
# This library is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
# See the GNU Lesser General Public License for more details.
|
# See the GNU Lesser General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU Lesser General Public
|
# You should have received a copy of the GNU Lesser General Public
|
||||||
# License along with this library; if not, write to the
|
# License along with this library; if not, write to the
|
||||||
# Free Software Foundation, Inc.,
|
# Free Software Foundation, Inc.,
|
||||||
# 59 Temple Place,
|
# 59 Temple Place,
|
||||||
# Suite 330,
|
# Suite 330,
|
||||||
# Boston, MA 02111-1307 USA
|
# Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
"Some automation of Windows Media player"
|
||||||
|
|
||||||
|
__revision__ = "$Revision$"
|
||||||
|
|
||||||
|
|
||||||
#import os
|
#import os
|
||||||
import time
|
import time
|
||||||
|
import sys
|
||||||
|
|
||||||
from pywinauto import application
|
from pywinauto import application
|
||||||
|
|
||||||
from pywinauto import tests
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def WindowsMedia():
|
def WindowsMedia():
|
||||||
|
|
||||||
app = application.Application()
|
|
||||||
|
|
||||||
app._connect(path = ur"C:\Program Files\Windows Media Player\wmplayer.exe")
|
app = application.Application()
|
||||||
|
|
||||||
app.WindowsMediaPlayer.MenuSelect("View->GoTo->Library")
|
|
||||||
app.WindowsMediaPlayer.MenuSelect("View->Choose Columns")
|
|
||||||
|
|
||||||
for ctrl in app.ChooseColumns.Children:
|
|
||||||
print ctrl.Class
|
|
||||||
|
|
||||||
|
|
||||||
print "Is it checked already:", app.ChooseColumsn.ListView.IsChecked(1)
|
|
||||||
|
|
||||||
# Check an Item in the listview
|
|
||||||
app.ChooseColumns.ListView.Check(1)
|
|
||||||
time.sleep(.5)
|
|
||||||
print "Shold be checked now:", app.ChooseColumsn.ListView.IsChecked(1)
|
|
||||||
|
|
||||||
# Uncheck it
|
try:
|
||||||
app.ChooseColumns.ListView.UnCheck(1)
|
app._connect(
|
||||||
time.sleep(.5)
|
path = ur"C:\Program Files\Windows Media Player\wmplayer.exe")
|
||||||
print "Should not be checked now:", app.ChooseColumsn.ListView.IsChecked(1)
|
except application.ProcessNotFoundError:
|
||||||
|
print "You must first start Windows Media "\
|
||||||
|
"Player before running this script"
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
# Check it again
|
app.WindowsMediaPlayer.MenuSelect("View->GoTo->Library")
|
||||||
app.ChooseColumns.ListView.Check(1)
|
app.WindowsMediaPlayer.MenuSelect("View->Choose Columns")
|
||||||
time.sleep(.5)
|
|
||||||
|
for ctrl in app.ChooseColumns.Children:
|
||||||
app.ChooseColumsn.Cancel.Click()
|
print ctrl.Class
|
||||||
|
|
||||||
|
|
||||||
|
print "Is it checked already:", app.ChooseColumsn.ListView.IsChecked(1)
|
||||||
|
|
||||||
|
# Check an Item in the listview
|
||||||
|
app.ChooseColumns.ListView.Check(1)
|
||||||
|
time.sleep(.5)
|
||||||
|
print "Shold be checked now:", app.ChooseColumsn.ListView.IsChecked(1)
|
||||||
|
|
||||||
|
# Uncheck it
|
||||||
|
app.ChooseColumns.ListView.UnCheck(1)
|
||||||
|
time.sleep(.5)
|
||||||
|
print "Should not be checked now:", app.ChooseColumsn.ListView.IsChecked(1)
|
||||||
|
|
||||||
|
# Check it again
|
||||||
|
app.ChooseColumns.ListView.Check(1)
|
||||||
|
time.sleep(.5)
|
||||||
|
|
||||||
|
app.ChooseColumsn.Cancel.Click()
|
||||||
|
|
||||||
|
|
||||||
def Main():
|
def Main():
|
||||||
start = time.time()
|
start = time.time()
|
||||||
|
|
||||||
WindowsMedia()
|
WindowsMedia()
|
||||||
|
|
||||||
print "Total time taken:", time.time() - start
|
print "Total time taken:", time.time() - start
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
Main()
|
Main()
|
Loading…
Reference in New Issue
Block a user