Changed HwndWrapper.Text, SetText to WindowText and SetWindowText (and EditWrapper.SetText to EditWrapper.SetEditText
This commit is contained in:
parent
a7c73f75b7
commit
81ade6e3d7
@ -14,12 +14,12 @@ def do_test_1():
|
|||||||
app = Application().start_(r"c:\windows\Notepad")
|
app = Application().start_(r"c:\windows\Notepad")
|
||||||
notepadWindow = app.Notepad
|
notepadWindow = app.Notepad
|
||||||
|
|
||||||
notepadWindow.Edit1.SetText(u"Hello, ägain!", 0, -1)
|
notepadWindow.Edit1.SetEditText(u"Hello, ägain!", 0, -1)
|
||||||
sleep(0.8)
|
sleep(0.8)
|
||||||
notepadWindow.Edit.SetText("\r\nYou still there?")
|
notepadWindow.Edit.SetEditText("\r\nYou still there?")
|
||||||
|
|
||||||
sleep(0.2)
|
sleep(0.2)
|
||||||
notepadWindow.Edit.SetText("\r\nGoing Bye Bye now!!")
|
notepadWindow.Edit.SetEditText("\r\nGoing Bye Bye now!!")
|
||||||
|
|
||||||
sleep(1)
|
sleep(1)
|
||||||
notepadWindow.MenuSelect("File->Exit")
|
notepadWindow.MenuSelect("File->Exit")
|
||||||
|
@ -50,7 +50,7 @@ prev_height = app.Attributes.Edit2.Texts()[1]
|
|||||||
|
|
||||||
# set our preferred area
|
# set our preferred area
|
||||||
app.Attributes.Edit1.TypeKeys("350") # you can use TypeKeys or
|
app.Attributes.Edit1.TypeKeys("350") # you can use TypeKeys or
|
||||||
app.Attributes.Edit2.SetText("350") # SetText - they work differently!
|
app.Attributes.Edit2.SetEditText("350") # SetText - they work differently!
|
||||||
|
|
||||||
app.Attributes.OK.CloseClick()
|
app.Attributes.OK.CloseClick()
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ if image:
|
|||||||
pwin.MenuSelect("Image->Attributes")
|
pwin.MenuSelect("Image->Attributes")
|
||||||
# set our preferred area
|
# set our preferred area
|
||||||
app.Attributes.Edit1.TypeKeys(prev_width)
|
app.Attributes.Edit1.TypeKeys(prev_width)
|
||||||
app.Attributes.Edit2.SetText(prev_height)
|
app.Attributes.Edit2.SetEditText(prev_height)
|
||||||
app.Attributes.OK.CloseClick()
|
app.Attributes.OK.CloseClick()
|
||||||
|
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ app.PageSetupDlg2.OK.CloseClick()
|
|||||||
app.PageSetupDlg.Ok.CloseClick()
|
app.PageSetupDlg.Ok.CloseClick()
|
||||||
|
|
||||||
# type some text - note that extended characters ARE allowed
|
# type some text - note that extended characters ARE allowed
|
||||||
app.Notepad.Edit.SetText(u"I am typing s\xe4me text to Notepad\r\n\r\n"
|
app.Notepad.Edit.SetEditText(u"I am typing s\xe4me text to Notepad\r\n\r\n"
|
||||||
"And then I am going to quit")
|
"And then I am going to quit")
|
||||||
|
|
||||||
app.Notepad.Edit.RightClick()
|
app.Notepad.Edit.RightClick()
|
||||||
@ -159,7 +159,7 @@ app.Notepad.Edit.TypeKeys(u"{END}{ENTER}SendText d\xf6\xe9s not "
|
|||||||
# Try and save
|
# Try and save
|
||||||
app.Notepad.MenuSelect("File->SaveAs")
|
app.Notepad.MenuSelect("File->SaveAs")
|
||||||
app.SaveAs.ComboBox5.Select("UTF-8")
|
app.SaveAs.ComboBox5.Select("UTF-8")
|
||||||
app.SaveAs.edit1.SetText("Example-utf8.txt")
|
app.SaveAs.edit1.SetEditText("Example-utf8.txt")
|
||||||
app.SaveAs.Save.CloseClick()
|
app.SaveAs.Save.CloseClick()
|
||||||
|
|
||||||
# my machine has a weird problem - when connected to the network
|
# my machine has a weird problem - when connected to the network
|
||||||
|
@ -91,7 +91,7 @@ app['PageSetup2']['OK'].CloseClick()
|
|||||||
app['PageSetup']['Ok'].CloseClick()
|
app['PageSetup']['Ok'].CloseClick()
|
||||||
|
|
||||||
# type some text
|
# type some text
|
||||||
app['Notepad']['Edit'].SetText(u"I am typing s\xe4me text to Notepad"
|
app['Notepad']['Edit'].SetEditText(u"I am typing s\xe4me text to Notepad"
|
||||||
"\r\n\r\nAnd then I am going to quit")
|
"\r\n\r\nAnd then I am going to quit")
|
||||||
|
|
||||||
# exit notepad
|
# exit notepad
|
||||||
|
@ -139,7 +139,7 @@ app.PageSetupDlg2.OK.CloseClick()
|
|||||||
app.PageSetupDlg.Ok.CloseClick()
|
app.PageSetupDlg.Ok.CloseClick()
|
||||||
|
|
||||||
# type some text - note that extended characters ARE allowed
|
# type some text - note that extended characters ARE allowed
|
||||||
app.Notepad.Edit.SetText(u"I am typing s\xe4me text to Notepad\r\n\r\n"
|
app.Notepad.Edit.SetEditText(u"I am typing s\xe4me text to Notepad\r\n\r\n"
|
||||||
"And then I am going to quit")
|
"And then I am going to quit")
|
||||||
|
|
||||||
# the following shows that Sendtext does not accept
|
# the following shows that Sendtext does not accept
|
||||||
@ -150,7 +150,7 @@ app.Notepad.Edit.TypeKeys(u"{END}{ENTER}SendText d\xf6\xe9s not "
|
|||||||
# Try and save
|
# Try and save
|
||||||
app.Notepad.MenuSelect("File->SaveAs")
|
app.Notepad.MenuSelect("File->SaveAs")
|
||||||
app.SaveAs.ComboBox5.Select("UTF-8")
|
app.SaveAs.ComboBox5.Select("UTF-8")
|
||||||
app.SaveAs.edit1.SetText("Example-utf8.txt")
|
app.SaveAs.edit1.SetEditText("Example-utf8.txt")
|
||||||
app.SaveAs.Save.CloseClick()
|
app.SaveAs.Save.CloseClick()
|
||||||
|
|
||||||
# my machine has a weird problem - when connected to the network
|
# my machine has a weird problem - when connected to the network
|
||||||
|
@ -194,10 +194,11 @@ def _XMLToStruct(element, structType = None):
|
|||||||
If structType is not specified then element['__type__']
|
If structType is not specified then element['__type__']
|
||||||
will be used for the ctypes struct type"""
|
will be used for the ctypes struct type"""
|
||||||
|
|
||||||
|
|
||||||
# handle if we are passed in an element or a dictionary
|
# handle if we are passed in an element or a dictionary
|
||||||
if isinstance(element, ElementTree._ElementInterface):
|
try:
|
||||||
attribs = element.attrib
|
attribs = element.attrib
|
||||||
else:
|
except AttributeError:
|
||||||
attribs = element
|
attribs = element
|
||||||
|
|
||||||
# if the type has not been passed in
|
# if the type has not been passed in
|
||||||
|
@ -520,15 +520,15 @@ class WindowSpecification(object):
|
|||||||
if ctrl.IsDialog():
|
if ctrl.IsDialog():
|
||||||
ctrls = ctrl.Children()
|
ctrls = ctrl.Children()
|
||||||
visible_text_ctrls = [ctrl for ctrl in ctrls
|
visible_text_ctrls = [ctrl for ctrl in ctrls
|
||||||
if ctrl.IsVisible() and ctrl.Text()]
|
if ctrl.IsVisible() and ctrl.WindowText()]
|
||||||
else:
|
else:
|
||||||
visible_text_ctrls = [ctrl for ctrl in ctrl.Parent().Children()
|
visible_text_ctrls = [ctrl for ctrl in ctrl.Parent().Children()
|
||||||
if ctrl.IsVisible() and ctrl.Text()]
|
if ctrl.IsVisible() and ctrl.WindowText()]
|
||||||
ctrls = [ctrl]
|
ctrls = [ctrl]
|
||||||
|
|
||||||
for ctrl in ctrls:
|
for ctrl in ctrls:
|
||||||
print "%s - %s %s"% (
|
print "%s - %s %s"% (
|
||||||
ctrl.Class(), ctrl.Text(), str(ctrl.Rectangle()))
|
ctrl.Class(), ctrl.WindowText(), str(ctrl.Rectangle()))
|
||||||
|
|
||||||
print "\t",
|
print "\t",
|
||||||
for text in findbestmatch.get_control_names(
|
for text in findbestmatch.get_control_names(
|
||||||
@ -572,8 +572,8 @@ def _resolve_control(criteria_, timeout = 0, wait_interval = .2):
|
|||||||
##
|
##
|
||||||
## #find the index of the best match item
|
## #find the index of the best match item
|
||||||
## ctrl_index = app_data.index(best_match)
|
## ctrl_index = app_data.index(best_match)
|
||||||
## #print best_match[0].Text()
|
## #print best_match[0].WindowText()
|
||||||
## ctrl_index, best_match.Text()
|
## ctrl_index, best_match.WindowText()
|
||||||
##
|
##
|
||||||
## criteria[1]['ctrl_index'] = ctrl_index -1
|
## criteria[1]['ctrl_index'] = ctrl_index -1
|
||||||
## #criteria[1]['class_name'] = best_match.Class()
|
## #criteria[1]['class_name'] = best_match.Class()
|
||||||
|
@ -177,7 +177,7 @@ class HwndWrapper(object):
|
|||||||
return handleprops.classname(self)
|
return handleprops.classname(self)
|
||||||
|
|
||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
def Text(self):
|
def WindowText(self):
|
||||||
"Main text of the control"
|
"Main text of the control"
|
||||||
return handleprops.text(self)
|
return handleprops.text(self)
|
||||||
|
|
||||||
@ -280,7 +280,7 @@ class HwndWrapper(object):
|
|||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
def Texts(self):
|
def Texts(self):
|
||||||
"Return the text for each item of this control"
|
"Return the text for each item of this control"
|
||||||
texts = [self.Text(), ]
|
texts = [self.WindowText(), ]
|
||||||
return texts
|
return texts
|
||||||
|
|
||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
@ -545,13 +545,13 @@ class HwndWrapper(object):
|
|||||||
|
|
||||||
|
|
||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
def SetText(self, text, append = False):
|
def SetWindowText(self, text, append = False):
|
||||||
"Set the text of the window"
|
"Set the text of the window"
|
||||||
|
|
||||||
self.VerifyActionable()
|
self.VerifyActionable()
|
||||||
|
|
||||||
if append:
|
if append:
|
||||||
text = self.Text() + text
|
text = self.WindowText() + text
|
||||||
|
|
||||||
text = ctypes.c_wchar_p(unicode(text))
|
text = ctypes.c_wchar_p(unicode(text))
|
||||||
self.PostMessage(win32defines.WM_SETTEXT, 0, text)
|
self.PostMessage(win32defines.WM_SETTEXT, 0, text)
|
||||||
|
@ -290,7 +290,7 @@ class ListViewWrapper(HwndWrapper.HwndWrapper):
|
|||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
def Texts(self):
|
def Texts(self):
|
||||||
"Get the texts for the ListView control"
|
"Get the texts for the ListView control"
|
||||||
texts = [self.Text()]
|
texts = [self.WindowText()]
|
||||||
texts.extend([item.Text for item in self.Items()])
|
texts.extend([item.Text for item in self.Items()])
|
||||||
return texts
|
return texts
|
||||||
|
|
||||||
@ -605,11 +605,11 @@ class TreeViewWrapper(HwndWrapper.HwndWrapper):
|
|||||||
#----------------------------------------------------------------
|
#----------------------------------------------------------------
|
||||||
def Texts(self):
|
def Texts(self):
|
||||||
"Return all the text for the tree view"
|
"Return all the text for the tree view"
|
||||||
texts = [self.Text(), self.Root().Text()]
|
texts = [self.WindowText(), self.Root().WindowText()]
|
||||||
|
|
||||||
elements = self.Root().SubElements()
|
elements = self.Root().SubElements()
|
||||||
|
|
||||||
texts.extend(elem.Text() for elem in elements)
|
texts.extend(elem.WindowText() for elem in elements)
|
||||||
|
|
||||||
return texts
|
return texts
|
||||||
|
|
||||||
@ -648,7 +648,7 @@ class TreeViewWrapper(HwndWrapper.HwndWrapper):
|
|||||||
|
|
||||||
if current_elem is None:
|
if current_elem is None:
|
||||||
raise IndexError("Root Item '%s' does not have %d sibling(s)"%
|
raise IndexError("Root Item '%s' does not have %d sibling(s)"%
|
||||||
(self.Root().Text(), i + 1))
|
(self.Root().WindowText(), i + 1))
|
||||||
|
|
||||||
self.SendMessage(
|
self.SendMessage(
|
||||||
win32defines.TVM_EXPAND,
|
win32defines.TVM_EXPAND,
|
||||||
@ -662,7 +662,7 @@ class TreeViewWrapper(HwndWrapper.HwndWrapper):
|
|||||||
current_elem = current_elem.Children()[child_index]
|
current_elem = current_elem.Children()[child_index]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
raise IndexError("Item '%s' does not have %d children"%
|
raise IndexError("Item '%s' does not have %d children"%
|
||||||
(current_elem.Text(), child_index + 1))
|
(current_elem.WindowText(), child_index + 1))
|
||||||
|
|
||||||
|
|
||||||
self.SendMessage(
|
self.SendMessage(
|
||||||
@ -855,7 +855,7 @@ class HeaderWrapper(HwndWrapper.HwndWrapper):
|
|||||||
#----------------------------------------------------------------
|
#----------------------------------------------------------------
|
||||||
def Texts(self):
|
def Texts(self):
|
||||||
"Return the texts of the Header control"
|
"Return the texts of the Header control"
|
||||||
texts = [self.Text(), ]
|
texts = [self.WindowText(), ]
|
||||||
for i in range(0, self.Count()):
|
for i in range(0, self.Count()):
|
||||||
texts.append(self.ColumnText(i))
|
texts.append(self.ColumnText(i))
|
||||||
|
|
||||||
@ -1037,7 +1037,7 @@ class StatusBarWrapper(HwndWrapper.HwndWrapper):
|
|||||||
#----------------------------------------------------------------
|
#----------------------------------------------------------------
|
||||||
def Texts(self):
|
def Texts(self):
|
||||||
"Return the texts for the control"
|
"Return the texts for the control"
|
||||||
texts = [self.Text()]
|
texts = [self.WindowText()]
|
||||||
|
|
||||||
for i in range(self.NumParts()):
|
for i in range(self.NumParts()):
|
||||||
texts.append(self.GetPartText(i))
|
texts.append(self.GetPartText(i))
|
||||||
@ -1162,7 +1162,7 @@ class TabControlWrapper(HwndWrapper.HwndWrapper):
|
|||||||
#----------------------------------------------------------------
|
#----------------------------------------------------------------
|
||||||
def Texts(self):
|
def Texts(self):
|
||||||
"Return the texts of the Tab Control"
|
"Return the texts of the Tab Control"
|
||||||
texts = [self.Text()]
|
texts = [self.WindowText()]
|
||||||
texts.extend(self._extra_texts)
|
texts.extend(self._extra_texts)
|
||||||
return texts
|
return texts
|
||||||
|
|
||||||
@ -1256,7 +1256,7 @@ class ToolbarWrapper(HwndWrapper.HwndWrapper):
|
|||||||
|
|
||||||
def Texts(self):
|
def Texts(self):
|
||||||
"Return the texts of the Toolbar"
|
"Return the texts of the Toolbar"
|
||||||
texts = [self.Text()]
|
texts = [self.WindowText()]
|
||||||
for i in range(0, self.ButtonCount()):
|
for i in range(0, self.ButtonCount()):
|
||||||
texts.append(self.GetButton(i).text)
|
texts.append(self.GetButton(i).text)
|
||||||
|
|
||||||
@ -1509,7 +1509,7 @@ class ReBarWrapper(HwndWrapper.HwndWrapper):
|
|||||||
#----------------------------------------------------------------
|
#----------------------------------------------------------------
|
||||||
def Texts(self):
|
def Texts(self):
|
||||||
"Return the texts of the Rebar"
|
"Return the texts of the Rebar"
|
||||||
texts = [self.Text()]
|
texts = [self.WindowText()]
|
||||||
for i in range(0, self.BandCount()):
|
for i in range(0, self.BandCount()):
|
||||||
band = self.GetBand(i)
|
band = self.GetBand(i)
|
||||||
texts.append(band.text)
|
texts.append(band.text)
|
||||||
|
@ -233,7 +233,7 @@ class ComboBoxWrapper(HwndWrapper.HwndWrapper):
|
|||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
def Texts(self):
|
def Texts(self):
|
||||||
"Return the text of the items in the combobox"
|
"Return the text of the items in the combobox"
|
||||||
texts = [self.Text()]
|
texts = [self.WindowText()]
|
||||||
texts.extend(self.ItemTexts())
|
texts.extend(self.ItemTexts())
|
||||||
return texts
|
return texts
|
||||||
|
|
||||||
@ -349,7 +349,7 @@ class ListBoxWrapper(HwndWrapper.HwndWrapper):
|
|||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
def Texts(self):
|
def Texts(self):
|
||||||
"Return the texts of the control"
|
"Return the texts of the control"
|
||||||
texts = [self.Text()]
|
texts = [self.WindowText()]
|
||||||
texts.extend(self.ItemTexts())
|
texts.extend(self.ItemTexts())
|
||||||
return texts
|
return texts
|
||||||
|
|
||||||
@ -473,7 +473,7 @@ class EditWrapper(HwndWrapper.HwndWrapper):
|
|||||||
def Texts(self):
|
def Texts(self):
|
||||||
"Get the text of the edit control"
|
"Get the text of the edit control"
|
||||||
|
|
||||||
texts = [self.Text(), ]
|
texts = [self.WindowText(), ]
|
||||||
|
|
||||||
for i in range(0, self.LineCount()+1):
|
for i in range(0, self.LineCount()+1):
|
||||||
texts.append(self.GetLine(i))
|
texts.append(self.GetLine(i))
|
||||||
@ -501,9 +501,13 @@ class EditWrapper(HwndWrapper.HwndWrapper):
|
|||||||
|
|
||||||
return (start.value, end.value)
|
return (start.value, end.value)
|
||||||
|
|
||||||
|
def SetWindowText(self):
|
||||||
|
HwndWrapper.HwndWrapper.SetWindowText(self)
|
||||||
|
raise UserWarning(
|
||||||
|
"SetWindowText() should probably not be called for Edit Controls")
|
||||||
|
|
||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
def SetText(self, text, pos_start = None, pos_end = None):
|
def SetEditText(self, text, pos_start = None, pos_end = None):
|
||||||
"Set the text of the edit control"
|
"Set the text of the edit control"
|
||||||
self.VerifyActionable()
|
self.VerifyActionable()
|
||||||
|
|
||||||
@ -531,6 +535,9 @@ class EditWrapper(HwndWrapper.HwndWrapper):
|
|||||||
# return this control so that actions can be chained.
|
# return this control so that actions can be chained.
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
# set SetText as an alias to SetEditText
|
||||||
|
SetText = SetEditText
|
||||||
|
|
||||||
#-----------------------------------------------------------
|
#-----------------------------------------------------------
|
||||||
def Select(self, start = 0, end = None):
|
def Select(self, start = 0, end = None):
|
||||||
"Set the edit selection of the edit control"
|
"Set the edit selection of the edit control"
|
||||||
|
@ -111,6 +111,7 @@ def _clean_text(text):
|
|||||||
#return text
|
#return text
|
||||||
# remove anything after the first tab
|
# remove anything after the first tab
|
||||||
text_before_tab = _after_tab.sub("", text)
|
text_before_tab = _after_tab.sub("", text)
|
||||||
|
return text_before_tab
|
||||||
|
|
||||||
# remove non alphanumeric characters
|
# remove non alphanumeric characters
|
||||||
return _non_word_chars.sub("", text_before_tab)
|
return _non_word_chars.sub("", text_before_tab)
|
||||||
@ -171,7 +172,7 @@ def GetNonTextControlName(ctrl, text_ctrls):
|
|||||||
# if this distance was closer then the last one
|
# if this distance was closer then the last one
|
||||||
if distance < closest:
|
if distance < closest:
|
||||||
closest = distance
|
closest = distance
|
||||||
name = _clean_text(text_ctrl.Text()) + ctrl.FriendlyClassName()
|
name = _clean_text(text_ctrl.WindowText()) + ctrl.FriendlyClassName()
|
||||||
|
|
||||||
return name
|
return name
|
||||||
|
|
||||||
@ -189,7 +190,7 @@ def get_control_names(control, visible_text_controls):
|
|||||||
|
|
||||||
# if it has some character text then add it base on that
|
# if it has some character text then add it base on that
|
||||||
# and based on that with friendly class name appended
|
# and based on that with friendly class name appended
|
||||||
cleaned = _clean_text(control.Text())
|
cleaned = _clean_text(control.WindowText())
|
||||||
if cleaned:
|
if cleaned:
|
||||||
names.append(cleaned)
|
names.append(cleaned)
|
||||||
names.append(cleaned + control.FriendlyClassName())
|
names.append(cleaned + control.FriendlyClassName())
|
||||||
@ -287,7 +288,7 @@ def find_best_control_matches(search_text, controls):
|
|||||||
# get the visible text controls so that we can get
|
# get the visible text controls so that we can get
|
||||||
# the closest text if the control has no text
|
# the closest text if the control has no text
|
||||||
visible_text_ctrls = [ctrl for ctrl in controls
|
visible_text_ctrls = [ctrl for ctrl in controls
|
||||||
if ctrl.IsVisible() and _clean_text(ctrl.Text())]
|
if ctrl.IsVisible() and _clean_text(ctrl.WindowText())]
|
||||||
|
|
||||||
# collect all the possible names for all controls
|
# collect all the possible names for all controls
|
||||||
# and build a list of them
|
# and build a list of them
|
||||||
|
@ -139,23 +139,23 @@ def find_windows(class_name = None,
|
|||||||
return [windows[ctrl_index]]
|
return [windows[ctrl_index]]
|
||||||
|
|
||||||
|
|
||||||
if class_name and windows:
|
if class_name is not None and windows:
|
||||||
windows = [win for win in windows
|
windows = [win for win in windows
|
||||||
if class_name == handleprops.classname(win)]
|
if class_name == handleprops.classname(win)]
|
||||||
|
|
||||||
if class_name_re and windows:
|
if class_name_re is not None and windows:
|
||||||
windows = [win for win in windows
|
windows = [win for win in windows
|
||||||
if re.match(class_name_re, handleprops.classname(win))]
|
if re.match(class_name_re, handleprops.classname(win))]
|
||||||
|
|
||||||
if process and windows:
|
if process is not None and windows:
|
||||||
windows = [win for win in windows
|
windows = [win for win in windows
|
||||||
if handleprops.processid(win) == process]
|
if handleprops.processid(win) == process]
|
||||||
|
|
||||||
if title and windows:
|
if title is not None and windows:
|
||||||
windows = [win for win in windows
|
windows = [win for win in windows
|
||||||
if title == handleprops.text(win)]
|
if title == handleprops.text(win)]
|
||||||
|
|
||||||
elif title_re and windows:
|
elif title_re is not None and windows:
|
||||||
windows = [win for win in windows
|
windows = [win for win in windows
|
||||||
if re.match(title_re, handleprops.text(win))]
|
if re.match(title_re, handleprops.text(win))]
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ def find_windows(class_name = None,
|
|||||||
if enabled_only and windows:
|
if enabled_only and windows:
|
||||||
windows = [win for win in windows if handleprops.isenabled(win)]
|
windows = [win for win in windows if handleprops.isenabled(win)]
|
||||||
|
|
||||||
if best_match and windows:
|
if best_match is not None and windows:
|
||||||
from controls import WrapHandle
|
from controls import WrapHandle
|
||||||
windows = [WrapHandle(win) for win in windows]
|
windows = [WrapHandle(win) for win in windows]
|
||||||
windows = findbestmatch.find_best_control_matches(
|
windows = findbestmatch.find_best_control_matches(
|
||||||
|
@ -78,7 +78,7 @@ def print_bugs(bugs):
|
|||||||
|
|
||||||
for i, ctrl in enumerate(ctrls):
|
for i, ctrl in enumerate(ctrls):
|
||||||
print '\t"%s" "%s" (%d %d %d %d) Vis: %d'% (
|
print '\t"%s" "%s" (%d %d %d %d) Vis: %d'% (
|
||||||
ctrl.Text(),
|
ctrl.WindowText(),
|
||||||
ctrl.FriendlyClassName(),
|
ctrl.FriendlyClassName(),
|
||||||
ctrl.Rectangle().left,
|
ctrl.Rectangle().left,
|
||||||
ctrl.Rectangle().top,
|
ctrl.Rectangle().top,
|
||||||
|
@ -95,7 +95,7 @@ def AsianHotkeyTest(windows):
|
|||||||
if not ImplementsHotkey(win):
|
if not ImplementsHotkey(win):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if _IsAsianHotkeyFormatIncorrect(win.Text()):
|
if _IsAsianHotkeyFormatIncorrect(win.WindowText()):
|
||||||
|
|
||||||
bugs.append((
|
bugs.append((
|
||||||
[win,],
|
[win,],
|
||||||
|
@ -74,11 +74,11 @@ def LeadTrailSpacesTest(windows):
|
|||||||
if not win.ref:
|
if not win.ref:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
locLeadSpaces = GetLeadSpaces(win.Text())
|
locLeadSpaces = GetLeadSpaces(win.WindowText())
|
||||||
locTrailSpaces = GetTrailSpaces(win.Text())
|
locTrailSpaces = GetTrailSpaces(win.WindowText())
|
||||||
|
|
||||||
refLeadSpaces = GetLeadSpaces(win.ref.Text())
|
refLeadSpaces = GetLeadSpaces(win.ref.WindowText())
|
||||||
refTrailSpaces = GetTrailSpaces(win.ref.Text())
|
refTrailSpaces = GetTrailSpaces(win.ref.WindowText())
|
||||||
|
|
||||||
diffs = []
|
diffs = []
|
||||||
if locLeadSpaces != refLeadSpaces:
|
if locLeadSpaces != refLeadSpaces:
|
||||||
|
@ -92,9 +92,9 @@ def MissingExtraStringTest(windows):
|
|||||||
for char in CharsToCheck:
|
for char in CharsToCheck:
|
||||||
missing_extra = ''
|
missing_extra = ''
|
||||||
|
|
||||||
if win.Text().count(char) > win.ref.Text().count(char):
|
if win.WindowText().count(char) > win.ref.WindowText().count(char):
|
||||||
missing_extra = "ExtraCharacters"
|
missing_extra = "ExtraCharacters"
|
||||||
elif win.Text().count(char) < win.ref.Text().count(char):
|
elif win.WindowText().count(char) < win.ref.WindowText().count(char):
|
||||||
missing_extra = "MissingCharacters"
|
missing_extra = "MissingCharacters"
|
||||||
|
|
||||||
if missing_extra:
|
if missing_extra:
|
||||||
|
@ -97,7 +97,7 @@ def RepeatedHotkeyTest(windows):
|
|||||||
# build up the available characters for each control
|
# build up the available characters for each control
|
||||||
for ctrl in controls:
|
for ctrl in controls:
|
||||||
controlChars = ""
|
controlChars = ""
|
||||||
controlChars = set(ctrl.Text().lower())
|
controlChars = set(ctrl.WindowText().lower())
|
||||||
|
|
||||||
controlAvailableChars = controlChars.intersection(dlgAvailable)
|
controlAvailableChars = controlChars.intersection(dlgAvailable)
|
||||||
controlAvailableChars = \
|
controlAvailableChars = \
|
||||||
@ -155,7 +155,7 @@ def _CollectDialogInfo(windows):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# get the hotkey
|
# get the hotkey
|
||||||
pos, char = GetHotkey(win.Text())
|
pos, char = GetHotkey(win.WindowText())
|
||||||
|
|
||||||
# if no hotkey for this control
|
# if no hotkey for this control
|
||||||
# then continue
|
# then continue
|
||||||
@ -169,7 +169,7 @@ def _CollectDialogInfo(windows):
|
|||||||
|
|
||||||
# Add the title of this control to the list of available
|
# Add the title of this control to the list of available
|
||||||
# characters for the dialog
|
# characters for the dialog
|
||||||
allChars += win.Text().lower()
|
allChars += win.WindowText().lower()
|
||||||
|
|
||||||
|
|
||||||
allChars = set(allChars)
|
allChars = set(allChars)
|
||||||
|
@ -256,7 +256,7 @@ def _ButtonTruncInfo(win):
|
|||||||
newRect.right -= widthAdj
|
newRect.right -= widthAdj
|
||||||
newRect.bottom -= heightAdj
|
newRect.bottom -= heightAdj
|
||||||
|
|
||||||
return [(win.Text(), newRect, win.Font(), lineFormat), ]
|
return [(win.WindowText(), newRect, win.Font(), lineFormat), ]
|
||||||
|
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
def _ComboBoxTruncInfo(win):
|
def _ComboBoxTruncInfo(win):
|
||||||
@ -323,7 +323,7 @@ def _StaticTruncInfo(win):
|
|||||||
if win.HasStyle(win32defines.SS_NOPREFIX):
|
if win.HasStyle(win32defines.SS_NOPREFIX):
|
||||||
lineFormat |= win32defines.DT_NOPREFIX
|
lineFormat |= win32defines.DT_NOPREFIX
|
||||||
|
|
||||||
return [(win.Text(), win.ClientRects()[0], win.Font(), lineFormat), ]
|
return [(win.WindowText(), win.ClientRects()[0], win.Font(), lineFormat), ]
|
||||||
|
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
def _EditTruncInfo(win):
|
def _EditTruncInfo(win):
|
||||||
@ -333,7 +333,7 @@ def _EditTruncInfo(win):
|
|||||||
if not win.HasStyle(win32defines.ES_MULTILINE):
|
if not win.HasStyle(win32defines.ES_MULTILINE):
|
||||||
lineFormat |= win32defines.DT_SINGLELINE
|
lineFormat |= win32defines.DT_SINGLELINE
|
||||||
|
|
||||||
return [(win.Text(), win.ClientRects()[0], win.Font(), lineFormat), ]
|
return [(win.WindowText(), win.ClientRects()[0], win.Font(), lineFormat), ]
|
||||||
|
|
||||||
|
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
@ -413,7 +413,7 @@ def _DialogTruncInfo(win):
|
|||||||
if 'min' in buttons and 'help' in buttons:
|
if 'min' in buttons and 'help' in buttons:
|
||||||
diff += 4
|
diff += 4
|
||||||
|
|
||||||
return [(win.Text(), newRect, win.Font(), win32defines.DT_SINGLELINE), ]
|
return [(win.WindowText(), newRect, win.Font(), win32defines.DT_SINGLELINE), ]
|
||||||
|
|
||||||
|
|
||||||
#==============================================================================
|
#==============================================================================
|
||||||
|
@ -27,8 +27,8 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
# allow it to be imported in a dev environment
|
# allow it to be imported in a dev environment
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
pywinauto_imp = "\\".join(__file__.split('\\')[:-3])
|
pywinauto_imp = "\\".join(__file__.split('\\')[:-3])
|
||||||
print "sdfdsf", pywinauto_imp
|
print "sdfdsf", pywinauto_imp
|
||||||
sys.path.append(pywinauto_imp)
|
sys.path.append(pywinauto_imp)
|
||||||
from pywinauto.controls.HwndWrapper import *
|
from pywinauto.controls.HwndWrapper import *
|
||||||
@ -80,11 +80,11 @@ class HwndWrapperTests(unittest.TestCase):
|
|||||||
|
|
||||||
#def testText(self):
|
#def testText(self):
|
||||||
# "Test getting the window Text of the dialog"
|
# "Test getting the window Text of the dialog"
|
||||||
# self.assertEquals(self.dlg.Text(), "Untitled - Notepad")
|
# self.assertEquals(self.dlg.WindowText(), "Untitled - Notepad")
|
||||||
|
|
||||||
def testText(self):
|
def testText(self):
|
||||||
"Test getting the window Text of the dialog"
|
"Test getting the window Text of the dialog"
|
||||||
self.assertEquals(self.dlg.Text(), "test.txt - Notepad")
|
self.assertEquals(self.dlg.WindowText(), "test.txt - Notepad")
|
||||||
|
|
||||||
def testClass(self):
|
def testClass(self):
|
||||||
"Test getting the classname of the dialog"
|
"Test getting the classname of the dialog"
|
||||||
@ -119,13 +119,13 @@ class HwndWrapperTests(unittest.TestCase):
|
|||||||
def testGetProperties(self):
|
def testGetProperties(self):
|
||||||
"Test getting the properties for the control"
|
"Test getting the properties for the control"
|
||||||
props = self.dlg.GetProperties()
|
props = self.dlg.GetProperties()
|
||||||
|
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
self.dlg.FriendlyClassName(), props['FriendlyClassName'])
|
self.dlg.FriendlyClassName(), props['FriendlyClassName'])
|
||||||
|
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
self.dlg.Texts(), props['Texts'])
|
self.dlg.Texts(), props['Texts'])
|
||||||
|
|
||||||
for prop_name in props:
|
for prop_name in props:
|
||||||
self.assertEquals(getattr(self.dlg, prop_name)(), props[prop_name])
|
self.assertEquals(getattr(self.dlg, prop_name)(), props[prop_name])
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ class ButtonTestCases(unittest.TestCase):
|
|||||||
from pywinauto.controls import WrapHandle
|
from pywinauto.controls import WrapHandle
|
||||||
|
|
||||||
children = self.calc.Children()
|
children = self.calc.Children()
|
||||||
no_text_buttons = [c for c in children if not c.Text() and c.Class() == "Button"]
|
no_text_buttons = [c for c in children if not c.WindowText() and c.Class() == "Button"]
|
||||||
|
|
||||||
first_group = no_text_buttons[0]
|
first_group = no_text_buttons[0]
|
||||||
|
|
||||||
@ -309,7 +309,7 @@ class EditTestCases(unittest.TestCase):
|
|||||||
|
|
||||||
def testSetText(self):
|
def testSetText(self):
|
||||||
"Test setting the text of the edit control"
|
"Test setting the text of the edit control"
|
||||||
self.ctrl.SetText("Here is\r\nsome text")
|
self.ctrl.SetEditText("Here is\r\nsome text")
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
"\n".join(self.ctrl.Texts()[1:]), "Here is\nsome text")
|
"\n".join(self.ctrl.Texts()[1:]), "Here is\nsome text")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user