2018-08-01 00:16:33 +00:00
|
|
|
import time
|
2018-02-07 13:18:55 +00:00
|
|
|
import pytest
|
2017-10-05 19:41:17 +00:00
|
|
|
|
2018-09-05 19:50:48 +00:00
|
|
|
from views.base_element import BaseElement, BaseEditBox, BaseButton, BaseText
|
2018-08-01 00:16:33 +00:00
|
|
|
from views.base_view import BaseView
|
|
|
|
|
2017-10-05 19:41:17 +00:00
|
|
|
|
|
|
|
class ProgressBarIcon(BaseElement):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ProgressBarIcon, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.ProgressBar")
|
|
|
|
|
|
|
|
|
2020-12-11 17:06:40 +00:00
|
|
|
class CloseTabButton(BaseElement):
|
|
|
|
def __init__(self, driver, name):
|
|
|
|
super(CloseTabButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[contains(@text, '%s')]/../../../../*[@content-desc='empty-tab']"
|
|
|
|
% name)
|
|
|
|
|
2018-08-01 00:16:33 +00:00
|
|
|
class WebLinkEditBox(BaseEditBox):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(WebLinkEditBox, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//android.widget.EditText")
|
|
|
|
|
|
|
|
|
2018-02-13 17:22:41 +00:00
|
|
|
class BackToHomeButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(BackToHomeButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('(//android.view.ViewGroup[@content-desc="icon"])[1]')
|
|
|
|
|
|
|
|
|
2018-04-27 10:13:29 +00:00
|
|
|
class BrowserPreviousPageButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(BrowserPreviousPageButton, self).__init__(driver)
|
2018-09-24 16:22:55 +00:00
|
|
|
self.locator = self.Locator.accessibility_id('previous-page-button')
|
2018-04-27 10:13:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
class BrowserNextPageButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(BrowserNextPageButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('next-page-button')
|
|
|
|
|
|
|
|
|
2018-07-22 13:38:01 +00:00
|
|
|
class BrowserRefreshPageButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(BrowserRefreshPageButton, self).__init__(driver)
|
2018-09-25 17:12:47 +00:00
|
|
|
self.locator = self.Locator.accessibility_id('refresh-page-button')
|
2018-07-22 13:38:01 +00:00
|
|
|
|
|
|
|
|
2018-04-23 18:42:12 +00:00
|
|
|
class WebViewBrowserButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(WebViewBrowserButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.text_part_selector('WebView Browser Tester')
|
|
|
|
|
|
|
|
|
|
|
|
class AlwaysButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(AlwaysButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.text_part_selector('ALWAYS')
|
|
|
|
|
2018-04-27 10:13:29 +00:00
|
|
|
|
2018-10-04 17:44:08 +00:00
|
|
|
class WebViewMenuButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(WebViewMenuButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('chat-menu-button')
|
|
|
|
|
|
|
|
|
2020-05-15 15:59:40 +00:00
|
|
|
class URLEditBoxLockIcon(BaseButton):
|
2018-08-02 10:11:45 +00:00
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(URLEditBoxLockIcon, self).__init__(driver)
|
2019-03-05 07:59:20 +00:00
|
|
|
self.locator = self.Locator.xpath_selector('(//android.view.ViewGroup[@content-desc="icon"])[2]')
|
2018-08-02 10:11:45 +00:00
|
|
|
|
|
|
|
|
2018-09-05 19:50:48 +00:00
|
|
|
class PolicySummary(BaseElement):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(PolicySummary, self).__init__(driver)
|
2018-10-08 13:10:00 +00:00
|
|
|
self.locator = self.Locator.xpath_selector('//*[@content-desc="Policy summary"] | //*[@text="Policy summary"]')
|
2018-09-05 19:50:48 +00:00
|
|
|
|
|
|
|
|
2020-05-20 15:43:29 +00:00
|
|
|
class ShareUrlButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ShareUrlButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('modal-share-link-button')
|
|
|
|
|
|
|
|
|
2020-07-02 16:02:53 +00:00
|
|
|
class GoBackButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(GoBackButton, self).__init__(driver)
|
2020-12-11 17:06:40 +00:00
|
|
|
self.locator = self.Locator.translation_id_selector('browsing-site-blocked-go-back')
|
2020-07-02 16:02:53 +00:00
|
|
|
|
2020-12-11 17:06:40 +00:00
|
|
|
class OpenTabsButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(OpenTabsButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('browser-open-tabs')
|
|
|
|
|
|
|
|
class CloseAllButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(CloseAllButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('close-all')
|
2020-07-02 16:02:53 +00:00
|
|
|
|
|
|
|
class ContinueAnywayButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ContinueAnywayButton, self).__init__(driver)
|
2020-12-11 17:06:40 +00:00
|
|
|
self.locator = self.Locator.translation_id_selector("continue-anyway")
|
2020-07-02 16:02:53 +00:00
|
|
|
|
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
class BaseWebView(BaseView):
|
2017-10-05 19:41:17 +00:00
|
|
|
|
|
|
|
def __init__(self, driver):
|
2018-01-03 09:34:40 +00:00
|
|
|
super(BaseWebView, self).__init__(driver)
|
2017-10-05 19:41:17 +00:00
|
|
|
self.driver = driver
|
|
|
|
|
|
|
|
self.progress_bar_icon = ProgressBarIcon(self.driver)
|
|
|
|
|
2018-08-02 10:11:45 +00:00
|
|
|
self.url_edit_box_lock_icon = URLEditBoxLockIcon(self.driver)
|
2018-09-05 19:50:48 +00:00
|
|
|
self.policy_summary = PolicySummary(self.driver)
|
2018-02-13 17:22:41 +00:00
|
|
|
self.back_to_home_button = BackToHomeButton(self.driver)
|
2018-04-27 10:13:29 +00:00
|
|
|
self.browser_previous_page_button = BrowserPreviousPageButton(self.driver)
|
|
|
|
self.browser_next_page_button = BrowserNextPageButton(self.driver)
|
2018-02-13 17:22:41 +00:00
|
|
|
|
2018-04-23 18:42:12 +00:00
|
|
|
self.web_view_browser = WebViewBrowserButton(self.driver)
|
2018-10-04 17:44:08 +00:00
|
|
|
self.web_view_menu_button = WebViewMenuButton(self.driver)
|
2018-04-23 18:42:12 +00:00
|
|
|
self.always_button = AlwaysButton(self.driver)
|
2018-07-22 13:38:01 +00:00
|
|
|
self.browser_refresh_page_button = BrowserRefreshPageButton(self.driver)
|
2020-05-20 15:43:29 +00:00
|
|
|
self.share_url_button = ShareUrlButton(self.driver)
|
2020-07-02 16:02:53 +00:00
|
|
|
self.go_back_button = GoBackButton(self.driver)
|
|
|
|
self.continue_anyway_button = ContinueAnywayButton(self.driver)
|
2020-12-11 17:06:40 +00:00
|
|
|
self.open_tabs_button = OpenTabsButton(self.driver)
|
|
|
|
self.close_all_button = CloseAllButton(self.driver)
|
2018-04-23 18:42:12 +00:00
|
|
|
|
2018-02-07 13:18:55 +00:00
|
|
|
def wait_for_d_aap_to_load(self, wait_time=35):
|
2017-10-05 19:41:17 +00:00
|
|
|
counter = 0
|
|
|
|
while self.progress_bar_icon.is_element_present(5):
|
|
|
|
time.sleep(1)
|
|
|
|
counter += 1
|
|
|
|
if counter > wait_time:
|
2018-08-15 12:51:52 +00:00
|
|
|
self.driver.fail("Page is not loaded during %s seconds" % wait_time)
|
2018-07-06 11:10:48 +00:00
|
|
|
|
|
|
|
def open_in_webview(self):
|
2020-01-21 13:59:01 +00:00
|
|
|
if self.web_view_browser.is_element_displayed():
|
|
|
|
self.web_view_browser.click()
|
2018-10-08 13:10:00 +00:00
|
|
|
if self.always_button.is_element_displayed():
|
|
|
|
self.always_button.click()
|
2020-01-21 13:59:01 +00:00
|
|
|
|
2020-12-11 17:06:40 +00:00
|
|
|
def remove_tab(self, name='', clear_all=False):
|
|
|
|
self.open_tabs_button.click()
|
|
|
|
if clear_all:
|
|
|
|
self.close_all_button.click()
|
|
|
|
else:
|
|
|
|
close_button = CloseTabButton(self.driver, name)
|
|
|
|
close_button.scroll_to_element()
|
|
|
|
close_button.click()
|
|
|
|
|