2018-01-26 11:07:09 +00:00
|
|
|
import time
|
|
|
|
from tests import info
|
2018-01-14 17:43:36 +00:00
|
|
|
from views.base_element import BaseText, BaseButton, BaseEditBox
|
2018-01-03 09:34:40 +00:00
|
|
|
from views.base_view import BaseView
|
2017-08-28 10:02:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
class PublicKeyText(BaseText):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(PublicKeyText, self).__init__(driver)
|
2017-09-11 10:43:42 +00:00
|
|
|
self.locator = self.Locator.accessibility_id('profile-public-key')
|
2017-08-28 10:02:20 +00:00
|
|
|
|
2017-10-11 20:10:57 +00:00
|
|
|
@property
|
|
|
|
def text(self):
|
|
|
|
text = self.scroll_to_element().text
|
2018-01-26 11:07:09 +00:00
|
|
|
info('%s is %s' % (self.name, text))
|
2017-10-11 20:10:57 +00:00
|
|
|
return text
|
|
|
|
|
2017-08-28 10:02:20 +00:00
|
|
|
|
2017-09-21 17:01:04 +00:00
|
|
|
class ProfileAddressText(BaseText):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ProfileAddressText, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.accessibility_id('profile-address')
|
|
|
|
|
|
|
|
|
2017-10-30 11:11:58 +00:00
|
|
|
class OptionsButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(OptionsButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector(
|
|
|
|
'(//android.view.ViewGroup[@content-desc="icon"])[2]')
|
|
|
|
|
|
|
|
class UserStatusBox(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(OptionsButton.UserStatusBox, self).__init__(driver)
|
2018-01-26 11:07:09 +00:00
|
|
|
self.locator = self.Locator.xpath_selector('(//android.widget.ScrollView)[2]//android.widget.TextView')
|
2017-10-30 11:11:58 +00:00
|
|
|
|
|
|
|
class UsernameInput(BaseEditBox):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(OptionsButton.UsernameInput, self).__init__(driver)
|
2018-01-26 11:07:09 +00:00
|
|
|
self.locator = self.Locator.xpath_selector('//android.widget.EditText')
|
2017-10-30 11:11:58 +00:00
|
|
|
|
|
|
|
class UserStatusInput(BaseEditBox):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(OptionsButton.UserStatusInput, self).__init__(driver)
|
2018-01-26 11:07:09 +00:00
|
|
|
self.locator = self.Locator.xpath_selector('(//android.widget.EditText)[2]')
|
2017-10-30 11:11:58 +00:00
|
|
|
|
|
|
|
|
2017-10-11 20:10:57 +00:00
|
|
|
class NetworkSettingsButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(NetworkSettingsButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('//*[@text="Network settings"]')
|
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
class NetworkButton(BaseButton):
|
|
|
|
def __init__(self, driver, network):
|
|
|
|
super(NetworkSettingsButton.NetworkButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('//*[@text="' + network + '"]')
|
2017-10-11 20:10:57 +00:00
|
|
|
|
|
|
|
class ConnectButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(NetworkSettingsButton.ConnectButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('//*[@text="CONNECT"]')
|
|
|
|
|
|
|
|
|
2018-01-14 17:43:36 +00:00
|
|
|
class LogoutButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(LogoutButton, self).__init__(driver)
|
2018-01-26 11:07:09 +00:00
|
|
|
self.locator = self.Locator.xpath_selector('//*[@text="Log out"]')
|
2018-01-14 17:43:36 +00:00
|
|
|
|
|
|
|
def click(self):
|
|
|
|
self.scroll_to_element()
|
2018-01-26 11:07:09 +00:00
|
|
|
for _ in range(2):
|
|
|
|
self.find_element().click()
|
|
|
|
time.sleep(2)
|
|
|
|
info('Tap on %s' % self.name)
|
2018-01-14 17:43:36 +00:00
|
|
|
from views.sign_in_view import SignInView
|
|
|
|
return SignInView(self.driver)
|
|
|
|
|
|
|
|
|
2018-01-26 11:07:09 +00:00
|
|
|
class ShareMyContactKeyButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ShareMyContactKeyButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('//*[@text="SHARE MY CONTACT CODE"]')
|
|
|
|
|
|
|
|
|
|
|
|
class EditButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(EditButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('//*[@text="EDIT"]')
|
|
|
|
|
|
|
|
|
|
|
|
class ConfirmButton(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(ConfirmButton, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector('(//android.view.ViewGroup[@content-desc="icon"])[1]')
|
|
|
|
|
|
|
|
|
|
|
|
class CrossIcon(BaseButton):
|
|
|
|
|
|
|
|
def __init__(self, driver):
|
|
|
|
super(CrossIcon, self).__init__(driver)
|
|
|
|
self.locator = self.Locator.xpath_selector(
|
|
|
|
'(// android.view.ViewGroup[@ content-desc="icon"])[1]/android.view.View')
|
|
|
|
|
|
|
|
|
2018-01-03 09:34:40 +00:00
|
|
|
class ProfileView(BaseView):
|
2017-08-28 10:02:20 +00:00
|
|
|
|
|
|
|
def __init__(self, driver):
|
2018-01-03 09:34:40 +00:00
|
|
|
super(ProfileView, self).__init__(driver)
|
2017-08-28 10:02:20 +00:00
|
|
|
self.driver = driver
|
|
|
|
|
2018-01-26 11:07:09 +00:00
|
|
|
# old design
|
2017-10-30 11:11:58 +00:00
|
|
|
self.options_button = OptionsButton(self.driver)
|
|
|
|
self.username_input = OptionsButton.UsernameInput(self.driver)
|
|
|
|
self.user_status_box = OptionsButton.UserStatusBox(self.driver)
|
|
|
|
self.user_status_input = OptionsButton.UserStatusInput(self.driver)
|
2017-08-28 10:02:20 +00:00
|
|
|
self.public_key_text = PublicKeyText(self.driver)
|
2017-09-21 17:01:04 +00:00
|
|
|
self.profile_address_text = ProfileAddressText(self.driver)
|
2017-10-11 20:10:57 +00:00
|
|
|
|
|
|
|
self.network_settings_button = NetworkSettingsButton(self.driver)
|
|
|
|
self.connect_button = NetworkSettingsButton.ConnectButton(self.driver)
|
2018-01-14 17:43:36 +00:00
|
|
|
self.logout_button = LogoutButton(self.driver)
|
2017-10-11 20:10:57 +00:00
|
|
|
|
2018-01-26 11:07:09 +00:00
|
|
|
# new design
|
|
|
|
|
|
|
|
self.share_my_contact_key_button = ShareMyContactKeyButton(self.driver)
|
|
|
|
self.edit_button = EditButton(self.driver)
|
|
|
|
self.confirm_button = ConfirmButton(self.driver)
|
|
|
|
self.cross_icon = CrossIcon(self.driver)
|
|
|
|
|
2017-10-11 20:10:57 +00:00
|
|
|
def switch_network(self, network):
|
|
|
|
self.network_settings_button.scroll_to_element()
|
|
|
|
self.network_settings_button.click()
|
2018-01-03 09:34:40 +00:00
|
|
|
network_button = NetworkSettingsButton.NetworkButton(self.driver, network)
|
|
|
|
network_button.click()
|
2017-10-11 20:10:57 +00:00
|
|
|
self.connect_button.click()
|
2018-01-03 09:34:40 +00:00
|
|
|
from views.sign_in_view import SignInView
|
|
|
|
return SignInView(self.driver)
|
2018-01-26 11:07:09 +00:00
|
|
|
|
|
|
|
def get_address(self):
|
|
|
|
profile_view = self.profile_button.click()
|
|
|
|
return profile_view.profile_address_text.text
|