2018-10-23 14:49:29 +00:00
|
|
|
import org.sikuli.script.SikulixForJython
|
|
|
|
from sikuli import *
|
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')
|
|
|
|
|
|
|
|
def click(self):
|
|
|
|
super(ProfileButton, self).click()
|
|
|
|
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()
|
|
|
|
self.back_button = BaseElement(IMAGES_PATH + '/back_button.png')
|
|
|
|
|
|
|
|
def find_text(self, expected_text):
|
|
|
|
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)
|