2019-04-05 13:05:23 +00:00
|
|
|
from views.base_element import BaseButton, BaseEditBox
|
|
|
|
from views.base_view import BaseView
|
|
|
|
from views.home_view import ChatElement
|
|
|
|
|
|
|
|
|
2019-10-03 18:33:36 +00:00
|
|
|
|
2019-04-05 13:05:23 +00:00
|
|
|
class OpenDAppButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(OpenDAppButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('open-dapp-button')
|
|
|
|
|
|
|
|
|
|
|
|
class OpenButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(OpenButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('open-dapp-button')
|
|
|
|
|
|
|
|
def navigate(self):
|
|
|
|
from views.web_views.base_web_view import BaseWebView
|
|
|
|
return BaseWebView(self.driver)
|
|
|
|
|
|
|
|
|
|
|
|
class EnterUrlEditbox(BaseEditBox):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(EnterUrlEditbox, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('dapp-url-input')
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2019-09-24 08:50:21 +00:00
|
|
|
class RemoveDappButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(RemoveDappButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('remove-dapp-from-list')
|
|
|
|
|
2019-10-03 18:33:36 +00:00
|
|
|
|
2019-09-24 08:50:21 +00:00
|
|
|
class ClearAllDappButton(BaseButton):
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ClearAllDappButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('clear-all-dapps')
|
|
|
|
|
2019-10-03 18:33:36 +00:00
|
|
|
|
2019-04-05 13:05:23 +00:00
|
|
|
class DappsView(BaseView):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(DappsView, self).__init__(driver)
|
|
|
|
|
|
|
|
self.open_d_app_button = OpenDAppButton(self.driver)
|
|
|
|
self.open_button = OpenButton(self.driver)
|
|
|
|
self.enter_url_editbox = EnterUrlEditbox(self.driver)
|
|
|
|
|
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
|
|
|
|
self.remove_d_app_button = RemoveDappButton(self.driver)
|
|
|
|
self.clear_all_d_app_button = ClearAllDappButton(self.driver)
|
|
|
|
|
|
|
|
|
2019-04-05 13:05:23 +00:00
|
|
|
def open_url(self, url):
|
|
|
|
self.enter_url_editbox.click()
|
|
|
|
self.enter_url_editbox.send_keys(url)
|
|
|
|
self.confirm()
|
|
|
|
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
|
|
|
|
|
|
|
def remove_browser_entry_long_press(self, name, clear_all=False):
|
|
|
|
entry = self.get_browser_entry(name)
|
|
|
|
entry.scroll_to_element()
|
|
|
|
entry.long_press_element()
|
|
|
|
self.clear_all_d_app_button if clear_all else self.remove_d_app_button.click()
|
|
|
|
return entry
|