2021-01-25 16:35:40 +00:00
|
|
|
from views.base_element import Button, EditBox, BaseElement
|
2022-06-22 14:09:04 +00:00
|
|
|
from views.base_view import BaseView, CheckBox, Text
|
2019-04-05 13:05:23 +00:00
|
|
|
from views.home_view import ChatElement
|
|
|
|
|
2021-11-18 15:16:48 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class DiscoverDappsButton(Button):
|
2019-04-05 13:05:23 +00:00
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, translation_id="open-dapp-store")
|
2019-04-05 13:05:23 +00:00
|
|
|
|
|
|
|
def navigate(self):
|
|
|
|
from views.web_views.base_web_view import BaseWebView
|
|
|
|
return BaseWebView(self.driver)
|
|
|
|
|
2019-10-21 07:15:34 +00:00
|
|
|
def click(self):
|
2021-01-25 16:35:40 +00:00
|
|
|
from views.web_views.base_web_view import BaseWebView
|
|
|
|
self.click_until_presence_of_element(BaseWebView(self.driver).browser_refresh_page_button)
|
2019-10-21 07:15:34 +00:00
|
|
|
return self.navigate()
|
|
|
|
|
2021-11-18 15:16:48 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
class EditUrlEditbox(EditBox):
|
2019-04-05 13:05:23 +00:00
|
|
|
def __init__(self, driver):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, xpath="(//android.widget.TextView)[1]")
|
2020-06-10 08:14:57 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def text(self):
|
|
|
|
return self.find_element().text
|
|
|
|
|
2019-04-05 13:05:23 +00:00
|
|
|
|
|
|
|
class BrowserEntry(ChatElement):
|
|
|
|
def __init__(self, driver, name):
|
2021-01-25 16:35:40 +00:00
|
|
|
super().__init__(driver, name)
|
|
|
|
self.locator = "//*[contains(@content-desc,'%s')]" % name
|
2020-05-08 13:36:05 +00:00
|
|
|
|
|
|
|
|
2019-04-05 13:05:23 +00:00
|
|
|
class DappsView(BaseView):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(DappsView, self).__init__(driver)
|
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
self.enter_url_editbox = EditBox(self.driver, accessibility_id="dapp-url-input")
|
2020-06-10 08:14:57 +00:00
|
|
|
self.edit_url_editbox = EditUrlEditbox(self.driver)
|
2019-10-21 07:15:34 +00:00
|
|
|
self.discover_dapps_button = DiscoverDappsButton(self.driver)
|
2021-01-25 16:35:40 +00:00
|
|
|
self.web_page = BaseElement(self.driver, xpath="(//android.webkit.WebView)[1]")
|
2019-04-05 13:05:23 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
# Ens dapp
|
2022-06-22 14:09:04 +00:00
|
|
|
self.get_started_ens = Button(self.driver, translation_id="get-started")
|
2021-01-25 16:35:40 +00:00
|
|
|
self.ens_name_input = EditBox(self.driver, xpath="//android.widget.EditText")
|
2021-06-14 17:52:58 +00:00
|
|
|
self.check_ens_name = Button(self.driver, xpath="(//android.widget.ImageView[@content-desc='icon'])[2]/../..")
|
2022-06-22 14:09:04 +00:00
|
|
|
self.agree_on_terms_ens = CheckBox(self.driver, accessibility_id=":checkbox-off")
|
|
|
|
self.register_ens_button = Button(self.driver, translation_id="ens-register")
|
|
|
|
self.ens_got_it = Button(self.driver, translation_id="ens-got-it")
|
|
|
|
self.registration_in_progress = Text(self.driver, translation_id="ens-registration-in-progress")
|
2019-08-02 09:28:59 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
# Options on long press
|
|
|
|
self.delete_bookmark_button = Button(self.driver, accessibility_id="delete-bookmark")
|
|
|
|
self.open_in_new_tab_button = Button(self.driver, accessibility_id="open-in-new-tab")
|
|
|
|
self.edit_bookmark_button = Button(self.driver, accessibility_id="edit-bookmark")
|
2019-09-24 08:50:21 +00:00
|
|
|
|
2021-01-25 16:35:40 +00:00
|
|
|
# Select account
|
|
|
|
self.select_account_button = Button(self.driver, accessibility_id="select-account")
|
2019-10-18 13:23:36 +00:00
|
|
|
|
2019-04-05 13:05:23 +00:00
|
|
|
def open_url(self, url):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("Open url '%s'" % url)
|
2022-01-14 16:51:54 +00:00
|
|
|
from views.web_views.base_web_view import BaseWebView
|
|
|
|
web_view = BaseWebView(self.driver)
|
|
|
|
if not self.enter_url_editbox.is_element_displayed():
|
2022-03-14 16:16:26 +00:00
|
|
|
web_view.open_tabs_button.click_if_shown()
|
|
|
|
web_view.open_new_tab_plus_button.click_if_shown()
|
2022-01-14 16:51:54 +00:00
|
|
|
self.enter_url_editbox.wait_for_visibility_of_element(20)
|
2019-04-05 13:05:23 +00:00
|
|
|
self.enter_url_editbox.click()
|
2022-03-22 16:37:47 +00:00
|
|
|
self.enter_url_editbox.set_value(url)
|
2019-04-05 13:05:23 +00:00
|
|
|
self.confirm()
|
2021-04-30 14:11:52 +00:00
|
|
|
from views.web_views.base_web_view import BaseWebView
|
|
|
|
BaseWebView(self.driver).wait_for_d_aap_to_load()
|
2019-04-05 13:05:23 +00:00
|
|
|
return self.get_base_web_view()
|
|
|
|
|
|
|
|
def get_browser_entry(self, name):
|
|
|
|
return BrowserEntry(self.driver, name)
|
2019-09-24 08:50:21 +00:00
|
|
|
|
2020-12-21 13:06:48 +00:00
|
|
|
def browser_entry_long_press(self, name):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("Long press on '%s' browser entry" % name)
|
2019-09-24 08:50:21 +00:00
|
|
|
entry = self.get_browser_entry(name)
|
|
|
|
entry.scroll_to_element()
|
|
|
|
entry.long_press_element()
|
|
|
|
return entry
|
2019-10-18 13:23:36 +00:00
|
|
|
|
2020-11-11 15:37:27 +00:00
|
|
|
def select_account_by_name(self, account_name=''):
|
|
|
|
account_name = self.status_account_name if not account_name else account_name
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("Select account by '%s'" % account_name)
|
2021-01-25 16:35:40 +00:00
|
|
|
return Button(self.driver,
|
|
|
|
xpath="//*[@text='%s']/../../android.view.ViewGroup/android.view.ViewGroup[2]" % account_name)
|
2019-11-25 10:32:30 +00:00
|
|
|
|
|
|
|
def set_primary_ens_username(self, ens_name):
|
2021-10-25 16:05:22 +00:00
|
|
|
self.driver.info("Set '%s' as primary ENS name" % ens_name)
|
2021-01-25 16:35:40 +00:00
|
|
|
return Button(self.driver, accessibility_id="not-primary-username")
|