2018-11-09 21:26:36 +00:00
|
|
|
try:
|
|
|
|
import org.sikuli.script.SikulixForJython
|
|
|
|
from sikuli import *
|
|
|
|
except Exception:
|
|
|
|
pass
|
2018-09-15 17:18:29 +00:00
|
|
|
import os
|
2018-11-16 09:53:05 +00:00
|
|
|
import logging
|
|
|
|
from views.base_element import BaseElement, InputField, TextElement
|
2018-09-15 17:18:29 +00:00
|
|
|
from views.base_view import BaseView
|
2018-10-23 14:49:29 +00:00
|
|
|
from views.home_view import HomeView
|
2018-09-15 17:18:29 +00:00
|
|
|
|
|
|
|
IMAGES_PATH = os.path.join(os.path.dirname(__file__), 'images/sign_in_view')
|
|
|
|
|
|
|
|
|
|
|
|
class CreateAccountButton(BaseElement):
|
|
|
|
def __init__(self):
|
|
|
|
super(CreateAccountButton, self).__init__(IMAGES_PATH + '/create_account.png')
|
|
|
|
|
2018-10-24 21:01:30 +00:00
|
|
|
def find_element(self, log=False):
|
2018-11-09 21:26:36 +00:00
|
|
|
from _pytest.runner import Failed
|
2018-10-23 14:49:29 +00:00
|
|
|
try:
|
2018-10-24 21:01:30 +00:00
|
|
|
super(CreateAccountButton, self).find_element(log=log)
|
2018-10-23 14:49:29 +00:00
|
|
|
except Failed:
|
|
|
|
self.screenshot = IMAGES_PATH + '/create_new_account.png'
|
2018-10-24 21:01:30 +00:00
|
|
|
super(CreateAccountButton, self).find_element(log=log)
|
2018-09-15 17:18:29 +00:00
|
|
|
|
|
|
|
|
2018-11-16 09:53:05 +00:00
|
|
|
class UserNameInput(InputField):
|
|
|
|
def __init__(self):
|
|
|
|
super(UserNameInput, self).__init__(IMAGES_PATH + '/username_input.png')
|
|
|
|
|
|
|
|
def input_value(self, value):
|
|
|
|
logging.info("%s field: set value '%s'" % (self.name, value))
|
|
|
|
import time
|
|
|
|
time.sleep(10)
|
|
|
|
type(value)
|
|
|
|
|
|
|
|
|
2018-09-15 17:18:29 +00:00
|
|
|
class SignInView(BaseView):
|
|
|
|
def __init__(self):
|
|
|
|
super(SignInView, self).__init__()
|
|
|
|
self.create_account_button = CreateAccountButton()
|
2018-11-16 09:53:05 +00:00
|
|
|
self.i_have_account_button = TextElement('I already have an account')
|
2018-10-23 14:49:29 +00:00
|
|
|
self.other_accounts_button = BaseElement(IMAGES_PATH + '/other_accounts.png')
|
2018-11-16 09:53:05 +00:00
|
|
|
self.privacy_policy_button = TextElement('Privacy Policy')
|
2018-10-23 14:49:29 +00:00
|
|
|
self.create_password_input = InputField(IMAGES_PATH + '/create_password_input.png')
|
|
|
|
self.confirm_password_input = InputField(IMAGES_PATH + '/confirm_password_input.png')
|
2018-11-16 09:53:05 +00:00
|
|
|
self.username_input = UserNameInput()
|
2018-10-23 14:49:29 +00:00
|
|
|
self.recovery_phrase_input = InputField(IMAGES_PATH + '/recovery_phrase_input.png')
|
|
|
|
self.recover_password_input = InputField(IMAGES_PATH + '/recover_password_input.png')
|
|
|
|
self.sign_in_button = BaseElement(IMAGES_PATH + '/sign_in_button.png')
|
|
|
|
self.password_input = InputField(IMAGES_PATH + '/password_input.png')
|
|
|
|
|
|
|
|
def create_account(self, password='qwerty', username='test'):
|
|
|
|
self.create_account_button.click()
|
|
|
|
self.create_password_input.input_value(password)
|
|
|
|
self.next_button.click()
|
|
|
|
self.confirm_password_input.input_value(password)
|
|
|
|
self.next_button.click()
|
|
|
|
self.username_input.input_value(username)
|
|
|
|
self.next_button.click()
|
|
|
|
self.home_button.find_element()
|
2018-11-16 09:53:05 +00:00
|
|
|
self.ok_button.click()
|
2018-10-23 14:49:29 +00:00
|
|
|
return HomeView()
|
|
|
|
|
2018-11-16 09:53:05 +00:00
|
|
|
def recover_access(self, passphrase, password='qwerty'):
|
2018-10-23 14:49:29 +00:00
|
|
|
self.i_have_account_button.click()
|
2018-10-24 21:01:30 +00:00
|
|
|
self.recovery_phrase_input.send_keys(passphrase)
|
2018-11-16 09:53:05 +00:00
|
|
|
self.recover_password_input.send_keys(password)
|
2018-10-23 14:49:29 +00:00
|
|
|
self.sign_in_button.click()
|
|
|
|
self.home_button.find_element()
|
2018-11-16 09:53:05 +00:00
|
|
|
self.ok_button.click()
|
2018-10-23 14:49:29 +00:00
|
|
|
return HomeView()
|