Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ v2.5.1

- Update map_param method to allow recursive replacements
- Update replace_param function to allow multiple date expressions in the same param
- Fix error message to show parent locator instead of object reference when an element is not found

v2.5.0
------
Expand Down
17 changes: 15 additions & 2 deletions toolium/pageelements/page_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def web_element(self):
try:
self._find_web_element()
except NoSuchElementException as exception:
parent_msg = " and parent locator '{}'".format(self.parent) if self.parent else ''
parent_msg = f" and parent locator {self.parent_locator_str()}" if self.parent else ''
msg = "Page element of type '%s' with locator %s%s not found"
self.logger.error(msg, type(self).__name__, self.locator, parent_msg)
exception.msg += "\n {}".format(msg % (type(self).__name__, self.locator, parent_msg))
Expand Down Expand Up @@ -169,6 +169,19 @@ def _ios_automatic_context_selection(self):
if self.driver.context != PageElement.native_context:
self.driver.switch_to.context(PageElement.native_context)

def parent_locator_str(self):
"""Return string with locator tuple for parent element

:returns: parent element locator
"""
if isinstance(self.parent, PageElement):
parent_locator = str(self.parent.locator)
elif isinstance(self.parent, tuple):
parent_locator = str(self.parent)
else:
parent_locator = '[WebElement without locator]'
return parent_locator

def scroll_element_into_view(self):
"""Scroll element into view

Expand Down Expand Up @@ -218,7 +231,7 @@ def _wait_until_condition(self, condition, timeout=None):
condition_msg = 'not found or is not clickable'
self.utils.wait_until_element_clickable(self, timeout)
except TimeoutException as exception:
parent_msg = " and parent locator '{}'".format(self.parent) if self.parent else ''
parent_msg = f" and parent locator {self.parent_locator_str()}" if self.parent else ''
timeout = timeout if timeout else self.utils.get_explicitly_wait()
msg = "Page element of type '%s' with locator %s%s %s after %s seconds"
msg = msg % (type(self).__name__, self.locator, parent_msg, condition_msg, timeout)
Expand Down