Skip to content

Commit

Permalink
added test and new logic for iframes
Browse files Browse the repository at this point in the history
  • Loading branch information
hesteban-tuenti committed Nov 3, 2023
1 parent f9bc39c commit 4dfcc5c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion toolium/pageobjects/common_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ def utils(self):
def _android_automatic_context_selection(self):
"""Change context selection depending if the element is a webview for android devices"""
# we choose the appPackage webview context, and select the first window returned by mobile: getContexts
if self.webview:
if self.webview or (self.parent and self.parent.webview):
context = None
window_handle = None
if self.webview_context_selection_callback:
context, window_handle = self.webview_context_selection_callback(*self.webview_csc_args)
elif self.parent and self.parent.webview_context_selection_callback:
context, window_handle = self.parent.webview_context_selection_callback(*self.parent.webview_csc_args)
else:
app_web_context = "{}_{}".format(CommonObject.webview_context_prefix,
self.driver.capabilities['appPackage'])
Expand Down
18 changes: 18 additions & 0 deletions toolium/test/pageelements/test_page_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def init_page_elements(self):
self.inputs = PageElements(By.XPATH, '//input')
self.links = PageElements(By.XPATH, '//a')
self.inputs_with_parent = PageElements(By.XPATH, '//input', parent=(By.ID, 'parent'))
self.inputs_with_webview = PageElements(By.XPATH, '//input', webview=True)


@pytest.fixture
Expand Down Expand Up @@ -163,3 +164,20 @@ def test_reset_object(driver_wrapper):
assert len(login_page.links._web_elements) == 1
assert login_page.links._page_elements[0]._web_element is not None
assert page_element_21._web_element is not None

def test_get_page_elements_without_webview(driver_wrapper):
driver_wrapper.driver.find_elements.return_value = child_elements
page_elements = LoginPageObject().inputs.page_elements

# Check webview attribute is set to false by default in child elements
assert page_elements[0].webview == False
assert page_elements[1].webview == False

def test_get_page_elements_with_webview(driver_wrapper):
driver_wrapper.driver.find_elements.return_value = child_elements
page_elements = LoginPageObject().inputs_with_webview.page_elements

# Check webview attribute is set to true in child element when a Pagelements element
# is created with the webview attribute
assert page_elements[0].webview
assert page_elements[1].webview

0 comments on commit 4dfcc5c

Please sign in to comment.