Skip to content

Commit

Permalink
Merge pull request pywinauto#439 from airelil/uia_ctl_name
Browse files Browse the repository at this point in the history
 uia_element_info: on error return empty string for name and class_name
  • Loading branch information
vasily-v-ryabov authored Nov 9, 2017
2 parents c29bc98 + 1ba2887 commit e692975
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pywinauto/uia_element_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"""Implementation of the class to deal with an UI element (based on UI Automation API)"""

from comtypes import COMError
from six import integer_types
from six import integer_types, text_type

from .uia_defines import IUIA
from .uia_defines import get_elem_interface
Expand Down Expand Up @@ -81,9 +81,10 @@ def __init__(self, handle_or_elem = None, cache_enable = False):
def _get_current_class_name(self):
"""Return an actual class name of the element"""
try:
return self._element.CurrentClassName
cn = self._element.CurrentClassName
return text_type('') if cn is None else cn
except COMError:
return None # probably element already doesn't exist
return text_type('') # probably element already doesn't exist

def _get_cached_class_name(self):
"""Return a cached class name of the element"""
Expand Down Expand Up @@ -120,9 +121,10 @@ def _get_cached_control_type(self):
def _get_current_name(self):
"""Return an actual name of the element"""
try:
return self._element.CurrentName
n = self._element.CurrentName
return text_type('') if n is None else n
except COMError:
return None # probably element already doesn't exist
return text_type('') # probably element already doesn't exist

def _get_cached_name(self):
"""Return a cached name of the element"""
Expand Down

0 comments on commit e692975

Please sign in to comment.