feat: make screenshot test easy to add between steps
This commit is contained in:
parent
b6ff7b9ded
commit
ba4aac6456
|
@ -1,7 +1,9 @@
|
|||
from drivers.SquishDriver import *
|
||||
import squish
|
||||
from remotesystem import RemoteSystem
|
||||
import time
|
||||
import platform
|
||||
from typing import Dict, Any
|
||||
|
||||
# The default maximum timeout to find ui object
|
||||
_MAX_WAIT_OBJ_TIMEOUT = 5000
|
||||
|
@ -12,7 +14,6 @@ _MIN_WAIT_OBJ_TIMEOUT = 500
|
|||
# The default maximum timeout to wait for close the app in seconds
|
||||
_MAX_WAIT_CLOSE_APP_TIMEOUT = 20
|
||||
|
||||
|
||||
def verify_screen(objName: str, timeout: int=_MAX_WAIT_OBJ_TIMEOUT):
|
||||
result = is_loaded_visible_and_enabled(objName, timeout)
|
||||
test.verify(result, True)
|
||||
|
@ -104,6 +105,15 @@ def verify_failure(errorMsg: str):
|
|||
def log(text: str):
|
||||
test.log(text)
|
||||
|
||||
|
||||
def verify_or_create_screenshot(vp: str, obj: Dict[str, Any]):
|
||||
try:
|
||||
test.vpWithObject(vp, obj)
|
||||
except RuntimeError:
|
||||
squish.createVisualVP(obj, vp)
|
||||
except squish.SquishVerificationFailedException:
|
||||
raise
|
||||
|
||||
def verify_screenshot(vp: str):
|
||||
test.vp(vp)
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ def hook(context):
|
|||
context.userData["fixtures_root"] = os.path.join(os.path.dirname(__file__), "../../../fixtures/")
|
||||
context.userData["search_images"] = os.path.join(os.path.dirname(__file__), "../shared/searchImages/")
|
||||
|
||||
context.userData["scenario_name"] = context._data["title"]
|
||||
|
||||
base_path = os.path.join(os.path.dirname(__file__))
|
||||
split_path = base_path.split("/")
|
||||
|
||||
|
@ -39,3 +41,7 @@ def hook(context):
|
|||
currentApplicationContext().detach()
|
||||
snooze(_app_closure_timeout)
|
||||
|
||||
|
||||
@OnStepEnd
|
||||
def hook(context):
|
||||
context.userData["step_name"] = context._data["text"]
|
|
@ -0,0 +1,18 @@
|
|||
import drivers.SquishDriverVerification as verifier
|
||||
import os
|
||||
from typing import Dict, Any
|
||||
from .global_names import mainWindow_RighPanel
|
||||
|
||||
|
||||
def verify_screenshot(func, obj: Dict[str, Any] = mainWindow_RighPanel):
|
||||
def inner(*args, **kwargs):
|
||||
context = args[0]
|
||||
func(*args, **kwargs)
|
||||
|
||||
scenario = context.userData["scenario_name"].lower().replace(" ", "_")
|
||||
step = context.userData["step_name"].lower().replace(" ", "_")
|
||||
filename = f"{step}_{'_'.join(args[1:])}"
|
||||
path = os.path.join(scenario, filename)
|
||||
verifier.verify_or_create_screenshot(path, obj)
|
||||
|
||||
return inner
|
|
@ -11,6 +11,9 @@ mainWindow_ScrollView_2 = {"container": statusDesktop_mainWindow, "occurrence":
|
|||
mainWindow_ProfileNavBarButton = {"container": statusDesktop_mainWindow, "objectName": "statusProfileNavBarTabButton", "type": "StatusNavBarTabButton", "visible": True}
|
||||
settings_navbar_settings_icon_StatusIcon = {"container": mainWindow_navBarListView_ListView, "objectName": "settings-icon", "type": "StatusIcon", "visible": True}
|
||||
|
||||
# main right panel
|
||||
mainWindow_RighPanel= {"container": statusDesktop_mainWindow, "type": "ColumnLayout", "objectName": "mainRightView", "visible": True}
|
||||
|
||||
# User Status Profile Menu
|
||||
userContextmenu_AlwaysActiveButton= {"container": statusDesktop_mainWindow_overlay, "objectName": "userStatusMenuAlwaysOnlineAction", "type": "StatusMenuItemDelegate", "visible": True}
|
||||
userContextmenu_InActiveButton= {"container": statusDesktop_mainWindow_overlay, "objectName": "userStatusMenuInactiveAction", "type": "StatusMenuItemDelegate", "visible": True}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from screens.StatusWalletScreen import StatusWalletScreen
|
||||
from scripts.decorators import verify_screenshot
|
||||
|
||||
_statusMain = StatusMainScreen()
|
||||
_walletScreen = StatusWalletScreen()
|
||||
|
@ -12,6 +13,7 @@ def step(context):
|
|||
_walletScreen.accept_signing_phrase()
|
||||
|
||||
@When("the user adds watch only account with |any| and |any|")
|
||||
@verify_screenshot
|
||||
def step(context, account_name, address):
|
||||
_walletScreen.add_watch_only_account(account_name, address)
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -397,6 +397,8 @@ Item {
|
|||
|
||||
rightPanel: ColumnLayout {
|
||||
spacing: 0
|
||||
objectName: "mainRightView"
|
||||
|
||||
ModuleWarning {
|
||||
id: versionWarning
|
||||
width: parent.width
|
||||
|
|
Loading…
Reference in New Issue