status-react/test/appium/views/dapps_view.py

82 lines
3.3 KiB
Python
Raw Normal View History

from views.base_element import Button, EditBox, BaseElement
from views.base_view import BaseView
from views.home_view import ChatElement
class DiscoverDappsButton(Button):
def __init__(self, driver):
super().__init__(driver, translation_id="open-dapp-store")
def navigate(self):
from views.web_views.base_web_view import BaseWebView
return BaseWebView(self.driver)
def click(self):
from views.web_views.base_web_view import BaseWebView
self.click_until_presence_of_element(BaseWebView(self.driver).browser_refresh_page_button)
return self.navigate()
class EditUrlEditbox(EditBox):
def __init__(self, driver):
super().__init__(driver, xpath="(//android.widget.TextView)[1]")
@property
def text(self):
return self.find_element().text
class BrowserEntry(ChatElement):
def __init__(self, driver, name):
super().__init__(driver, name)
self.locator = "//*[contains(@content-desc,'%s')]" % name
class DappsView(BaseView):
def __init__(self, driver):
super(DappsView, self).__init__(driver)
self.enter_url_editbox = EditBox(self.driver, accessibility_id="dapp-url-input")
self.edit_url_editbox = EditUrlEditbox(self.driver)
self.discover_dapps_button = DiscoverDappsButton(self.driver)
self.web_page = BaseElement(self.driver, xpath="(//android.webkit.WebView)[1]")
# Ens dapp
self.ens_name_input = EditBox(self.driver, xpath="//android.widget.EditText")
self.check_ens_name = Button(self.driver, xpath="//android.widget.EditText//following-sibling::android.view.ViewGroup[1]")
# 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")
# Select account
self.select_account_button = Button(self.driver, accessibility_id="select-account")
def open_url(self, url):
self.driver.info("**Open url '%s'**" % url)
self.enter_url_editbox.wait_for_visibility_of_element(10)
self.enter_url_editbox.click()
self.enter_url_editbox.send_keys(url)
self.confirm()
self.progress_bar.wait_for_invisibility_of_element(50)
return self.get_base_web_view()
def get_browser_entry(self, name):
return BrowserEntry(self.driver, name)
def browser_entry_long_press(self, name):
self.driver.info("**Long press on '%s' browser entry**" % name)
entry = self.get_browser_entry(name)
entry.scroll_to_element()
entry.long_press_element()
return entry
def select_account_by_name(self, account_name=''):
account_name = self.status_account_name if not account_name else account_name
self.driver.info("**Select account by '%s'**" % account_name)
return Button(self.driver,
xpath="//*[@text='%s']/../../android.view.ViewGroup/android.view.ViewGroup[2]" % account_name)
def set_primary_ens_username(self, ens_name):
self.driver.info("**Set {} as primary ENS name**".format(ens_name))
return Button(self.driver, accessibility_id="not-primary-username")