2018-10-24 21:01:30 +00:00
|
|
|
import logging
|
2018-11-16 09:53:05 +00:00
|
|
|
|
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-10-23 14:49:29 +00:00
|
|
|
import pytest
|
2018-09-15 17:18:29 +00:00
|
|
|
|
2018-10-23 14:49:29 +00:00
|
|
|
from views.base_element import BaseElement, TextElement
|
2018-09-15 17:18:29 +00:00
|
|
|
|
|
|
|
IMAGES_PATH = os.path.join(os.path.dirname(__file__), 'images/base_view')
|
|
|
|
|
|
|
|
|
2018-10-23 14:49:29 +00:00
|
|
|
class ProfileButton(BaseElement):
|
2018-09-15 17:18:29 +00:00
|
|
|
def __init__(self):
|
2018-10-23 14:49:29 +00:00
|
|
|
super(ProfileButton, self).__init__(IMAGES_PATH + '/profile_button.png')
|
|
|
|
|
2018-10-24 21:01:30 +00:00
|
|
|
def click(self, log=True):
|
|
|
|
super(ProfileButton, self).click(log=log)
|
2018-10-23 14:49:29 +00:00
|
|
|
from views.profile_view import ProfileView
|
|
|
|
return ProfileView()
|
2018-09-15 17:18:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
class BaseView(object):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
super(BaseView, self).__init__()
|
2018-10-23 14:49:29 +00:00
|
|
|
self.home_button = BaseElement(IMAGES_PATH + '/home_button.png')
|
|
|
|
self.profile_button = ProfileButton()
|
2018-11-16 09:53:05 +00:00
|
|
|
self.back_button = BaseElement(IMAGES_PATH + '/back_button.png', x=10, y=20, w=50, h=50)
|
|
|
|
self.ok_button = BaseElement(IMAGES_PATH + '/ok_button.png')
|
|
|
|
self.next_button = BaseElement(IMAGES_PATH + '/next_button.png')
|
|
|
|
self.done_button = BaseElement(IMAGES_PATH + '/done_button.png')
|
|
|
|
self.yes_button = BaseElement(IMAGES_PATH + '/yes_button.png')
|
2018-10-23 14:49:29 +00:00
|
|
|
|
|
|
|
def find_text(self, expected_text):
|
2018-10-24 21:01:30 +00:00
|
|
|
logging.info("Find text '%s'" % expected_text)
|
2018-10-23 14:49:29 +00:00
|
|
|
for _ in range(3):
|
|
|
|
current_text = text().encode('ascii', 'ignore').replace('\n', ' ')
|
|
|
|
if expected_text in current_text:
|
|
|
|
return
|
|
|
|
pytest.fail("Could not find text '%s'" % expected_text)
|
|
|
|
|
|
|
|
def get_clipboard(self):
|
|
|
|
return Env.getClipboard()
|
|
|
|
|
|
|
|
def element_by_text(self, text):
|
|
|
|
return TextElement(text)
|
2018-10-24 21:01:30 +00:00
|
|
|
|
|
|
|
def press_enter(self):
|
|
|
|
logging.info('Press Enter button')
|
|
|
|
type(Key.ENTER)
|
|
|
|
|
|
|
|
def press_tab(self):
|
|
|
|
logging.info('Press Tab button')
|
|
|
|
type(Key.TAB)
|