Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added preliminary template for execution file. #167

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
305 changes: 305 additions & 0 deletions examples/demo/simple_demo_v2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,305 @@
{
"schema-version": "1.0.0",
"Job":
{
"uuid": "tr100101",
"build": "V2.4",
"title": "Simple Demo v.1",
"parent": "None"
},
"Tests": [
{
"uuid": "tr100101--uuid-tc-01--chrome001",
"case": "uuid-tc-01",
"configurations": [
{
"type": "browser",
"uuid": "chrome001"
}
]
},
{
"uuid": "tr100101--uuid-tc-02--ffox002",
"case": "uuid-tc-02",
"configurations": [
{
"type": "browser",
"uuid": "ffox002"
}
]
}
],
"Cases":
[
{
"uuid": "uuid-tc-01",
"title": "Tass Sample Case A",
"steps": [
"q1",
"q2",
"q3",
"q4",
"q5",
"q6",
"q7",
"q8"
]
},
{
"uuid": "Uuid-tc-02",
"title": "Tass Sample Case B",
"steps": [
"q1",
"q2",
"q3",
"q4",
"q5",
"q1",
"q2",
"q3",
"q4",
"q5",
"q6a"
]
}
],
"Steps": [
{
"uuid": "q1",
"title": "Launch test page",
"action": [
"selenium",
"load_file"
],
"parameters": {
"relative_path": "examples/demo-html/page1.html"
}
},
{
"uuid": "q2",
"title": "Assert page is open",
"action": [
"selenium",
"assert_page_is_open"
],
"parameters": {
"page": [
"sample",
"page1"
]
}
},
{
"uuid": "q3",
"title": "Wait for element then type",
"action": [
"selwait",
"wait_element_visible"
],
"parameters": {
"locator": {
"by": "id",
"value": "nameField"
},
"action": [
"selenium",
"write"
],
"text": "do a barrel roll"
}
},
{
"uuid": "q4",
"title": "Click a button",
"action": [
"selenium",
"click"
],
"parameters": {
"locator": "btnColor",
"page": [
"sample",
"page1"
]
}
},
{
"uuid": "q5",
"title": "Read CSS",
"action": [
"selenium",
"read_css"
],
"parameters": {
"locator": "btnColor",
"page": [
"sample",
"page1"
],
"attribute": "background-color"
}
},
{
"uuid": "q6",
"title": "Assert element is displayed",
"action": [
"selenium",
"assert_displayed"
],
"parameters": {
"locator": "btnX",
"page": [
"sample",
"page1"
],
"soft": "true"
}
},
{
"uuid": "q7",
"title": "Assert element is displayed",
"action": [
"selenium",
"assert_displayed"
],
"parameters": {
"locator": "btnX",
"page": [
"sample",
"page1"
]
}
},
{
"uuid": "q8",
"title": "Assert element is displayed",
"action": [
"selenium",
"assert_displayed"
],
"parameters": {
"locator": "btnX",
"page": [
"sample",
"page1"
],
"soft": "true"
}
},
{
"uuid": "q6a",
"title": "Click a button",
"action": [
"selenium",
"click"
],
"parameters": {
"locator": "btnFormat",
"page": [
"sample",
"page1"
],
"locator_args": [
"Color"
]
}
}
],
"Browsers": [
{
"browser_name": "chrome",
"uuid": "chrome001",
"configs": {
"driver": {
"implicit_wait": "5",
"explicit_wait": "10"
},
"browser": {
"arguments": [
"--start-maximized"
],
"preferences": {}
}
}
},
{
"browser_name": "chrome",
"uuid": "chrome001A",
"configs": {
"driver": {
"implicit_wait": "5",
"explicit_wait": "10"
},
"browser": {
"arguments": [
"--window-size=1920,1080"
],
"preferences": {}
}
}
},
{
"browser_name": "chrome",
"uuid": "chrome001B",
"configs": {
"driver": {
"implicit_wait": "5",
"explicit_wait": "10"
},
"browser": {
"arguments": [
"--window-size=900,600"
],
"preferences": {}
}
}
},
{
"browser_name": "chrome",
"uuid": "chrome002",
"configs": {
"driver": {
"implicit_wait": "5",
"explicit_wait": "10"
},
"browser": {
"arguments": [
"--headless",
"--start-maximized"
],
"preferences": {}
}
}
},
{
"browser_name": "firefox",
"uuid": "ffox001",
"configs": {
"driver": {
"implicit_wait": "15",
"explicit_wait": "30"
},
"browser": {
"arguments": [
"--start-maximized"
],
"preferences": {}
}
}
},
{
"browser_name": "firefox",
"uuid": "ffox002",
"configs": {
"driver": {
"implicit_wait": "15",
"explicit_wait": "30"
},
"browser": {
"arguments": ["--headless"],
"preferences": {}
}
}
}
]
}
55 changes: 20 additions & 35 deletions tass-base/src/tass/base/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@ def default(self, obj):
)


def _make_report(registrar, func_name, *args, **kwargs):
if registrar:
log.debug("Running report function: %s", func_name)
for reporter in registrar.iter_reporters():
log.debug("Reporter: %s executing function", reporter.uuid)
getattr(reporter, func_name)(*args, **kwargs)

# TODO: add logging messages.


def main(args):
"""
Starting point for execution of tests.
Expand All @@ -44,36 +34,31 @@ def main(args):

path = Path(args.file).resolve()

runs, registrar = parse(path, args.no_validate)
test = parse(path, args.no_validate)

for test in runs:
log.info("<<<<< Starting Run: %s >>>>>", test.uuid)
_make_report(registrar, "start_report", test)
for case in test.collect():
log.info("")
log.info("< < < Starting Case: %s > > >", case.uuid)
log.info("")
log.info("<<<<< Starting Run: %s >>>>>", test.uuid)
for case in test.collect():
log.info("")
log.info("< < < Starting Case: %s > > >", case.uuid)
log.info("")

case.execute_tass()
case.execute_tass()

log.info("")
log.info("> > > Finished Case: %s < < <", case.uuid)
log.info("")

_make_report(registrar, "report", test)
_make_report(registrar, 'end_report', test)
log.info("")
log.info("> > > Finished Case: %s < < <", case.uuid)
log.info("")

Path('results').mkdir(exist_ok=True)
for test in runs:
file_name = test.uuid + '---' + test.start_time + '.json'
result_path = Path().resolve() / "results" / file_name
try:
f = open(result_path, 'w+', encoding='utf-8')
except IOError as e:
log.error("An IOError occured: %s" % e)
return
with f:
json.dump(test, f, indent=4, cls=TassEncoder)

file_name = test.uuid + '---' + test.start_time + '.json'
result_path = Path().resolve() / "results" / file_name
try:
f = open(result_path, 'w+', encoding='utf-8')
except IOError as e:
log.error("An IOError occured: %s" % e)
return
with f:
json.dump(test, f, indent=4, cls=TassEncoder)


if __name__ == '__main__':
Expand Down
6 changes: 3 additions & 3 deletions tass-base/src/tass/base/actions/action_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
}


def get_manager(module_name, **kwargs):
def get_manager(module_name, *args, **kwargs):
# Try to import the required module
log.info("Trying to import %s", module_name)
module = _import_module(module_name)

log.debug("Using manager args: %s", kwargs)
manager = module.get_manager(**kwargs)
log.debug("Getting manager: %s", module)
manager = module.get_manager(*args, **kwargs)
log.info("Created action manager of type: %s", manager.__class__.__name__)
return manager

Expand Down
Loading