2020-05-08 13:36:05 +00:00
|
|
|
from views.base_element import BaseButton, BaseEditBox, BaseElement
|
2019-04-05 13:05:23 +00:00
|
|
|
from views.base_view import BaseView
|
|
|
|
from views.home_view import ChatElement
|
|
|
|
|
2019-10-21 07:15:34 +00:00
|
|
|
class DiscoverDappsButton(BaseButton):
|
2019-04-05 13:05:23 +00:00
|
|
|
def __init__(self, driver):
|
2019-10-21 07:15:34 +00:00
|
|
|
super(DiscoverDappsButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.text_selector('Discover ÐApps')
|
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):
|
|
|
|
from views.web_views.base_web_view import BrowserRefreshPageButton
|
|
|
|
self.click_until_presence_of_element(BrowserRefreshPageButton(self.driver))
|
|
|
|
return self.navigate()
|
|
|
|
|
2019-04-05 13:05:23 +00:00
|
|
|
|
|
|
|
class EnterUrlEditbox(BaseEditBox):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(EnterUrlEditbox, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('dapp-url-input')
|
|
|
|
|
2020-06-10 08:14:57 +00:00
|
|
|
class EditUrlEditbox(BaseEditBox):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(EditUrlEditbox, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('(//android.widget.TextView)[1]')
|
|
|
|
|
|
|
|
@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):
|
|
|
|
super(BrowserEntry, self).__init__(driver, name)
|
2019-10-14 10:14:10 +00:00
|
|
|
self.locator = self.locator.text_part_selector(name)
|
2019-04-05 13:05:23 +00:00
|
|
|
|
2019-10-03 18:33:36 +00:00
|
|
|
|
2019-08-02 09:28:59 +00:00
|
|
|
class EnsName(BaseEditBox):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(EnsName, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('//android.widget.EditText')
|
|
|
|
|
2019-10-03 18:33:36 +00:00
|
|
|
|
2019-08-02 09:28:59 +00:00
|
|
|
class EnsCheckName(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(EnsCheckName, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('//android.widget.EditText//following-sibling::android.view.ViewGroup[1]')
|
2019-04-05 13:05:23 +00:00
|
|
|
|
2019-10-03 18:33:36 +00:00
|
|
|
|
2020-12-21 13:06:48 +00:00
|
|
|
class DeleteBookmarkButton(BaseButton):
|
2019-09-24 08:50:21 +00:00
|
|
|
def __init__(self, driver):
|
2020-12-21 13:06:48 +00:00
|
|
|
super(DeleteBookmarkButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('delete-bookmark')
|
2019-09-24 08:50:21 +00:00
|
|
|
|
2019-10-03 18:33:36 +00:00
|
|
|
|
2020-12-21 13:06:48 +00:00
|
|
|
class EditBookmarkButton(BaseButton):
|
2019-09-24 08:50:21 +00:00
|
|
|
def __init__(self, driver):
|
2020-12-21 13:06:48 +00:00
|
|
|
super(EditBookmarkButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('edit-bookmark')
|
|
|
|
|
|
|
|
|
|
|
|
class OpenInNewTabButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(OpenInNewTabButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('open-in-new-tab')
|
2019-09-24 08:50:21 +00:00
|
|
|
|
2019-10-18 13:23:36 +00:00
|
|
|
class SelectAccountButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(SelectAccountButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('select-account')
|
|
|
|
|
|
|
|
class SelectAccountRadioButton(BaseButton):
|
|
|
|
def __init__(self, driver, account_name):
|
|
|
|
super(SelectAccountRadioButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='%s']/../../android.view.ViewGroup/android.view.ViewGroup[2]" % account_name)
|
|
|
|
|
2019-11-25 10:32:30 +00:00
|
|
|
class SetPrimaryUsername(BaseButton):
|
2020-07-08 14:28:54 +00:00
|
|
|
def __init__(self, driver):
|
2019-11-25 10:32:30 +00:00
|
|
|
super(SetPrimaryUsername, self).__init__(driver)
|
2020-07-08 14:28:54 +00:00
|
|
|
self.locator = self.Locator.accessibility_id('not-primary-username')
|
2019-11-25 10:32:30 +00:00
|
|
|
|
2019-10-18 13:23:36 +00:00
|
|
|
|
2019-10-21 12:48:45 +00:00
|
|
|
class AlwaysAllowRadioButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(AlwaysAllowRadioButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector("//*[@text='Always allow']/../android.view.ViewGroup")
|
|
|
|
|
|
|
|
|
|
|
|
class CrossCloseWeb3PermissionButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(CrossCloseWeb3PermissionButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector(
|
|
|
|
'//*[contains(@text,"ÐApps can access")]/../android.view.ViewGroup[1]/android.view.ViewGroup')
|
2019-10-03 18:33:36 +00:00
|
|
|
|
2020-05-08 13:36:05 +00:00
|
|
|
|
|
|
|
class WebViewPageElement(BaseElement):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(WebViewPageElement, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('(//android.webkit.WebView)[1]')
|
|
|
|
|
|
|
|
|
2019-04-05 13:05:23 +00:00
|
|
|
class DappsView(BaseView):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(DappsView, self).__init__(driver)
|
|
|
|
|
|
|
|
self.enter_url_editbox = EnterUrlEditbox(self.driver)
|
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)
|
2020-05-08 13:36:05 +00:00
|
|
|
self.web_page = WebViewPageElement(self.driver)
|
2019-04-05 13:05:23 +00:00
|
|
|
|
2019-08-02 09:28:59 +00:00
|
|
|
#ens dapp
|
|
|
|
self.ens_name = EnsName(self.driver)
|
|
|
|
self.check_ens_name = EnsCheckName(self.driver)
|
|
|
|
|
2019-09-24 08:50:21 +00:00
|
|
|
#options on long press
|
2020-12-21 13:06:48 +00:00
|
|
|
self.delete_bookmark_button = DeleteBookmarkButton(self.driver)
|
|
|
|
self.open_in_new_tab_button = OpenInNewTabButton(self.driver)
|
|
|
|
self.edit_bookmark_button = EditBookmarkButton(self.driver)
|
2019-09-24 08:50:21 +00:00
|
|
|
|
2019-10-18 13:23:36 +00:00
|
|
|
#select account
|
|
|
|
self.select_account_button = SelectAccountButton(self.driver)
|
|
|
|
self.select_account_radio_button = SelectAccountRadioButton(self.driver,
|
2020-11-11 15:37:27 +00:00
|
|
|
account_name=self.status_account_name)
|
2019-10-21 12:48:45 +00:00
|
|
|
#permissions window
|
|
|
|
self.always_allow_radio_button = AlwaysAllowRadioButton(self.driver)
|
|
|
|
self.close_web3_permissions_window_button = CrossCloseWeb3PermissionButton(self.driver)
|
2019-10-18 13:23:36 +00:00
|
|
|
|
2019-04-05 13:05:23 +00:00
|
|
|
def open_url(self, url):
|
2020-12-14 17:39:29 +00:00
|
|
|
self.enter_url_editbox.wait_for_visibility_of_element(10)
|
2019-04-05 13:05:23 +00:00
|
|
|
self.enter_url_editbox.click()
|
|
|
|
self.enter_url_editbox.send_keys(url)
|
|
|
|
self.confirm()
|
2020-10-14 12:09:01 +00:00
|
|
|
self.progress_bar.wait_for_invisibility_of_element(50)
|
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):
|
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
|
2019-10-18 13:23:36 +00:00
|
|
|
return SelectAccountRadioButton(self.driver, account_name)
|
2019-11-25 10:32:30 +00:00
|
|
|
|
|
|
|
def set_primary_ens_username(self, ens_name):
|
2020-07-08 14:28:54 +00:00
|
|
|
self.driver.info("Set {} as primary ENS name".format(ens_name))
|
|
|
|
return SetPrimaryUsername(self.driver)
|