Merge pull request #1023 from deajan/findElement-allow-none

Allow to silently skip no found elements
This commit is contained in:
MikeTheWatchGuy 2019-01-03 08:37:57 -05:00 committed by GitHub
commit de26da647b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 7 deletions

View File

@ -3735,15 +3735,18 @@ class Window:
FillFormWithValues(self, values_dict)
return self
def FindElement(self, key):
def FindElement(self, key, silent_on_error=None):
element = _FindElementFromKeyInSubForm(self, key)
if element is None:
print('*** WARNING = FindElement did not find the key. Please check your key\'s spelling ***')
PopupError('Keyword error in FindElement Call',
'Bad key = {}'.format(key),
'Your bad line of code may resemble this:',
'window.FindElement("{}")'.format(key))
return ErrorElement(key=key)
if not silent_on_error == True:
print('*** WARNING = FindElement did not find the key. Please check your key\'s spelling ***')
PopupError('Keyword error in FindElement Call',
'Bad key = {}'.format(key),
'Your bad line of code may resemble this:',
'window.FindElement("{}")'.format(key))
return ErrorElement(key=key)
else:
return False
return element
Element = FindElement # Shortcut function