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

WIP, refactoring all library #304

Open
wants to merge 49 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
30c1be8
[qacode] refactoring all library
netzulo Jan 29, 2020
99f4f85
[qacode] pair testlink elements
netzulo Jan 29, 2020
fe2695b
Merge branch 'master' into remove-useless
netzulo Jan 31, 2020
5e7abef
[qacode] update test bots+ added tests browsers
netzulo Feb 1, 2020
5e81fd3
[qacode] more update tests bots+browsers
netzulo Feb 2, 2020
3aebafe
[qacode] fix flake errors
netzulo Feb 2, 2020
26527a4
[qacode] added modules to browser
netzulo Feb 3, 2020
7de7340
[qacode] added tests for modules
netzulo Feb 3, 2020
d5b6c9f
[qacode] working tests
netzulo Feb 4, 2020
93b96c8
[qacode] added fixture for browser
netzulo Feb 5, 2020
90821e0
[qacode] added more commons tests
netzulo Feb 5, 2020
730ed97
[qacode] fixe flake errors
netzulo Feb 5, 2020
670a93a
[qacode] more tests for commons modules
netzulo Feb 6, 2020
d12748d
[qacode] added module for screenshots
netzulo Feb 8, 2020
a2d0b16
[qacode] coverage 100% for module commons
netzulo Feb 8, 2020
32347d3
[qacode] flake fix
netzulo Feb 8, 2020
73e2bea
[qacode] added loggers tests
netzulo Feb 9, 2020
7a151c7
[qacode] update elements coverage to 70%
netzulo Feb 9, 2020
ae8dc22
[qacode] added so much tests today
netzulo Feb 10, 2020
4609a29
[qacode] missclicked
netzulo Feb 10, 2020
3fb3ff0
[qacode] removed refactored files
netzulo Feb 10, 2020
489774c
[qacode] remove old files
netzulo Feb 10, 2020
376a9c7
[qacode] update coverage to 90%
netzulo Feb 11, 2020
ad7cf02
[qacode] Update coverate to 95%
netzulo Feb 12, 2020
6e6b53d
[qacode] added page + test template
netzulo Feb 18, 2020
586df9e
[qacode] instanced drivers on modules
netzulo Feb 18, 2020
0de6ea0
[qacode] added 100% coverage for page
netzulo Feb 18, 2020
c99719b
[qacode] added controls+tests, 93% coverage
netzulo Feb 19, 2020
0bd9f30
[qacode] fix codeclimate errors
netzulo Feb 19, 2020
002785b
[qacode] fixes for codeclimate
netzulo Feb 19, 2020
ba26aa4
[qacode] add base class for browser modules
netzulo Feb 25, 2020
af80d87
[qacode] added some functionality to controls
netzulo Feb 25, 2020
04b7bfa
[qacode] 96% coverage again
netzulo Feb 25, 2020
1985f02
[qacode] fix for issue #279
netzulo Feb 26, 2020
ca5240d
[qacode] more tests
netzulo Mar 15, 2020
d73efbe
[qacode] fixes for codeclimate
netzulo Mar 15, 2020
5e68bc6
[qacode] delete useless comment
netzulo Mar 16, 2020
a4dee85
[qacode] removed driver_wait from elements mod
netzulo Mar 16, 2020
493baf8
[qacode] added page to bot +tests
netzulo Mar 17, 2020
293f1d9
[qacode] merge from master
netzulo Apr 6, 2020
0691da0
[qacode] merge from master, removed enums
netzulo Apr 6, 2020
53bbd9f
[qacode] merge from master
netzulo Apr 7, 2020
4855030
Merge branch 'master' into remove-useless
netzulo Apr 7, 2020
79fde94
[qacode] more changes for issue
netzulo Apr 9, 2020
20653e0
[qacode] missing tests for new exceptions
netzulo Apr 9, 2020
bb8b425
[qacode] added working tests for exceptions
netzulo May 25, 2021
5ff8ae6
[qacode] update domain at settings for CI builds
netzulo May 26, 2021
a661566
[qacode] fix tox -e docs on CI builds
netzulo May 26, 2021
fa460d6
[qacode] merge v0.6.5 from master
Oct 21, 2021
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
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ ENV/

# QACODE ignores
qacode/configs/settings.json
tests/reports/*
tests/reports/coverage/*
tests/reports/benchmarks/benchmark.*.svg
qacode_old/configs/settings.json

tests_old/reports/*
tests_old/reports/coverage/*
tests_old/reports/benchmarks/benchmark.*.svg
# Visual Studio
.vs/
# Visual code
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ Getting Started


SETTINGS = settings(
file_path="/home/user/config/dir/",
file_name="settings.json"
path="/home/user/config/dir/",
name="settings.json"
)


Expand Down
24 changes: 17 additions & 7 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,32 @@

import pytest
import sys
from qacode.core.bots.bot_base import BotBase
from qacode.core.bots.bot import Bot
from qacode.utils import settings


sys.dont_write_bytecode = True


@pytest.fixture(scope="session")
def browser():
CFG = settings(file_path="qacode/configs/", file_name="settings.json")
bot = None
def bot():
CFG = settings(path="qacode/configs/", name="settings.json")
bot = Bot(**CFG)
try:
bot = BotBase(**CFG)
yield bot
except Exception as err:
raise err


@pytest.fixture(scope="session")
def browser():
CFG = settings(path="qacode/configs/", name="settings.json")
bot = Bot(**CFG)
try:
yield bot.browser_create(bot.config.browsers[0])
except Exception as err:
raise err
finally:
if bot:
bot.close()
if bot.browsers[0].driver is not None:
bot.browsers[0].close()
# else: useless browser, never opened
161 changes: 44 additions & 117 deletions qacode/configs/settings.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,47 @@
{ "bot": {
"log_output_file": "logs/",
"log_name": "qacode",
"log_level": "INFO",
"mode": "remote",
"browser": "chrome",
"options": { "headless": false },
"url_hub": "http://netzulo.tk:11000/wd/hub",
{
"log":{
"path": "logs/", "name": "qacode", "level": "INFO"
},
"bot":{
"hub_url": "http://146.255.103.8:11000/wd/hub",
"drivers_path": "../qadrivers",
"drivers_names": [
"chromedriver_32.exe",
"chromedriver_64.exe",
"chromedriver_32",
"chromedriver_64",
"firefoxdriver_32.exe",
"firefoxdriver_64.exe",
"firefoxdriver_64",
"firefoxdriver_32",
"iexplorerdriver_32.exe",
"iexplorerdriver_64.exe",
"edgedriver_32.exe",
"edgedriver_64.exe",
"operadriver_32.exe",
"operadriver_64.exe",
"operadriver_32",
"operadriver_64"
"drivers_names": {
"chrome": "chromedriver_64.exe",
"firefox": "firefoxdriver_64.exe",
"opera": "operadriver_64.exe",
"iexplorer": "iexplorerdriver_64.exe",
"edge": "edgedriver_64.exe"
},
"browsers": [
{"browser": "chrome", "mode": "remote", "options": {"headless": false}},
{"browser": "chrome", "mode": "local", "options": {"headless": false}}
],
"pages": [
{"name": "login", "url": "http://146.255.103.8:83/qacode/login"},
{"name": "logout", "url": "http://146.255.103.8:83/qacode/logout"},
{"name": "inputs", "url": "http://146.255.103.8:83/qacode/forms/inputs"},
{"name": "lists", "url": "http://146.255.103.8:83/qacode/data/lists"}
],
"controls": [
{ "name": "form", "selector": "#frmLogin", "pages": ["login"]},
{ "name": "username", "selector": "#txtUsername-field", "pages": ["login"]},
{ "name": "password", "selector": "#txtPassword-field", "pages": ["login"]},
{ "name": "submit", "selector": "#btnLogin", "pages": ["login"]},
{ "name": "btn_logout", "selector": "a[href='/qacode/logout']", "pages": ["logout"]},
{ "name": "btn_login", "selector": "a[href='/qacode/login']", "pages": ["logout"]},
{ "name": "title_buttons", "selector": "#titleButtons", "pages": ["inputs"]},
{ "name": "btn_invisible", "selector": "#btnInvisibleAtTimeout", "pages": ["inputs"]},
{ "name": "btn_visible", "selector": "#btnVisibleAtTimeout", "pages": ["inputs"]},
{ "name": "input_text", "selector": "#txtTest001", "pages": ["inputs"]},
{ "name": "dd_base", "selector": "#txtTest002", "pages": ["inputs"]},
{ "name": "dd_multiple", "selector": "#txtTest003", "pages": ["inputs"]},
{ "name": "lst_ordered", "selector": "ol:nth-child(1)", "pages": ["lists"]},
{ "name": "lst_ordered_child", "selector": "li", "pages": ["lists"]},
{ "name": "dd_menu_data", "selector": "#ddData", "pages": ["lists"]},
{ "name": "dd_menu_data_lists", "selector": "a[href='/qacode/data/lists']", "pages": ["lists"]},
{ "name": "tbl_ok", "selector": "#tblOk", "pages": ["lists"]},
{ "name": "tbl_html5_ok", "selector": "#tblHtml5Ok", "pages": ["lists"]},
{ "name": "tbl_html_tbodies_ok", "selector": "#tblHtml5OkTbodies", "pages": ["lists"]}
]
},
"testlink": {
Expand All @@ -34,96 +52,5 @@
},
"dev_key": "1bfd2ef4ceda22b482b12f2b25457495",
"log_level":"INFO"
},
"tests": {
"skip":{
"test_configs": true,
"browsers": {
"chrome": {"local":true, "remote":false},
"firefox": {"local":true, "remote":true},
"iexplorer": {"local":true, "remote":true},
"edge": {"local":true, "remote":true},
"opera": {"local":true, "remote":false}
},
"bot_multiple": false,
"bot_unique": false,
"bot_navigations": false,
"web_controls": {
"control_base": false,
"control_form": false,
"control_dropdown": false,
"control_table": false
},
"web_pages": false,
"benchmarks": true
},
"apps": [
{ "name": "qadmin",
"pages": [
{ "name": "qacode_login",
"url": "http://netzulo.tk:83/qacode/login",
"locator": "css selector",
"go_url": false,
"wait_url": 0,
"maximize": false,
"controls": [
{ "name": "form_login", "selector": "#frmLogin", "on_instance_search": true, "on_instance_load": false },
{ "name": "txt_username", "selector": "#txtUsername-field", "on_instance_search": true, "on_instance_load": false },
{ "name": "txt_password", "selector": "#txtPassword-field", "on_instance_search": true, "on_instance_load": false },
{ "name": "btn_submit", "selector": "#btnLogin", "on_instance_search": true, "on_instance_load": false }
]
},
{ "name": "qacode_lists",
"url": "http://netzulo.tk:83/qacode/data/lists",
"locator": "css selector",
"go_url": false,
"wait_url": 0,
"maximize": false,
"controls": [
{ "name": "lst_ordered", "selector": "ol:nth-child(1)"},
{ "name": "lst_ordered_child", "selector": "li"},
{ "name": "dd_menu_data", "selector": "#ddData"},
{ "name": "dd_menu_data_lists", "selector": "a[href='/qacode/data/lists']"},
{ "name": "tbl_ok", "selector": "#tblOk"},
{ "name": "tbl_html5_ok", "selector": "#tblHtml5Ok"},
{ "name": "tbl_html_tbodies_ok", "selector": "#tblHtml5OkTbodies"}
]
},
{ "name": "qacode_inputs",
"url": "http://netzulo.tk:83/qacode/forms/inputs",
"locator": "css selector",
"go_url": false,
"wait_url": 0,
"maximize": false,
"controls": [
{ "name": "dd_base", "selector": "#txtTest002", "instance": "ControlForm",
"strict_rules": [
{ "tag": "select", "type": "tag", "severity": "hight" }
]
},
{ "name": "dd_multiple", "selector": "#txtTest003", "instance": "ControlForm",
"strict_rules": [
{ "tag": "select", "type": "tag", "severity": "hight" }
]
},
{ "name": "btn_click_invisible", "selector": "#btnInvisibleAtTimeout" },
{ "name": "btn_click_visible", "selector": "#btnVisibleAtTimeout" },
{ "name": "title_buttons", "selector": "#titleButtons" }
]
},
{ "name": "qacode_logout",
"url": "http://netzulo.tk:83/qacode/logout",
"locator": "css selector",
"go_url": true,
"wait_url": 0,
"maximize": false,
"controls": [
{ "name": "btn_logout", "selector": "a[href='/qacode/logout']" },
{ "name": "btn_login", "selector": "a[href='/qacode/login']" }
]
}
]
}
]
}
}
}
14 changes: 11 additions & 3 deletions qacode/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@


from qacode.core import bots
from qacode.core import exceptions
from qacode.core import browsers
from qacode.core import controls
from qacode.core import loggers
from qacode.core import pages
from qacode.core import testing
from qacode.core import webs


__all__ = ['bots', 'exceptions', 'loggers', 'testing', 'webs']
__all__ = [
'bots',
'browsers',
'controls',
'loggers',
'pages',
'testing',
]
21 changes: 12 additions & 9 deletions qacode/core/bots/__init__.py
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# -*- coding: utf-8 -*-
"""package qacode.core.bots"""


from qacode.core.bots import bot_base
from qacode.core.bots import modules


__all__ = ['bot_base', 'modules']
# -*- coding: utf-8 -*-
"""package qacode.core.bots"""


from qacode.core.bots import bot
from qacode.core.bots import bot_config


__all__ = [
'bot',
'bot_config',
]
101 changes: 101 additions & 0 deletions qacode/core/bots/bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# -*- coding: utf-8 -*-
"""TODO"""


from qacode.core.bots.bot_config import BotConfig
from qacode.core.browsers.browser import Browser
from qacode.core.exceptions.bot_error import BotError
from qacode.core.loggers.log import Log
from qacode.core.pages.page import Page


class Bot(object):
"""Class Base for handle selenium functionality throught this wrapper"""

def __init__(self, **kwargs):
"""TODO: doc method"""
self._browsers = []
self._pages = []
self._controls = []
self._config = BotConfig(**kwargs)
self._log = Log(**{
"name": self._config.log_name,
"path": self._config.log_path,
"level": self._config.log_level})

def __raises__(self, message):
"""TODO: doc method"""
self.log.error(message)
raise BotError(message, self)

def start(self):
"""TODO: doc method"""
for _browser in self._config.browsers:
self.browser_create(_browser)
for _page in self._config.pages:
self.page_create(self._browsers[0], _page)

def browser(self, session_id):
"""TODO: doc method"""
for browser in self.browsers:
if browser.session_id == session_id:
return browser
self.__raises__("browser not found")

def page(self, url):
"""TODO: doc method"""
for page in self.pages:
if page.config.url == url:
return page
self.__raises__("page not found")

# def control(self, selector):
# """TODO: doc method"""
# for control in self.controls:
# if control.selector == selector:
# return control
# raise Exception("control not found")

def browser_create(self, config):
"""TODO: doc method"""
driver_name = self._config.drivers_names[config.get("browser")]
driver_path = self._config.drivers_path
_config = config.copy()
_config.update({
"driver_path": driver_path,
"driver_name": driver_name,
"hub_url": self._config.hub_url})
browser = Browser(self.log, **_config)
self._browsers.append(browser)
return browser

def page_create(self, browser, config):
"""TODO: doc method"""
page = Page(browser, **config)
self._pages.append(page)
return page

@property
def config(self):
"""TODO: doc method"""
return self._config

@property
def browsers(self):
"""TODO: doc method"""
return self._browsers

@property
def pages(self):
"""TODO: doc method"""
return self._pages

@property
def controls(self):
"""TODO: doc method"""
return self._controls

@property
def log(self):
"""TODO: doc method"""
return self._log
Loading