+ +
+

Welcome to Qacode’s documentation!

+
+
+

Indices and tables

+ +
+
+

package: qacode.core.bots

+
+

Class: BotBase

+

TODO

+
+
+class qacode.core.bots.bot_base.BotBase(**kwargs)
+

Bases: object

+

Class Base for handle selenium functionality throught this wrapper

+

curr_caps – Capabilities class

+

curr_driver – WebDriver class

+

curr_driver_path – WebDriver browser executable path

+

navigation – Bot methods to brigde selenium functions

+

bot_config – Bot configuration object

+
+
logger_manager – logger manager class loaded from
+
LoggerManager object
+
+

log – log class to write messages

+
+
+IS_64BITS = True
+
+ +
+
+IS_WIN = True
+
+ +
+
+close()
+

Close curr_driver browser

+
+ +
+
+curr_caps = None
+
+ +
+
+curr_driver = None
+
+ +
+
+curr_driver_path = None
+
+ +
+
+driver_name_filter(driver_name=None)
+

Filter names of driver to search selected on config list

+
+
Keyword Arguments:
+
+
driver_name {str} – driver_name_format is
+
{driver_name}{arch}{os} (default: {None})
+
+
+
Raises:
+
CoreException – driver_name param is None +CoreException – driver_name not in
+
Returns:
+
+
str – name of driver
+
(example: chromedriver_32.exe)
+
+
+
+
+ +
+
+log = None
+
+ +
+
+logger_manager = None
+
+ +
+
+mode_local()
+

Open new brower on local mode

+
+
Raises:
+
+
CoreException – driver_name on config JSON
+
file is not valid value
+
+
+
+
+ +
+
+mode_remote()
+

Open new brower on remote mode

+
+
Raises:
+
CoreException – browser name is not in valid values list
+
+
+ +
+
+navigation = None
+
+ +
+
+settings = None
+
+ +
+ +
+
+class qacode.core.bots.bot_base.BotBase(**kwargs)
+

Class Base for handle selenium functionality throught this wrapper

+

curr_caps – Capabilities class

+

curr_driver – WebDriver class

+

curr_driver_path – WebDriver browser executable path

+

navigation – Bot methods to brigde selenium functions

+

bot_config – Bot configuration object

+
+
logger_manager – logger manager class loaded from
+
LoggerManager object
+
+

log – log class to write messages

+
+
+close()
+

Close curr_driver browser

+
+ +
+
+driver_name_filter(driver_name=None)
+

Filter names of driver to search selected on config list

+
+
Keyword Arguments:
+
+
driver_name {str} – driver_name_format is
+
{driver_name}{arch}{os} (default: {None})
+
+
+
Raises:
+
CoreException – driver_name param is None +CoreException – driver_name not in
+
Returns:
+
+
str – name of driver
+
(example: chromedriver_32.exe)
+
+
+
+
+ +
+
+mode_local()
+

Open new brower on local mode

+
+
Raises:
+
+
CoreException – driver_name on config JSON
+
file is not valid value
+
+
+
+
+ +
+
+mode_remote()
+

Open new brower on remote mode

+
+
Raises:
+
CoreException – browser name is not in valid values list
+
+
+ +
+ +
+
+

Class: NavBase (used at bot.navigation as property)

+

Created on 04 march 2017

+

@author: ntz

+
+
+class qacode.core.bots.modules.nav_base.NavBase(driver, log, driver_wait=None)
+

Bases: object

+

Main navigation methods to use on selenium scripts

+
+ +

Deletes a single cookie with the given name

+
+ +
+
+delete_cookies()
+

Delete all cookies in the scope of the session

+
+ +
+
+driver = None
+
+ +
+
+ele_attribute(element, attr_name)
+

Returns tuple with (attr, value) if founds +This method will first try to return the value of a property with +the given name. If a property with that name doesn’t exist, it +returns the value of the attribute with the same name. If there’s +no attribute with that name, None is returned.

+
+ +
+
+ele_clear(element)
+

Clear element text

+
+ +
+
+ele_click(element=None, selector=None, locator='css selector')
+
+
Perform click webelement with locator param or search it by default
+
CSS_SELECTOR value if element it’s none but selector +it’s not default value
+
Keyword Arguments:
+
+
element {WebElement} – selenium object, instance of WebElement
+
(default: {None})
+
selector {str} – selector to search and element to click
+
(default: {None})
+
locator {By} – locator selenium strategy
+
(default: {By.CSS_SELECTOR})
+
+
+
Raises:
+
+
CoreException – Bad params combination, need element
+
or selector to search element
+
+
+
Returns:
+
WebElement – returns element clicked (to allow chaining)
+
+
+ +
+
+ele_css(element, prop_name)
+

Allows to obtain CSS value based on CSS property name

+
+
Arguments:
+
element {WebElement} – WebElement to modify CSS property +prop_name {str} – CSS property name
+
Returns:
+
str – Value of CSS property searched
+
+
+ +
+
+ele_input_value(element)
+

Return value of value attribute, usefull for inputs

+
+ +
+
+ele_is_displayed(element)
+

Whether the element is visible to a user

+
+
Webdriver spec to determine if element it’s displayed:
+
https://w3c.github.io/webdriver/webdriver-spec.html#widl-WebElement-isDisplayed-boolean
+
Arguments:
+
element {WebElement} – selenium web element
+
Returns:
+
+
bool – Value based on selenium SPEC to determine if an element
+
is enabled
+
+
+
+
+ +
+
+ele_is_enabled(element)
+

Returns whether the element is enabled

+
+
Arguments:
+
element {WebElement} – selenium web element
+
Returns:
+
+
bool – Value based on selenium SPEC to determine if an element
+
is enabled
+
+
+
+
+ +
+
+ele_is_selected(element)
+

Returns whether the element is selected

+
+
Arguments:
+
element {WebElement} – selenium web element
+
Returns:
+
+
bool – Value based on selenium SPEC to determine if an element
+
is enabled
+
+
+
+
+ +
+
+ele_tag(element)
+

Returns element.tag_name value

+
+ +
+
+ele_text(element, on_screen=True)
+
+
Get element content text.
+
If the isDisplayed() method can sometimes trip over when +the element is not really hidden but outside the viewport +get_text() returns an empty string for such an element.
+
Keyword Arguments:
+
+
on_screen {bool} – allow to obtain text if element
+
it not displayed to this element before +read text (default: {True})
+
+
+
Returns:
+
str – Return element content text (innerText property)
+
+
+ +
+
+ele_write(element, text=None)
+

Over element perform send_keys , if not sended text, then will write +empty over element +:param element: WebElement +:return: None

+
+ +
+
+execute_js(script, *args)
+

Execute arbitrary Javascript code

+
+
Arguments:
+
script {str} – JS code to be executed on WebDriver +*args {[type]} – More arguments ( like element selector )
+
Returns:
+
str – JS script returns
+
+
+ +
+
+find_element(selector, locator='css selector')
+
+
Just divided execution ways for search web element
+
throught selenium
+
Arguments:
+
+
selector {str} – string selector used to locate one
+
element or first obtained
+
+
+
Keyword Arguments:
+
+
locator {By} – locator strategy used to find
+
WebElement selector (default: {By.CSS_SELECTOR})
+
+
+
Raises:
+

CoreException – If locator is None +CoreException – Element selector+locator strategy raises

+
+
selenium NoSuchElementException
+
+
Returns:
+
WebElement – selenium representation for a web element
+
+
+ +
+
+find_element_wait(selector, locator='css selector', driver_wait=None)
+
+
Search element using WebDriverWait class
+
and ElementConditions presence_of_element_located
+
Arguments:
+
+
selector {str} – string selector used to locate one
+
element or first obtained
+
+
+
Keyword Arguments:
+
+
locator {By} – locator strategy used to find
+
WebElement selector (default: {By.CSS_SELECTOR})
+
driver_wait {WebDriverWait} – driver that supports
+
ExpectedConditions methods (default: {None})
+
+
+
Raises:
+
+
CoreException – if NavBase instanced
+
without driver_wait
+
+
+
Returns:
+
+
WebElement – element through selenium
+
WebDriverWait class
+
+
+
+
+ +
+
+find_elements(selector, locator='css selector')
+
+
Just divided execution ways for search web elements
+
throught selenium
+
Arguments:
+
+
selector {str} – string selector used to locate
+
one or more elements
+
+
+
Keyword Arguments:
+
+
locator {By} – locator strategy used to find
+
WebElement selector (default: {By.CSS_SELECTOR})
+
+
+
Raises:
+

CoreException – If locator is None +CoreException – Element selector+locator strategy raises

+
+
selenium NoSuchElementException
+
+
Returns:
+
+
list(WebElement) – selenium representation for a
+
list of web elements
+
+
+
+
+ +
+
+forward()
+

Go forward using browser functionality

+
+ +
+
+get_capabilities()
+

Retrieve current capabilities applied to selenium driver

+
+ +
+
+get_current_url()
+

Return current url from opened bot

+
+
Raises:
+
+
CoreException – if can’t obtains url with this
+
selenium driver
+
+
+
Returns:
+
str – string representation of current driver url
+
+
+ +
+
+get_log(log_name='browser')
+
+
Get selenium log by name, this depends of
+
driver mode and browser what it’s using each time
+
Keyword Arguments:
+
log_name {str} – get log type lanes (default: {‘browser’})
+
Raises:
+
+
CoreException – if log_name value not in list
+
of valid values : browser, driver, client, server
+
+
+
Returns:
+
list() – list of messages typed on a log_name
+
+
+ +
+
+get_maximize_window()
+

Maximize browser window

+
+ +
+
+get_screenshot_as_base64()
+

Gets the screenshot of the current window as a base64 encoded string +which is useful in embedded images in HTML

+
+ +
+
+get_screenshot_as_file(file_name)
+
+
Gets the screenshot of the current window. Returns False
+
if there is any IOError, else returns True. Use full paths +in your filename.
+
Arguments:
+
+
file_name {str} – name of file path where
+
want to save screenshot
+
+
+
Returns:
+
list(byte) – file binary object of screenshot bytes
+
+
+ +
+
+get_screenshot_as_png()
+
+
Gets the screenshot of the current window as a
+
binary data.
+
Returns:
+
File – file binary object of screenshot with PNG format
+
+
+ +
+
+get_screenshot_save(file_name)
+
+
Gets the screenshot of the current window. Returns False
+
if there is any IOError, else returns True. +Use full paths in your filename.
+
Arguments:
+
+
file_name {str} – name of file path where
+
want to save screenshot
+
+
+
Returns:
+
list(byte) – file binary object of screenshot bytes
+
+
+ +
+
+get_title()
+

Obtains the title of the current page and return it

+
+
Returns:
+
str – title of current page opened
+
+
+ +
+
+get_url(url, wait_for_load=0)
+

Do get_url including implicit wait for page load

+
+ +
+
+get_window_handle()
+

Get window object to handle with selenium on scripts

+
+ +
+
+is_url(url, ignore_raises=True)
+

Check if url it’s the same what selenium current and visible url

+
+
Arguments:
+
url {str} – string value used to verify url
+
Keyword Arguments:
+
+
ignore_raises {bool} – allows to ignore errors
+
when executes if raises errors (default: {True})
+
+
+
Raises:
+
exceptions – [description] +CoreException – [description]
+
Returns:
+
+
bool – if current driver url match with param url,
+
then returns True, False if not
+
+
+
+
+ +
+
+js_set_timeout(timeout=60)
+
+
Set the amount of time that the script should wait during an
+
execute_async_script call before throwing an error.
+
Keyword Arguments:
+
+
timeout {int} – seconds to raise script
+
wait (default: {60})
+
+
+
+
+ +
+
+log = None
+
+ +
+
+reload()
+

Go reload page using browser functionality

+
+ +
+
+set_css_rule(css_selector, css_prop, css_value, css_important=False, index=0)
+

Set new value for given CSS property name

+
+
Arguments:
+
css_selector {str} – CSS selector to apply rule +css_prop {str} – CSS property to be applied to rule +css_value {str} – CSS property value to be applied to rule
+
Keyword Arguments:
+
+
css_important {bool} – Allow to include ‘!important’
+
to rule (default: {False})
+
index {int} – Position to insert new CSS rule
+
on first stylesheet (default: {0})
+
+
+
Returns:
+
str – JS script returns
+
+
+ +
+
+set_web_element(new_attr_id)
+

Create web element using selenium adding to DOM

+
+
Arguments:
+
+
new_attr_id {str} – html attribute ID for
+
new web element
+
+
+
+
+ +
+
+set_window_size(pos_x=800, pos_y=600)
+
+
Sets the width and height of the current
+
window. (window.resizeTo)
+
Keyword Arguments:
+
pos_x {int} – width of new window size (default: {800}) +pos_y {int} – height of new window size (default: {600})
+
+
+ +
+ +
+
+class qacode.core.bots.modules.nav_base.NavBase(driver, log, driver_wait=None)
+

Main navigation methods to use on selenium scripts

+
+
+delete_cookie_by_key(key_name)
+

Deletes a single cookie with the given name

+
+ +
+
+delete_cookies()
+

Delete all cookies in the scope of the session

+
+ +
+
+ele_attribute(element, attr_name)
+

Returns tuple with (attr, value) if founds +This method will first try to return the value of a property with +the given name. If a property with that name doesn’t exist, it +returns the value of the attribute with the same name. If there’s +no attribute with that name, None is returned.

+
+ +
+
+ele_clear(element)
+

Clear element text

+
+ +
+
+ele_click(element=None, selector=None, locator='css selector')
+
+
Perform click webelement with locator param or search it by default
+
CSS_SELECTOR value if element it’s none but selector +it’s not default value
+
Keyword Arguments:
+
+
element {WebElement} – selenium object, instance of WebElement
+
(default: {None})
+
selector {str} – selector to search and element to click
+
(default: {None})
+
locator {By} – locator selenium strategy
+
(default: {By.CSS_SELECTOR})
+
+
+
Raises:
+
+
CoreException – Bad params combination, need element
+
or selector to search element
+
+
+
Returns:
+
WebElement – returns element clicked (to allow chaining)
+
+
+ +
+
+ele_css(element, prop_name)
+

Allows to obtain CSS value based on CSS property name

+
+
Arguments:
+
element {WebElement} – WebElement to modify CSS property +prop_name {str} – CSS property name
+
Returns:
+
str – Value of CSS property searched
+
+
+ +
+
+ele_input_value(element)
+

Return value of value attribute, usefull for inputs

+
+ +
+
+ele_is_displayed(element)
+

Whether the element is visible to a user

+
+
Webdriver spec to determine if element it’s displayed:
+
https://w3c.github.io/webdriver/webdriver-spec.html#widl-WebElement-isDisplayed-boolean
+
Arguments:
+
element {WebElement} – selenium web element
+
Returns:
+
+
bool – Value based on selenium SPEC to determine if an element
+
is enabled
+
+
+
+
+ +
+
+ele_is_enabled(element)
+

Returns whether the element is enabled

+
+
Arguments:
+
element {WebElement} – selenium web element
+
Returns:
+
+
bool – Value based on selenium SPEC to determine if an element
+
is enabled
+
+
+
+
+ +
+
+ele_is_selected(element)
+

Returns whether the element is selected

+
+
Arguments:
+
element {WebElement} – selenium web element
+
Returns:
+
+
bool – Value based on selenium SPEC to determine if an element
+
is enabled
+
+
+
+
+ +
+
+ele_tag(element)
+

Returns element.tag_name value

+
+ +
+
+ele_text(element, on_screen=True)
+
+
Get element content text.
+
If the isDisplayed() method can sometimes trip over when +the element is not really hidden but outside the viewport +get_text() returns an empty string for such an element.
+
Keyword Arguments:
+
+
on_screen {bool} – allow to obtain text if element
+
it not displayed to this element before +read text (default: {True})
+
+
+
Returns:
+
str – Return element content text (innerText property)
+
+
+ +
+
+ele_write(element, text=None)
+

Over element perform send_keys , if not sended text, then will write +empty over element +:param element: WebElement +:return: None

+
+ +
+
+execute_js(script, *args)
+

Execute arbitrary Javascript code

+
+
Arguments:
+
script {str} – JS code to be executed on WebDriver +*args {[type]} – More arguments ( like element selector )
+
Returns:
+
str – JS script returns
+
+
+ +
+
+find_element(selector, locator='css selector')
+
+
Just divided execution ways for search web element
+
throught selenium
+
Arguments:
+
+
selector {str} – string selector used to locate one
+
element or first obtained
+
+
+
Keyword Arguments:
+
+
locator {By} – locator strategy used to find
+
WebElement selector (default: {By.CSS_SELECTOR})
+
+
+
Raises:
+

CoreException – If locator is None +CoreException – Element selector+locator strategy raises

+
+
selenium NoSuchElementException
+
+
Returns:
+
WebElement – selenium representation for a web element
+
+
+ +
+
+find_element_wait(selector, locator='css selector', driver_wait=None)
+
+
Search element using WebDriverWait class
+
and ElementConditions presence_of_element_located
+
Arguments:
+
+
selector {str} – string selector used to locate one
+
element or first obtained
+
+
+
Keyword Arguments:
+
+
locator {By} – locator strategy used to find
+
WebElement selector (default: {By.CSS_SELECTOR})
+
driver_wait {WebDriverWait} – driver that supports
+
ExpectedConditions methods (default: {None})
+
+
+
Raises:
+
+
CoreException – if NavBase instanced
+
without driver_wait
+
+
+
Returns:
+
+
WebElement – element through selenium
+
WebDriverWait class
+
+
+
+
+ +
+
+find_elements(selector, locator='css selector')
+
+
Just divided execution ways for search web elements
+
throught selenium
+
Arguments:
+
+
selector {str} – string selector used to locate
+
one or more elements
+
+
+
Keyword Arguments:
+
+
locator {By} – locator strategy used to find
+
WebElement selector (default: {By.CSS_SELECTOR})
+
+
+
Raises:
+

CoreException – If locator is None +CoreException – Element selector+locator strategy raises

+
+
selenium NoSuchElementException
+
+
Returns:
+
+
list(WebElement) – selenium representation for a
+
list of web elements
+
+
+
+
+ +
+
+forward()
+

Go forward using browser functionality

+
+ +
+
+get_capabilities()
+

Retrieve current capabilities applied to selenium driver

+
+ +
+
+get_current_url()
+

Return current url from opened bot

+
+
Raises:
+
+
CoreException – if can’t obtains url with this
+
selenium driver
+
+
+
Returns:
+
str – string representation of current driver url
+
+
+ +
+
+get_log(log_name='browser')
+
+
Get selenium log by name, this depends of
+
driver mode and browser what it’s using each time
+
Keyword Arguments:
+
log_name {str} – get log type lanes (default: {‘browser’})
+
Raises:
+
+
CoreException – if log_name value not in list
+
of valid values : browser, driver, client, server
+
+
+
Returns:
+
list() – list of messages typed on a log_name
+
+
+ +
+
+get_maximize_window()
+

Maximize browser window

+
+ +
+
+get_screenshot_as_base64()
+

Gets the screenshot of the current window as a base64 encoded string +which is useful in embedded images in HTML

+
+ +
+
+get_screenshot_as_file(file_name)
+
+
Gets the screenshot of the current window. Returns False
+
if there is any IOError, else returns True. Use full paths +in your filename.
+
Arguments:
+
+
file_name {str} – name of file path where
+
want to save screenshot
+
+
+
Returns:
+
list(byte) – file binary object of screenshot bytes
+
+
+ +
+
+get_screenshot_as_png()
+
+
Gets the screenshot of the current window as a
+
binary data.
+
Returns:
+
File – file binary object of screenshot with PNG format
+
+
+ +
+
+get_screenshot_save(file_name)
+
+
Gets the screenshot of the current window. Returns False
+
if there is any IOError, else returns True. +Use full paths in your filename.
+
Arguments:
+
+
file_name {str} – name of file path where
+
want to save screenshot
+
+
+
Returns:
+
list(byte) – file binary object of screenshot bytes
+
+
+ +
+
+get_title()
+

Obtains the title of the current page and return it

+
+
Returns:
+
str – title of current page opened
+
+
+ +
+
+get_url(url, wait_for_load=0)
+

Do get_url including implicit wait for page load

+
+ +
+
+get_window_handle()
+

Get window object to handle with selenium on scripts

+
+ +
+
+is_url(url, ignore_raises=True)
+

Check if url it’s the same what selenium current and visible url

+
+
Arguments:
+
url {str} – string value used to verify url
+
Keyword Arguments:
+
+
ignore_raises {bool} – allows to ignore errors
+
when executes if raises errors (default: {True})
+
+
+
Raises:
+
exceptions – [description] +CoreException – [description]
+
Returns:
+
+
bool – if current driver url match with param url,
+
then returns True, False if not
+
+
+
+
+ +
+
+js_set_timeout(timeout=60)
+
+
Set the amount of time that the script should wait during an
+
execute_async_script call before throwing an error.
+
Keyword Arguments:
+
+
timeout {int} – seconds to raise script
+
wait (default: {60})
+
+
+
+
+ +
+
+reload()
+

Go reload page using browser functionality

+
+ +
+
+set_css_rule(css_selector, css_prop, css_value, css_important=False, index=0)
+

Set new value for given CSS property name

+
+
Arguments:
+
css_selector {str} – CSS selector to apply rule +css_prop {str} – CSS property to be applied to rule +css_value {str} – CSS property value to be applied to rule
+
Keyword Arguments:
+
+
css_important {bool} – Allow to include ‘!important’
+
to rule (default: {False})
+
index {int} – Position to insert new CSS rule
+
on first stylesheet (default: {0})
+
+
+
Returns:
+
str – JS script returns
+
+
+ +
+
+set_web_element(new_attr_id)
+

Create web element using selenium adding to DOM

+
+
Arguments:
+
+
new_attr_id {str} – html attribute ID for
+
new web element
+
+
+
+
+ +
+
+set_window_size(pos_x=800, pos_y=600)
+
+
Sets the width and height of the current
+
window. (window.resizeTo)
+
Keyword Arguments:
+
pos_x {int} – width of new window size (default: {800}) +pos_y {int} – height of new window size (default: {600})
+
+
+ +
+ +
+
+
+

package: qacode.core.webs.controls

+
+

Class: ControlBase

+

Package module qacode.core.webs.control_base

+
+
+class qacode.core.webs.controls.control_base.ControlBase(bot, **kwargs)
+

Bases: object

+

Requirements: #35, #70

+
+
+attr_class = None
+
+ +
+
+attr_id = None
+
+ +
+
+bot = None
+
+ +
+
+clear()
+

Clear input element text value

+
+ +
+
+click()
+

Click on element

+
+ +
+
+element = None
+
+ +
+
+find_child(selector, locator='css selector')
+
+
Find child element using bot with default By.CSS_SELECTOR strategy
+
for internal element trought selenium WebElement
+
Arguments:
+
selector {str} – string search for locator type
+
Keyword Arguments:
+
+
locator {[selenium.webdriver.common.by.By]} – string type to
+
use on this selenium search request +(default: {By.CSS_SELECTOR})
+
+
+
Returns:
+
ControlBase – instanced base element using qacode library object
+
+
+ +
+
+get_attr_value(attr_name)
+

Search and attribute name over self.element and get value, +if attr_value is obtained, then compare and raise if not

+
+
Arguments:
+
+
attr_name {str} – find an attribute on WebElement
+
with this name
+
+
+
Returns:
+
str – value of html attr_name
+
+
+ +
+
+get_attrs(attr_names)
+

Find a list of attributes on WebElement +and returns a dict list of {name, value}

+
+
Arguments:
+
+
attr_names {list of str} – list of attr_name to search
+
for each one name and value on self.element
+
+
+
Returns:
+
dict – a dict list of {name, value}
+
+
+ +
+
+get_css_value(prop_name)
+

Allows to obtain CSS value based on CSS property name

+
+
Arguments:
+
prop_name {str} – CSS property name
+
Returns:
+
str – Value of CSS property searched
+
+
+ +
+
+get_tag()
+

Returns tag_name from Webelement

+
+ +
+
+get_text(on_screen=True)
+
+
Get element content text.
+
If the isDisplayed() method can sometimes trip over when +the element is not really hidden but outside the viewport +get_text() returns an empty string for such an element.
+
Keyword Arguments:
+
+
on_screen {bool} – allow to obtain text if element
+
it not displayed to this element before +read text (default: {True})
+
+
+
Returns:
+
str – Return element content text (innerText property)
+
+
+ +
+
+is_displayed = None
+
+ +
+
+is_enabled = None
+
+ +
+
+is_selected = None
+
+ +
+
+load_settings_keys(settings, update=False)
+

Load default setting for ControlBase instance

+
+ +
+
+locator = None
+
+ +
+
+name = None
+
+ +
+
+on_instance_load = None
+
+ +
+ +
+ +
+
+reload(**kwargs)
+

Reload ‘self.settings’ property:dict and call to instance +logic with new configuration

+
+ +
+
+selector = None
+
+ +
+
+set_css_value(prop_name, prop_value, css_important=True)
+
+
Set new value for given CSS property name
+
on ControlBase selector
+
Arguments:
+
prop_name {str} – CSS property name +prop_value {str} – CSS property value
+
Keyword Arguments:
+
+
css_important {bool} – Allow to include ‘!important’ to rule for
+
overrite others values applied (default: {True})
+
+
+
+
+ +
+
+settings = None
+
+ +
+
+tag = None
+
+ +
+
+text = None
+
+ +
+
+type_text(text, clear=False)
+

Type text on input element

+
+
Arguments:
+
text {str} – string to be typed on web element
+
Keyword Arguments:
+
clear {bool} – clear text element at enable key (default: {False})
+
+
+ +
+ +
+
+class qacode.core.webs.controls.control_base.ControlBase(bot, **kwargs)
+

Requirements: #35, #70

+
+
+clear()
+

Clear input element text value

+
+ +
+
+click()
+

Click on element

+
+ +
+
+find_child(selector, locator='css selector')
+
+
Find child element using bot with default By.CSS_SELECTOR strategy
+
for internal element trought selenium WebElement
+
Arguments:
+
selector {str} – string search for locator type
+
Keyword Arguments:
+
+
locator {[selenium.webdriver.common.by.By]} – string type to
+
use on this selenium search request +(default: {By.CSS_SELECTOR})
+
+
+
Returns:
+
ControlBase – instanced base element using qacode library object
+
+
+ +
+
+get_attr_value(attr_name)
+

Search and attribute name over self.element and get value, +if attr_value is obtained, then compare and raise if not

+
+
Arguments:
+
+
attr_name {str} – find an attribute on WebElement
+
with this name
+
+
+
Returns:
+
str – value of html attr_name
+
+
+ +
+
+get_attrs(attr_names)
+

Find a list of attributes on WebElement +and returns a dict list of {name, value}

+
+
Arguments:
+
+
attr_names {list of str} – list of attr_name to search
+
for each one name and value on self.element
+
+
+
Returns:
+
dict – a dict list of {name, value}
+
+
+ +
+
+get_css_value(prop_name)
+

Allows to obtain CSS value based on CSS property name

+
+
Arguments:
+
prop_name {str} – CSS property name
+
Returns:
+
str – Value of CSS property searched
+
+
+ +
+
+get_tag()
+

Returns tag_name from Webelement

+
+ +
+
+get_text(on_screen=True)
+
+
Get element content text.
+
If the isDisplayed() method can sometimes trip over when +the element is not really hidden but outside the viewport +get_text() returns an empty string for such an element.
+
Keyword Arguments:
+
+
on_screen {bool} – allow to obtain text if element
+
it not displayed to this element before +read text (default: {True})
+
+
+
Returns:
+
str – Return element content text (innerText property)
+
+
+ +
+
+load_settings_keys(settings, update=False)
+

Load default setting for ControlBase instance

+
+ +
+
+reload(**kwargs)
+

Reload ‘self.settings’ property:dict and call to instance +logic with new configuration

+
+ +
+
+set_css_value(prop_name, prop_value, css_important=True)
+
+
Set new value for given CSS property name
+
on ControlBase selector
+
Arguments:
+
prop_name {str} – CSS property name +prop_value {str} – CSS property value
+
Keyword Arguments:
+
+
css_important {bool} – Allow to include ‘!important’ to rule for
+
overrite others values applied (default: {True})
+
+
+
+
+ +
+
+type_text(text, clear=False)
+

Type text on input element

+
+
Arguments:
+
text {str} – string to be typed on web element
+
Keyword Arguments:
+
clear {bool} – clear text element at enable key (default: {False})
+
+
+ +
+ +
+
+

Class: ControlForm

+

Package module qacode.core.webs.control_form

+
+
+class qacode.core.webs.controls.control_form.ControlForm(bot, **kwargs)
+

Bases: qacode.core.webs.controls.control_base.ControlBase

+

Requirements: #63

+
+
+add_rules(strict_rules, typed=False)
+

Validate strict rules for each type

+
+
Arguments:
+

strict_rules {StrictRule} – strict_rule +on_instance_strict {bool} – if enabled, load values for

+
+
future checks
+
+
+
+ +
+
+dropdown = None
+
+ +
+
+load_settings_keys(settings, update=False)
+

Load default setting for ControlForm instance

+
+ +
+
+load_strict_attrs(strict_attrs=None)
+

Validate if element.attrs is in list of strict_attrs

+
+
Keyword Arguments:
+
strict_attrs {[type]} – [description] (default: {None})
+
Returns:
+
[type] – [description]
+
+
+ +
+
+load_strict_css_props(strict_css_props=None)
+

Validate if element.attrs is in list of strict_attrs

+
+
Keyword Arguments:
+
strict_css_props {[type]} – [description] (default: {None})
+
Returns:
+
[type] – [description]
+
+
+ +
+
+load_strict_tags(strict_tags=None)
+
+
Validate if element.tag is in list of strict_tags and
+

instance ControlForm specific properties

+

tag=select, instance down ‘dropdown’ property

+
+
Keyword Arguments:
+
strict_tags {[type]} – [description] (default: {None})
+
Returns:
+
[type] – [description]
+
+
+ +
+
+on_instance_strict = None
+
+ +
+
+parse_rules(strict_rules=None)
+

Parse array of configurations dicts of strict_rules to +instances list of StrictRule

+
+ +
+
+reload(**kwargs)
+

Reload ‘self.settings’ property:dict and call to instance +logic with new configuration

+
+ +
+
+strict_attrs = None
+
+ +
+
+strict_css_props = None
+
+ +
+
+strict_rules = None
+
+ +
+
+strict_rules_typed = None
+
+ +
+
+strict_tags = None
+
+ +
+ +
+
+class qacode.core.webs.controls.control_form.ControlForm(bot, **kwargs)
+

Requirements: #63

+
+
+add_rules(strict_rules, typed=False)
+

Validate strict rules for each type

+
+
Arguments:
+

strict_rules {StrictRule} – strict_rule +on_instance_strict {bool} – if enabled, load values for

+
+
future checks
+
+
+
+ +
+
+load_settings_keys(settings, update=False)
+

Load default setting for ControlForm instance

+
+ +
+
+load_strict_attrs(strict_attrs=None)
+

Validate if element.attrs is in list of strict_attrs

+
+
Keyword Arguments:
+
strict_attrs {[type]} – [description] (default: {None})
+
Returns:
+
[type] – [description]
+
+
+ +
+
+load_strict_css_props(strict_css_props=None)
+

Validate if element.attrs is in list of strict_attrs

+
+
Keyword Arguments:
+
strict_css_props {[type]} – [description] (default: {None})
+
Returns:
+
[type] – [description]
+
+
+ +
+
+load_strict_tags(strict_tags=None)
+
+
Validate if element.tag is in list of strict_tags and
+

instance ControlForm specific properties

+

tag=select, instance down ‘dropdown’ property

+
+
Keyword Arguments:
+
strict_tags {[type]} – [description] (default: {None})
+
Returns:
+
[type] – [description]
+
+
+ +
+
+parse_rules(strict_rules=None)
+

Parse array of configurations dicts of strict_rules to +instances list of StrictRule

+
+ +
+
+reload(**kwargs)
+

Reload ‘self.settings’ property:dict and call to instance +logic with new configuration

+
+ +
+ +
+
+
+

package: qacode.core.webs.pages

+
+

Class: PageBase

+

package module qacode.core.webs.pages.page_base

+
+
+class qacode.core.webs.pages.page_base.PageBase(bot, **kwargs)
+

Bases: object

+

Base class for all Inehrit Page classes wich need selenium functionality +througth qacode bot

+
+
+bot = None
+
+ +
+
+get_element(config_control)
+

Search element on Bot instance

+
+
Arguments:
+
config_controls {dict} – base dict for ControlBase class
+
Returns:
+
+
ControlBase – an element to be use
+
throught selenium
+
+
+
+
+ +
+
+get_elements(config_controls)
+
+
Search element on Bot instance, choose selector
+
from instance or locator param
+
Arguments:
+
config_controls {dict} – base dict for ControlBase class
+
Returns:
+
+
list(ControlBase) – an element to be use as wrapper
+
for selenium functionality
+
+
+
+
+ +
+
+go_url(url=None, wait_for_load=0)
+

Go to url, choose url from instance or locator params

+
+
Keyword Arguments:
+
+
url {str} – string of FQDN, if None, load value from settings
+
(default: {self.settings.get(‘url’)})
+
+

wait_for_load {int} – [description] (default: {0})

+
+
+
+ +
+
+is_url(url=None, ignore_raises=True)
+
+
Allows to check if current selenium visible url it’s the same
+
what self.url value
+
+ +++ + + + +
Attributes:
+
url: default page url but can be string
+

value used to verify url

+
+
+

ignore_raises: not raise exceptions if enabled

+
+
+ +
+
+log = None
+
+ +
+
+settings = None
+
+ +
+ +
+
+class qacode.core.webs.pages.page_base.PageBase(bot, **kwargs)
+

Base class for all Inehrit Page classes wich need selenium functionality +througth qacode bot

+
+
+get_element(config_control)
+

Search element on Bot instance

+
+
Arguments:
+
config_controls {dict} – base dict for ControlBase class
+
Returns:
+
+
ControlBase – an element to be use
+
throught selenium
+
+
+
+
+ +
+
+get_elements(config_controls)
+
+
Search element on Bot instance, choose selector
+
from instance or locator param
+
Arguments:
+
config_controls {dict} – base dict for ControlBase class
+
Returns:
+
+
list(ControlBase) – an element to be use as wrapper
+
for selenium functionality
+
+
+
+
+ +
+
+go_url(url=None, wait_for_load=0)
+

Go to url, choose url from instance or locator params

+
+
Keyword Arguments:
+
+
url {str} – string of FQDN, if None, load value from settings
+
(default: {self.settings.get(‘url’)})
+
+

wait_for_load {int} – [description] (default: {0})

+
+
+
+ +
+
+is_url(url=None, ignore_raises=True)
+
+
Allows to check if current selenium visible url it’s the same
+
what self.url value
+
+ +++ + + + +
Attributes:
+
url: default page url but can be string
+

value used to verify url

+
+
+

ignore_raises: not raise exceptions if enabled

+
+
+ +
+ +
+
+
+

package: qacode.core.testing

+
+

Class: TestInfoBase

+

Base module for inherit new Test Suites

+
+
+class qacode.core.testing.test_info.TestInfoBase
+

Bases: object

+

Base class for inherit new Test classes

+
+
+classmethod add_property(name, value=None)
+

Add property to test instance using param ‘name’, will setup +None if any value it’s passed by param

+
+ +
+
+assert_contains_url(actual, contains, msg=None, wait=0)
+

Allow to compare 2 urls and check if 1st contains 2nd url

+
+ +
+
+assert_equals(actual, expected, msg=None)
+

Allow to compare 2 values and check if 1st it’s equals to +2nd value

+
+ +
+
+assert_equals_url(actual, expected, msg=None, wait=0)
+

Allow to compare 2 urls and check if 1st it’s equals to 2nd url

+
+
Arguments:
+
actual {type} – actual value +expected {type} – expected value
+
Keyword Arguments:
+
+
wait {int} – Wait time on Runtime execution before execute
+
next lane of code (default: {0})
+
+
+
Raises:
+
AssertionError – [description]
+
+
+ +
+
+assert_false(actual, msg=None)
+

Allow to compare and check if value it’s equals to ‘False’

+
+ +
+
+assert_greater(actual, greater, msg=None)
+

Allow to encapsulate method assertGreater(a, b, msg=msg)

+
+ +
+
+assert_in(actual, valid_values, msg=None)
+

Allow to compare if value it’s in to 2nd list of values

+
+ +
+
+assert_is_instance(instance, class_type, msg=None)
+

Allow to encapsulate method assertIsInstance(obj, cls, msg=’‘)

+
+ +
+
+assert_lower(actual, lower, msg=None)
+

Allow to encapsulate method assertLower(a, b, msg=msg)

+
+ +
+
+assert_none(actual, msg=None)
+

Allow to compare and check if value it’s equals to ‘None’

+
+ +
+
+assert_not_contains_url(actual, contains, msg=None, wait=0)
+

Allow to compare 2 urls and check if 1st not contains 2nd url

+
+ +
+
+assert_not_equals(actual, expected, msg=None)
+

Allow to compare 2 value to check if 1st isn’t equals to +2nd value

+
+ +
+
+assert_not_equals_url(actual, expected, msg=None, wait=0)
+

Allow to compare 2 urls to check if 1st isn’t equals to 2nd url

+
+ +
+
+assert_not_in(actual, invalid_values, msg=None)
+

Allow to compare if value it’s not in to 2nd list of values

+
+ +
+
+assert_not_none(actual, msg=None)
+

Allow to compare and check if value it’s not equals to ‘None’

+
+ +
+
+assert_not_regex(actual, pattern, msg=None)
+

Allow to compare if value not match pattern

+
+ +
+
+assert_path_exist(actual, is_dir=True, msg=None)
+

Allow to check if path exist, can check if is_dir also

+
+ +
+
+assert_path_not_exist(actual, msg=None)
+

Allow to check if path not exist, can check if is_dir also

+
+ +
+
+assert_raises(expected_exception, function, *args, **kwargs)
+
+
Allow to encapsulate pytest.raises method(
+
+
*args=(
+
expected_exception, +function,
+
+

), +**kwargs={

+
+
msg: ASSERT_MSG_DEFAULT
+

}

+
+
+

)

+
+ +
+
+assert_regex(actual, pattern, msg=None)
+

Allow to compare if value match pattern

+
+ +
+
+assert_regex_url(actual, pattern=None, msg=None)
+

Allow to compare if value match url pattern, can use +custom pattern

+
+ +
+
+assert_true(actual, msg=None)
+

Allow to compare and check if value it’s equals to ‘True’

+
+ +
+
+classmethod bot_close(bot)
+

Close bot calling bot.close() from param

+
+ +
+
+classmethod bot_open(config)
+

Open browser using BotBase instance

+
+
Returns:
+
BotBase – wrapper browser handler for selenium
+
+
+ +
+
+config = None
+
+ +
+
+is_loaded = False
+
+ +
+
+classmethod load(config)
+

Load default config dict

+
+ +
+
+log = None
+
+ +
+
+classmethod settings_app(app_name)
+

Obtain inherit dict from ‘cls.config’ dict named +‘config.tests.apps’ filtering by ‘app_name’ param

+
+ +
+
+classmethod settings_apps()
+

Obtain inherit dict from ‘cls.config’ dict named +‘config.tests.apps’

+
+ +
+
+classmethod settings_control(control_name, page_name=None, app_name=None)
+

Obtain inherit dict from ‘cls.config’ dict named +‘config.tests.apps[i].pages[j].controls’ filtering by +‘control_name’ param

+
+ +
+
+classmethod settings_page(page_name, app_name=None)
+

Obtain inherit dict from ‘cls.config’ dict named +‘config.tests.apps[i].pages’ filtering by ‘page_name’ param

+
+ +
+
+setup_method(test_method, **kwargs)
+

Configure self.attribute

+
+ +
+
+sleep(wait=0)
+

Just call to native python time.sleep method

+
+
Keyword Arguments:
+
+
wait {int} – Wait time on Runtime execution before execute
+
next lane of code (default: {0})
+
+
+
+
+ +
+
+teardown_method(test_method)
+

Unload self.attribute

+
+ +
+
+timer(wait=5, print_each=5)
+

Timer to sleep browser on testcases

+
+
Keyword Arguments:
+

wait {int} – seconds to wait (default: {5}) +print_each {int} – print message each seconds, must be divisible

+
+
by 5, negatives are accepted (default: {5})
+
+
Raises:
+
Exception – [description]
+
+
+ +
+ +
+
+class qacode.core.testing.test_info.TestInfoBot
+

Bases: qacode.core.testing.test_info.TestInfoBase

+

Inherit class what implements bot on each testcase

+
+
+bot = None
+
+ +
+
+setup_method(test_method, **kwargs)
+

Configure self.attribute. +If skipIf mark applied and True as first param for args tuple

+
+
then not open bot
+
+ +
+
+teardown_method(test_method, close=True)
+

Unload self.attribute, also close bot

+
+ +
+ +
+
+class qacode.core.testing.test_info.TestInfoBotUnique
+

Bases: qacode.core.testing.test_info.TestInfoBot

+

Inherit class what implements bot on each testcase

+
+
+classmethod setup_class(**kwargs)
+

Configure ‘cls.attribute’. If name start with ‘test_’ and have +decorator skipIf with value True, then not open bot

+
+ +
+
+classmethod teardown_class()
+

Unload self.attribute, closing bot from ‘cls.bot’ property

+
+ +
+
+teardown_method(test_method, close=False)
+

Unload self.attribute, also disable closing bot from TestInfoBot

+
+ +
+ +
+
+class qacode.core.testing.test_info.TestInfoBase
+

Base class for inherit new Test classes

+
+
+classmethod add_property(name, value=None)
+

Add property to test instance using param ‘name’, will setup +None if any value it’s passed by param

+
+ +
+
+assert_contains_url(actual, contains, msg=None, wait=0)
+

Allow to compare 2 urls and check if 1st contains 2nd url

+
+ +
+
+assert_equals(actual, expected, msg=None)
+

Allow to compare 2 values and check if 1st it’s equals to +2nd value

+
+ +
+
+assert_equals_url(actual, expected, msg=None, wait=0)
+

Allow to compare 2 urls and check if 1st it’s equals to 2nd url

+
+
Arguments:
+
actual {type} – actual value +expected {type} – expected value
+
Keyword Arguments:
+
+
wait {int} – Wait time on Runtime execution before execute
+
next lane of code (default: {0})
+
+
+
Raises:
+
AssertionError – [description]
+
+
+ +
+
+assert_false(actual, msg=None)
+

Allow to compare and check if value it’s equals to ‘False’

+
+ +
+
+assert_greater(actual, greater, msg=None)
+

Allow to encapsulate method assertGreater(a, b, msg=msg)

+
+ +
+
+assert_in(actual, valid_values, msg=None)
+

Allow to compare if value it’s in to 2nd list of values

+
+ +
+
+assert_is_instance(instance, class_type, msg=None)
+

Allow to encapsulate method assertIsInstance(obj, cls, msg=’‘)

+
+ +
+
+assert_lower(actual, lower, msg=None)
+

Allow to encapsulate method assertLower(a, b, msg=msg)

+
+ +
+
+assert_none(actual, msg=None)
+

Allow to compare and check if value it’s equals to ‘None’

+
+ +
+
+assert_not_contains_url(actual, contains, msg=None, wait=0)
+

Allow to compare 2 urls and check if 1st not contains 2nd url

+
+ +
+
+assert_not_equals(actual, expected, msg=None)
+

Allow to compare 2 value to check if 1st isn’t equals to +2nd value

+
+ +
+
+assert_not_equals_url(actual, expected, msg=None, wait=0)
+

Allow to compare 2 urls to check if 1st isn’t equals to 2nd url

+
+ +
+
+assert_not_in(actual, invalid_values, msg=None)
+

Allow to compare if value it’s not in to 2nd list of values

+
+ +
+
+assert_not_none(actual, msg=None)
+

Allow to compare and check if value it’s not equals to ‘None’

+
+ +
+
+assert_not_regex(actual, pattern, msg=None)
+

Allow to compare if value not match pattern

+
+ +
+
+assert_path_exist(actual, is_dir=True, msg=None)
+

Allow to check if path exist, can check if is_dir also

+
+ +
+
+assert_path_not_exist(actual, msg=None)
+

Allow to check if path not exist, can check if is_dir also

+
+ +
+
+assert_raises(expected_exception, function, *args, **kwargs)
+
+
Allow to encapsulate pytest.raises method(
+
+
*args=(
+
expected_exception, +function,
+
+

), +**kwargs={

+
+
msg: ASSERT_MSG_DEFAULT
+

}

+
+
+

)

+
+ +
+
+assert_regex(actual, pattern, msg=None)
+

Allow to compare if value match pattern

+
+ +
+
+assert_regex_url(actual, pattern=None, msg=None)
+

Allow to compare if value match url pattern, can use +custom pattern

+
+ +
+
+assert_true(actual, msg=None)
+

Allow to compare and check if value it’s equals to ‘True’

+
+ +
+
+classmethod bot_close(bot)
+

Close bot calling bot.close() from param

+
+ +
+
+classmethod bot_open(config)
+

Open browser using BotBase instance

+
+
Returns:
+
BotBase – wrapper browser handler for selenium
+
+
+ +
+
+classmethod load(config)
+

Load default config dict

+
+ +
+
+classmethod settings_app(app_name)
+

Obtain inherit dict from ‘cls.config’ dict named +‘config.tests.apps’ filtering by ‘app_name’ param

+
+ +
+
+classmethod settings_apps()
+

Obtain inherit dict from ‘cls.config’ dict named +‘config.tests.apps’

+
+ +
+
+classmethod settings_control(control_name, page_name=None, app_name=None)
+

Obtain inherit dict from ‘cls.config’ dict named +‘config.tests.apps[i].pages[j].controls’ filtering by +‘control_name’ param

+
+ +
+
+classmethod settings_page(page_name, app_name=None)
+

Obtain inherit dict from ‘cls.config’ dict named +‘config.tests.apps[i].pages’ filtering by ‘page_name’ param

+
+ +
+
+setup_method(test_method, **kwargs)
+

Configure self.attribute

+
+ +
+
+sleep(wait=0)
+

Just call to native python time.sleep method

+
+
Keyword Arguments:
+
+
wait {int} – Wait time on Runtime execution before execute
+
next lane of code (default: {0})
+
+
+
+
+ +
+
+teardown_method(test_method)
+

Unload self.attribute

+
+ +
+
+timer(wait=5, print_each=5)
+

Timer to sleep browser on testcases

+
+
Keyword Arguments:
+

wait {int} – seconds to wait (default: {5}) +print_each {int} – print message each seconds, must be divisible

+
+
by 5, negatives are accepted (default: {5})
+
+
Raises:
+
Exception – [description]
+
+
+ +
+ +
+
+ +
+
+ + +