QAutomate keyword library¶
-
class
webframework.extension.util.common_utils.
AndroidAsserts
(driver_cache=None)¶ Class that contains methods for making Android verifications
-
verify_text
(element, value)¶ Verifies if text in the element corresponds to expected one
-
verify_value
(element, value)¶ Verifies if value of element corresponds to expected one
-
-
class
webframework.extension.util.common_utils.
AndroidMethods
(driver_cache=None)¶ Class that contains methods for Android
-
add_dynamic_content_to_parameters
(parameters, name, value, section=None)¶ Add dynamic content to parameters dictionary
dynamic content is available in current test run
Parameters: - parameters – Parameters dictionary
- name – Name for added parameter as string
- value – Value for added parameter as string
- section – Optional section where parameter is added as string
Example: Page model level exampleself.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value")
self.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value", "my_section")
Using dynamic valueself.add_dynamic_content_to_parameters(self.ELEMENT_NAME, parameters["param_name"])
Test level exampleself.common_utils.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value")
self.common_utils.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value", "my_section")
Using dynamic valueself.trial.login(TESTDATA["my_section"])
-
android_back_key
(element)¶ Press BACK key in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_home_key
(element)¶ Press HOME key in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_power_key
(element)¶ Press POWER key in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_scroll_down
(element)¶ Scroll down in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_scroll_up
(element)¶ Scroll up in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_slide_center_to_bottom
(element)¶ Slide from element center to the bottom in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_slide_center_to_left
(element)¶ Slide from element center to the left in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_slide_center_to_right
(element)¶ Slide from element center to the right in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_slide_center_to_top
(element)¶ Slide from element center to the top in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_swipe_left_to_right
(element)¶ Swipe from left to right in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_swipe_right_to_left
(element)¶ Swipe from right to left in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_tap
(element)¶ Tap on element center in android native application
Parameters: element – Element representation (By, value) or WebElement
-
click_element
(element, to_print=True)¶ Click at element
Parameters: - element – Element representation (By, value) or WebElement
- to_print – Flag, if True prints action message
Example: Page model levelusing web elementself.click_element(self.TRIAL)
using representationself.click_element((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementself.common_utils.click_element(self.trial.TRIAL)
-
click_element_at_coordinates
(element, x, y, to_print=True)¶ Clicks at the specified coordinates at element
Parameters: - element – Element representation (By, value) or WebElement
- x – x-coordinate
- y – y-coordinate
- to_print – Flag, if True prints action message
Example: Page model levelusing web elementself.click_element_at_coordinates(self.TRIAL, 1, 1)
using representationself.click_element_at_coordinates((By.LINK_TEXT, u'Trial'), 1, 1)
Test levelusing web elementself.common_utils.click_element_at_coordinates(self.trial.TRIAL, 1, 1)
-
close_all_browsers
()¶ Closes all opened browsers
Example: Page model level exampleself.close_all_browsers()
Test level exampleself.common_utils.close_all_browsers()
-
close_browser
()¶ Closes current active browser
Example: Page model level exampleself.close_browser()
Test level exampleself.common_utils.close_browser()
-
compare_element_screenshots
(element, ref_scr_name)¶ Compares screenshots of elements
Parameters: - element – Element representation (By, value) or WebElement
- ref_scr_name – Screenshot name in string format
Example: Page model level example self.compare_element_screenshots(self.TRIAL,"ref_scr_name")
-
compare_screenshots
(ref_scr_name)¶ Compares screenshots or part of screenshots
Parameters: ref_scr_name – Screenshot name in string format Example: Page model level exampleself.compare_screenshots("ref_scr_name")
Test level exampleself.common_utils.compare_screenshots("ref_scr_name")
-
double_click_element
(element, to_print=True)¶ Double click at element
Parameters: - element – Element representation (By, value) or WebElement
- to_print – Flag, if True prints action message
Example: Page model level exampleusing web elementself.double_click_element(self.TRIAL)
using representationself.double_click_element((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementself.common_utils.double_click_element(self.trial.TRIAL)
-
execute_async_javascript
(js_script, log=True)¶ Execute async JavaScript code
Parameters: - js_script – String represents JavaScript code
- log – Flag, if True prints action message
Returns: Object return by JavaScript code else None
-
execute_javascript
(js_script, log=True)¶ Execute JavaScript code
Parameters: - js_script – String represents JavaScript code
- log – Flag, if True prints action message
Returns: Object return by JavaScript code else None
Example: age model level examplevalue = self.execute_javascript("run_function(variable)")
Test level examplevalue = self.common_utils.execute_javascript("run_function(variable)")
-
fail
(message)¶ Message to print in report as a String
Parameters: message – Message to print as a string. Example: Page model level exampleself.fail("My message")
Test level exampleself.common_utils.fail("My message")
-
find_element
(element)¶ Return found WebElement
Parameters: element – Element representation (By, value) or WebElement Returns: WebElement Example: Page model levelelement = self.find_element((By.LINK_TEXT, u'Trial'))
-
find_elements
(element)¶ Return found list of WebElement’s
Parameters: element – Element representation (By, value) or WebElement Returns: List of WebElement’s Example: Page model levelall_elements = self.find_elements((By.CSS_SELECTOR, u"img"))
-
generate_zap_test_report
(installation_dir, session_name, report_name='qautomate_zap_report.html')¶ Generate zap test report html
Note
Zapproxy UI and python client must be installed
Parameters: - installation_dir – Zap installation dir
- session_name – Zap session name
- report_name – Zap report name
Example: Test level examplezap, zap_session = self.common_utils.start_zapproxy_daemon('C:\ZedAttackProxy\zap.bat')
self.common_utils.stop_zapproxy_daemon(zap)
self.oommon_utils.generate_zap_test_report('C:\ZedAttackProxy\zap.bat', zap_session)
or self.common_utils.generate_zap_test_report('C:\ZedAttackProxy\zap.bat', zap_session, "qautomate_zap.html")
-
get_android_element_center
(element)¶ Returns midpoint coordinates of an android element
Parameters: element – Element representation (By, value) or WebElement Returns: midpoint coordinates of an android element
-
get_android_element_coordinates
(element)¶ Returns coordinates top left and bottom right corner of an android element
Parameters: element – Element representation (By, value) or WebElement Returns: coordinates top left and bottom right corner of an android element
-
get_android_element_name
(element)¶ Returns name of an android element
Parameters: element – Element representation (By, value) or WebElement Returns: name of an android element
-
get_dom_element_count
(log=True)¶ Counting DOM-elements
Returns: Returns number of DOM-elements on web page. Example: Page model level exampleself.get_dom_element_count()
Test level exampleself.common_utils.get_dom_element_count()
-
get_measurements
(measurement_name)¶ Return measurements
Parameters: measurement_name – String represents name of measurement point Returns: Measured time in specific point Example: Page model level exampleself.get_measurements("trial")
Test level exampleself.common_utils.get_measurements("trial")
-
get_resource_timings
(measurement_name)¶ Return resource timings
Parameters: measurement_name – String represents name of measurement point Returns: Measured time in specific resource Example: Page model level exampleself.get_resource_timings("trial")
Test level exampleself.common_utils.get_resource_timings("trial")
-
get_soap_response
(url, request_file_xml)¶ Gets SOAP response from web service to be used in verify_soap_api
Parameters: - url – Web service url
- request_file_xml – Request xml file in ../data/soap/requests/
Example: Page model level examplevalue = self.get_soap_response(u'http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL', u'soap_xml.xml')
Test level examplevalue = self.common_utils.get_soap_response(u'http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL', u'soap_xml.xml')
-
get_text
(element)¶ Return element’s text
Parameters: element – Element representation (By, value) or WebElement Returns: Text of element Example: Page model level exampleusing web elementvalue = self.get_text(self.TRIAL)
using representationvalue = self.get_text((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementvalue = self.common_utils.get_text(self.trial.TRIAL)
-
get_text_length
(element)¶ Return element text length. Spaces are also counted.
Parameters: element – Element representation (By, value) or WebElement Returns: WebElement text length as integer Example: Page model level exampleusing web elementvalue = self.get_text_length(self.TRIAL)
using representationvalue = self.get_text_length((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementvalue = self.common_utils.get_text_length(self.trial.TRIAL)
-
get_timestamp
()¶ Return timestamp
Format: ‘yyyyMMddhhmmss’ Returns: String which represents current time Example: Page model level examplevalue = self.get_timestamp()
Test level examplevalue = self.common_utils.get_timestamp()
-
get_value
(element)¶ Return element’s value
Parameters: element – Element representation (By, value) or WebElement Returns: Value of element Example: Page model level exampleusing web elementvalue = self.get_value(self.TRIAL)
using representationvalue = self.get_value((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementvalue = self.common_utils.get_value(self.trial.TRIAL)
-
get_web_response
(url, method, auth_file, data)¶ Return response from web service
Parameters: - url – Web service url
- method – Rest-api method. Get, post, put or delete.
- auth_file – Optional name of the auth_file. Blank if not needed.
- data – Optional data for request as string.
Returns: Web response from server
Example: Page model level examplevalue = self.get_web_response(u'http://api.openweathermap.org/data/2.5/weather?q=London&mode=xml', u'get', u'auth_file.txt', u'')
Test level examplevalue = self.common_utils.get_web_response(u'http://api.openweathermap.org/data/2.5/weather?q=London&mode=xml', u'get', u'auth_file.txt', u'')
-
go_to
(url, log=True)¶ Open specified url
Parameters: - url – Url to open
- log – Flag, if True prints action message
Example: Page model level exampleself.go_to("http://qautomate.fi/")
Test level exampleself.common_utils.go_to("http://qautomate.fi/")
-
ignore_fail
(enable=True)¶
-
input_text
(element, value, to_print=True)¶ Clear and types text to input element
Parameters: - element – Element representation (By, value) or WebElement
- value – String to type in
- to_print – Flag, if True prints action message
Example: Page model levelusing web elementself.input_text(self.ID_CONTACT_FIRST_NAME, "this is value")
using representationself.input_text((By.ID, u'contact_first_name'), "this is value")
Test levelusing web elementself.common_utils.input_text(self.trial.ID_CONTACT_FIRST_NAME, "this is value")
-
is_disabled
(element, timeout=None)¶ Return disability of element.
Parameters: - element – Element representation (By, value) or WebElement.
- timeout – No timeout used, unless custom value provided.
Returns: True if element disabled, else - False.
Example: Page model level exampleusing web elementself.is_disabled(self.TRIAL)
using representationself.is_disabled((By.LINK_TEXT, u'Trial'))
using timeoutself.is_disabled(self.TRIAL, 10)
self.is_disabled((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.is_disabled(self.trial.TRIAL)
using timeoutself.common_utils.is_disabled(self.trial.TRIAL, 10)
-
is_enabled
(element, timeout=None)¶ Return enablity of element.
Parameters: - element – Element representation (By, value) or WebElement.
- timeout – No timeout used, unless custom value provided.
Returns: True if element enabled, else - False.
Example: Page model level exampleusing web elementself.is_enabled(self.TRIAL)
using representationself.is_enabled((By.LINK_TEXT, u'Trial'))
using timeoutself.is_enabled(self.TRIAL, 10)
self.is_enabled((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.is_enabled(self.trial.TRIAL)
using timeoutself.common_utils.is_enabled(self.trial.TRIAL, 10)
-
is_visible
(element, timeout=None)¶ Return visibility of element.
Parameters: - element – Element representation (By, value) or WebElement.
- timeout – No timeout used, unless custom value provided.
Returns: visibility of element. True or False.
Example: Page model level exampleusing web elementself.is_visible(self.TRIAL)
using representationself.is_visible((By.LINK_TEXT, u'Trial'))
using timeoutself.is_visible(self.TRIAL, 10)
self.is_visible((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.is_visible(self.trial.TRIAL)
using timeoutself.common_utils.is_visible(self.trial.TRIAL, 10)
-
measure_async_screen_response_time
(measurement_name, timeout, reference_picture, element=None)¶ Return page loading time based on screenshot verification
Parameters: - measurement_name – String represents name of measure point
- timeout – Int represents how long (in seconds) to take screenshots
- reference_picture – String represents name of the reference picture
- element – Tuple represents element: (By, ‘value’)
Returns: return Time in seconds how long takes to find correct screenshot or if no match found return False
Example: Page model levelself.measure_async_screen_response_time("trial", 10, "trial_perf_pic")
Test levelself.common_utils.measure_async_screen_response_time("trial", 10, "trial_perf_pic")
-
open_browser
(browser_name=None, url=None, alias=None, size=None)¶ Open specified browser with url
Parameters: - browser_name – Browser to open
- url – Url to open
- alias – save driver with alias
- size – Browser window size. Fullscreen if none.
Returns: id
Example: Page model level exampleself.open_browser("ff", http://qautomate.fi/")
Test level exampleself.common_utils.open_browser("ff", "http://qautomate.fi/")
-
open_url
(url, log=True)¶ Open specified url
Parameters: - url – Url to open
- log – Flag, if True prints action message
Example: Page model level exampleself.open_url("http://qautomate.fi/")
Test level exampleself.common_utils.open_url("http://qautomate.fi/")
-
robot_script_runner
(robot_script)¶ Runs robot framework scripts
Parameters: robot_script – Robot framework script Example: Page model levelself.robot_script_runner("C:\Users\username\Documents\script.robot")
Test level exampleself.common_utils.robot_script_runner("C:\Users\username\Documents\script.robot")
-
send_keys
(element, value, to_print=True)¶ Type value to element
Parameters: - element – Element representation (By, value) or WebElement
- value – Value to type in to the element
- to_print – Flag, if True prints action message
Example: Page model levelusing web elementself.send_keys(self.ID_CONTACT_FIRST_NAME, "this is value")
using representationself.send_keys((By.ID, u'contact_first_name'), "this is value")
Test levelusing web elementself.common_utils.send_keys(self.trial.ID_CONTACT_FIRST_NAME, "this is value")
-
start_zapproxy_daemon
(installation_dir)¶ Start Zap proxy daemon
Note
Zapproxy UI and python client must be installed
Parameters: installation_dir – Zapproxy installation folder Returns: Zap daemon object, zap session name Example: Page model level examplezap, zap_session = self.start_zapproxy_daemon('C:\ZedAttackProxy\zap.bat')
Test level examplezap, zap_session = self.common_utils.start_zapproxy_daemon('C:\ZedAttackProxy\zap.bat')
-
stop_zapproxy_daemon
(zap)¶ Stop Zap proxy daemon
Note
Zapproxy UI and python client must be installed
Parameters: zap – Zap proxy object Example: Test level examplezap, zap_session = self.common_utils.start_zapproxy_daemon('C:\ZedAttackProxy\zap.bat')
self.common_utils.stop_zapproxy_daemon(zap)
-
switch_browser
(id_or_alias)¶ Switch between active browsers using id or alias
Parameters: id_or_alias – Identify new active browser Example: Page model level example with idid = self.open_browser("ff", "http://qautomate.fi/")
id2 = self.open_browser("ff", "http://qautomate.fi/")
run some stepsself.switch_browser(id)
Test level example with aliasself.common_utils.open_browser("ff", "http://qautomate.fi/", "alias1")
self.common_utils.open_browser("ff", "http://qautomate.fi/", "alias2")
run some stepsself.common_utils.switch_browser("alias1")
-
triple_click_element
(element, to_print=True)¶ Triple click at element
Parameters: - element – Element representation (By, value) or WebElement
- to_print – Flag, if True prints action message
Example: Page model level exampleusing web elementself.triple_click_element(self.TRIAL)
using representationself.triple_click_element((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementself.common_utils.triple_click_element(self.trial.TRIAL)
-
wait_until_element_is_disabled
(element, timeout=None, msg=None)¶ Wait until element is disabled.
Parameters: - element – Element representation (By, value) or WebElement object.
- timeout – Uses default timeout, unless custom value provided.
- msg – Message if element is not disabled
Exception: If time exceeds DEFAULT_TIMEOUT, then rise exception.
Example: Page model level exampleusing web elementself.wait_until_element_is_disabled(self.TRIAL)
using representationself.common_utils.wait_until_element_is_disabled((By.LINK_TEXT, u'Trial'))
using timeoutself.wait_until_element_is_disabled(self.TRIAL, 10)
self.wait_until_element_is_disabled((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.wait_until_element_is_disabled(self.trial.TRIAL)
using timeoutself.common_utils.wait_until_element_is_disabled(self.trial.TRIAL, 10)
-
wait_until_element_is_enabled
(element, timeout=None, msg=None)¶ Wait until element is enabled.
Parameters: - element – Element representation (By, value) or WebElement object.
- timeout – Uses default timeout, unless custom value provided.
- msg – Message if element is not enabled.
Exception: If time exceeds DEFAULT_TIMEOUT, then rise exception.
Example: Page model level exampleusing web elementself.wait_until_element_is_enabled(self.TRIAL)
using representationself.common_utils.wait_until_element_is_enabled((By.LINK_TEXT, u'Trial'))
using timeoutself.wait_until_element_is_enabled(self.TRIAL, 10)
self.wait_until_element_is_enabled((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.wait_until_element_is_enabled(self.trial.TRIAL)
using timeoutself.common_utils.wait_until_element_is_enabled(self.trial.TRIAL, 10)
-
wait_until_element_is_not_visible
(element, timeout=None, msg=None)¶ Wait until element specified is not visible
Parameters: - element – Element representation (By, value) or WebElement object.
- timeout – Uses default timeout, unless custom value provided.
- msg – Message if element is visible
Exception: If time exceeds DEFAULT_TIMEOUT, then rise exception.
Example: Page model level exampleusing web elementself.wait_until_element_is_not_visible(self.TRIAL)
using representationself.common_utils.wait_until_element_is_not_visible((By.LINK_TEXT, u'Trial'))
using timeoutself.wait_until_element_is_not_visible(self.TRIAL, 10)
self.wait_until_element_is_not_visible((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.wait_until_element_is_not_visible(self.trial.TRIAL)
using timeoutself.common_utils.wait_until_element_is_not_visible(self.trial.TRIAL, 10)
-
wait_until_element_is_visible
(element, timeout=None, msg=None)¶ Wait until element specified is visible
Parameters: - element – Element representation (By, value) or WebElement object.
- timeout – Uses default timeout, unless custom value provided.
- msg – Message if element is not visible
Exception: If time exceeds DEFAULT_TIMEOUT, then rise exception.
Example: Page model level exampleusing web elementself.wait_until_element_is_visible(self.TRIAL)
using representationself.common_utils.wait_until_element_is_visible((By.LINK_TEXT, u'Trial'))
using timeoutself.wait_until_element_is_visible(self.TRIAL, 10)
self.wait_until_element_is_visible((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.wait_until_element_is_visible(self.trial.TRIAL)
using timeoutself.common_utils.wait_until_element_is_visible(self.trial.TRIAL, 10)
-
warning
(message)¶ Adds warning to test report
Parameters: message – Message to print as a String Example: Page model level exampleself.warning("My message")
Test level exampleself.common_utils.warning("My message")
-
-
class
webframework.extension.util.common_utils.
AndroidWrappers
(driver_cache=None)¶ -
android_back_key
(element)¶
-
android_home_key
(element)¶
-
android_power_key
(element)¶
-
android_scroll_down
(element)¶
-
android_scroll_up
(element)¶
-
android_slide_center_to_bottom
(element)¶
-
android_slide_center_to_left
(element)¶
-
android_slide_center_to_right
(element)¶
-
android_slide_center_to_top
(element)¶
-
android_swipe_left_to_right
(element)¶
-
android_swipe_right_to_left
(element)¶
-
android_tap
(element)¶
-
click_element
(element)¶
-
click_element_at_coordinates
(x, y)¶
-
compare_element_screenshots
(element, parameters)¶
-
compare_screenshots
(parameters)¶
-
element_should_be
(element, parameters)¶
-
element_value_should_be
(element, parameters)¶
-
fail
(message)¶
-
input_text
(element, parameters)¶
-
send_keys
(element, parameters)¶
-
wait_until_element_is_visible
(element)¶
-
-
class
webframework.extension.util.common_utils.
Asserts
(driver_cache=None)¶ Class that contains methods for making verifications
-
checkbox_should_be_selected
(element)¶ Check radiobutton is selected.
Parameters: element – Radiobutton element Example: self.checkbox_should_be_selected(self.CLASS_RADIO)
-
checkbox_should_not_be_selected
(element)¶ Check radiobutton is not selected.
Parameters: element – Radiobutton element Example: self.checkbox_should_not_be_selected(self.CLASS_RADIO)
-
element_attribute_should_be
(element, attribute, value)¶ Verifies if attribute of element corresponds to expected one
Parameters: - element – Element representation (By, value).
- attribute – Attribute of an element
- value – String text
Example: self.wait_until_element_should_not_be(self.element, attribute, value)
-
element_attribute_should_contains
(element, attr, expected_value)¶ Verify if attribute contains expected value
Parameters: - element – Element representation (By, value) or WebElement.
- attr – Element’s attribute
- expected_value – Element’s attribute value which should be contained
Example: self.element_attribute_should_contains(self.CONTACT_QAUTOMATE_FI, u'href', u'mailto')
-
element_should_be_disabled
(element)¶ Verify that element is disabled.
Use
unittest.assertTrue()
to verify that element is disabled.Parameters: element – Element representation (By, value). Example: rcm = (By.ID, "map-player-rcMenu")
element_should_be_disabled(self, rcm)
-
element_should_be_enabled
(element)¶ Verify that element is enabled.
Use
unittest.assertTrue()
to verify that element is disabled.Parameters: element – Element representation (By, value). Example: rcm = (By.ID, "map-player-rcMenu")
element_should_be_enabled(self, rcm)
-
element_should_be_present
(element)¶ Verify that element is present.
Use
unittest.assertTrue()
to verify that element is present.Parameters: element – Element representation (By, value). Example: rcm = (By.ID, "map-player-rcMenu")
element_should_be_present(self, rcm)
-
element_should_be_table_column_and_row
(element, text, column, row, cell='TD')¶ Verify that text from selected table column and row.
Use
unittest.assert_equal()
to verify that text is correct.Parameters: - element – Table element representation (By, value) or WebElement object.
- text – Element’s text which should be
- column – Table column where to verify text
- row – Table row where to verify text
- cell – Xpath to element where text should be, default is ‘TD’
Example: TABLE = (By.ID, "my-table")
element_should_be_table_column_and_row(self, TABLE, "text_to_verify", 2, 1)
-
element_should_be_visible
(element)¶ Verify that element is visible.
Use
unittest.assertTrue()
to verify that element is visible.Parameters: element – Element representation (By, value). Example: rcm = (By.ID, "map-player-rcMenu")
element_should_be_visible(self, rcm)
-
element_should_contain
(element, text)¶ Verifies if text in element contains given text
Parameters: - element – Element representation (By, value).
- text – String text
Example: self.element_should_contain(self.CLASS_MAIN_HEADER, text)
-
element_text_length_should_be
(element, expected_length)¶ Verifies if element text length is equal to expected. Spaces are also counted.
Parameters: - element – Element representation (By, value) or WebElement
- expected_length – User provided expected length
Example: self.verify_text_length(self.FEATURELIST_FEATURE, u'13')
-
element_text_should_be
(element, text)¶ Verifies if text in element corresponds to expected one
Parameters: - element – Element representation (By, value).
- text – String text
Example: self.element_text_should_be(self.element, text)
-
element_value_should_be
(element, value)¶ Verifies if value of element corresponds to expected one
Parameters: - element – Element representation (By, value).
- value – String
Example: self.element_text_should_be(self.element, value)
-
elements_count_should_be
(element, value_int)¶ Verifies if count of elements corresponds to expected one
Parameters: - element – Element representation (By, value).
- value_int – Integer number
Example: self.elements_count_should_be(self.element, value_int)
-
list_label_should_be
(element, text)¶ Verifies if text of selected item in drop-down list corresponds to expected one
Parameters: - element – Element representation (By, value).
- text – String text
Example: self.list_label_should_be(self.element, text)
-
list_value_should_be
(element, value)¶ Verifies if value of selected item in drop-down list corresponds to expected one
Parameters: - element – Element representation (By, value).
- value – Value of the item
Example: self.list_value_should_be(self.element, value)
-
title_should_be
(string)¶ Verifies if page title corresponds to expected one
Parameters: string – expected page title
-
verify_rest_api_json_value
(url, method, expected_file, auth_file, request_file_json)¶ Verifies if REST-API values are equal to expected ones. Supports get, post, put and delete methods. Only JSON format.
Directories for request, response and login files are in your working directory
../data/..
Key example: coord.latParameters: - url – Web request url
- method – Rest-api method. Get, post, put or delete.
- expected_file – Text file which includes key/value pairs to verify. One verification per line: key expected_value.
- auth_file – Optional login credentials text file. Only one line: username password. Leave blank if not needed.
- request_file_json – Name of the request file. Leave blank if not needed.
Example: url = u'http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=2de143494c0b295cca9337e1e96b00e0'
self.verify_rest_api_json_value(url, u'get', u'expected.txt', u'', u'')
self.verify_rest_api_json_value(u'http://exampleurl.com', u'post', u'expected_response.txt', u'auth.txt', u'request.txt')
-
verify_rest_api_xml_value
(url, method, expected_file, auth_file, request_file_xml)¶ Verifies if REST-API values are equal to expected ones. Supports get, post, put and delete methods. Only XML format.
Xpath examples:
"//city[1]/country[1]/text()"
,"//city[1]/coord[1]/@lat"
Parameters: - url – Web request url
- method – get, post, put or delete
- expected_file – Text file which includes xpaths and expected values to verify. One verification per line: xpath expected_value
- auth_file – Optional login credentials text file. Only one line: username password. Leave blank if not needed.
- request_file_xml – Name of the request xml file. Leave blank if not needed.
Example: url = u'http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=2de143494c0b295cca9337e1e96b00e0&mode=xml'
self.verify_rest_api_xml_value(url, u'get', u'expected.txt', u'', u'')
self.verify_rest_api_xml_value(u'http://exampleurl.com', u'post', u'expected_response.txt', u'auth.txt', u'request.xml')
-
verify_soap_api_value
(url, request_file_xml, response_file, full_file=True)¶ Verifies if SOAP-API values are equal to expected ones.
Place for request and response files:
../data/soap/..
If verifying single values: One verification per line in response file. xpath expected_value
Parameters: - url – Web service url
- request_file_xml – Request xml filename
- response_file – File which includes expectes response or key/value pairs
- full_file – Boolean: If true verify full reponse, if false verify single values
Example: self.verify_soap_api(u'http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL', u'soap_xml.xml', response_file.txt)
-
-
class
webframework.extension.util.common_utils.
CanvasMethods
(driver_cache=None)¶ Class that contains methods for Canvas based areas
-
click_canvas
(element)¶ Click at element
Parameters: element – Element representation (By, value) or WebElement
-
compare_element_screenshots_canvas
(element, ref_scr_name)¶ Compares screenshots of elements
Parameters: - element – Element representation (By, value)
- ref_scr_name – Screenshot name in string format
-
compare_screenshots_canvas
(ref_scr_name)¶ Compares screenshots or part of screenshots
Parameters: ref_scr_name – Screenshot name in string format
-
find_element_canvas
(element)¶ Return found WebElement
Parameters: element – (By, ‘value’) Returns: found WebElement
-
wait_until_element_is_visible_canvas
(element, msg=None, timeout=None)¶ Wait until visible
Parameters: - element – element: (By, ‘value’)
- msg – Message
- timeout – Using default timeout
-
-
class
webframework.extension.util.common_utils.
CanvasWrappers
(driver_cache=None)¶ -
click_canvas
(element)¶
-
compare_element_screenshots_canvas
(element, parameters)¶
-
compare_screenshots_canvas
(parameters)¶
-
wait_until_element_is_visible_canvas
(element)¶
-
-
class
webframework.extension.util.common_utils.
CommonMethods
(driver_cache=None)¶ Class that contains common methods
-
add_dynamic_content_to_parameters
(parameters, name, value, section=None)¶ Add dynamic content to parameters dictionary
dynamic content is available in current test run
Parameters: - parameters – Parameters dictionary
- name – Name for added parameter as string
- value – Value for added parameter as string
- section – Optional section where parameter is added as string
Example: Page model level exampleself.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value")
self.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value", "my_section")
Using dynamic valueself.add_dynamic_content_to_parameters(self.ELEMENT_NAME, parameters["param_name"])
Test level exampleself.common_utils.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value")
self.common_utils.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value", "my_section")
Using dynamic valueself.trial.login(TESTDATA["my_section"])
-
click_element
(element, to_print=True)¶ Click at element
Parameters: - element – Element representation (By, value) or WebElement
- to_print – Flag, if True prints action message
Example: Page model levelusing web elementself.click_element(self.TRIAL)
using representationself.click_element((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementself.common_utils.click_element(self.trial.TRIAL)
-
click_element_at_coordinates
(element, x, y, to_print=True)¶ Clicks at the specified coordinates at element
Parameters: - element – Element representation (By, value) or WebElement
- x – x-coordinate
- y – y-coordinate
- to_print – Flag, if True prints action message
Example: Page model levelusing web elementself.click_element_at_coordinates(self.TRIAL, 1, 1)
using representationself.click_element_at_coordinates((By.LINK_TEXT, u'Trial'), 1, 1)
Test levelusing web elementself.common_utils.click_element_at_coordinates(self.trial.TRIAL, 1, 1)
-
close_all_browsers
()¶ Closes all opened browsers
Example: Page model level exampleself.close_all_browsers()
Test level exampleself.common_utils.close_all_browsers()
-
close_browser
()¶ Closes current active browser
Example: Page model level exampleself.close_browser()
Test level exampleself.common_utils.close_browser()
-
compare_element_screenshots
(element, ref_scr_name)¶ Compares screenshots of elements
Parameters: - element – Element representation (By, value) or WebElement
- ref_scr_name – Screenshot name in string format
Example: Page model level example self.compare_element_screenshots(self.TRIAL,"ref_scr_name")
-
compare_screenshots
(ref_scr_name)¶ Compares screenshots or part of screenshots
Parameters: ref_scr_name – Screenshot name in string format Example: Page model level exampleself.compare_screenshots("ref_scr_name")
Test level exampleself.common_utils.compare_screenshots("ref_scr_name")
-
double_click_element
(element, to_print=True)¶ Double click at element
Parameters: - element – Element representation (By, value) or WebElement
- to_print – Flag, if True prints action message
Example: Page model level exampleusing web elementself.double_click_element(self.TRIAL)
using representationself.double_click_element((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementself.common_utils.double_click_element(self.trial.TRIAL)
-
execute_async_javascript
(js_script, log=True)¶ Execute async JavaScript code
Parameters: - js_script – String represents JavaScript code
- log – Flag, if True prints action message
Returns: Object return by JavaScript code else None
-
execute_javascript
(js_script, log=True)¶ Execute JavaScript code
Parameters: - js_script – String represents JavaScript code
- log – Flag, if True prints action message
Returns: Object return by JavaScript code else None
Example: age model level examplevalue = self.execute_javascript("run_function(variable)")
Test level examplevalue = self.common_utils.execute_javascript("run_function(variable)")
-
fail
(message)¶ Message to print in report as a String
Parameters: message – Message to print as a string. Example: Page model level exampleself.fail("My message")
Test level exampleself.common_utils.fail("My message")
-
find_element
(element)¶ Return found WebElement
Parameters: element – Element representation (By, value) or WebElement Returns: WebElement Example: Page model levelelement = self.find_element((By.LINK_TEXT, u'Trial'))
-
find_elements
(element)¶ Return found list of WebElement’s
Parameters: element – Element representation (By, value) or WebElement Returns: List of WebElement’s Example: Page model levelall_elements = self.find_elements((By.CSS_SELECTOR, u"img"))
-
generate_zap_test_report
(installation_dir, session_name, report_name='qautomate_zap_report.html')¶ Generate zap test report html
Note
Zapproxy UI and python client must be installed
Parameters: - installation_dir – Zap installation dir
- session_name – Zap session name
- report_name – Zap report name
Example: Test level examplezap, zap_session = self.common_utils.start_zapproxy_daemon('C:\ZedAttackProxy\zap.bat')
self.common_utils.stop_zapproxy_daemon(zap)
self.oommon_utils.generate_zap_test_report('C:\ZedAttackProxy\zap.bat', zap_session)
or self.common_utils.generate_zap_test_report('C:\ZedAttackProxy\zap.bat', zap_session, "qautomate_zap.html")
-
get_dom_element_count
(log=True)¶ Counting DOM-elements
Returns: Returns number of DOM-elements on web page. Example: Page model level exampleself.get_dom_element_count()
Test level exampleself.common_utils.get_dom_element_count()
-
get_measurements
(measurement_name)¶ Return measurements
Parameters: measurement_name – String represents name of measurement point Returns: Measured time in specific point Example: Page model level exampleself.get_measurements("trial")
Test level exampleself.common_utils.get_measurements("trial")
-
get_resource_timings
(measurement_name)¶ Return resource timings
Parameters: measurement_name – String represents name of measurement point Returns: Measured time in specific resource Example: Page model level exampleself.get_resource_timings("trial")
Test level exampleself.common_utils.get_resource_timings("trial")
-
get_soap_response
(url, request_file_xml)¶ Gets SOAP response from web service to be used in verify_soap_api
Parameters: - url – Web service url
- request_file_xml – Request xml file in ../data/soap/requests/
Example: Page model level examplevalue = self.get_soap_response(u'http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL', u'soap_xml.xml')
Test level examplevalue = self.common_utils.get_soap_response(u'http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL', u'soap_xml.xml')
-
get_text
(element)¶ Return element’s text
Parameters: element – Element representation (By, value) or WebElement Returns: Text of element Example: Page model level exampleusing web elementvalue = self.get_text(self.TRIAL)
using representationvalue = self.get_text((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementvalue = self.common_utils.get_text(self.trial.TRIAL)
-
get_text_length
(element)¶ Return element text length. Spaces are also counted.
Parameters: element – Element representation (By, value) or WebElement Returns: WebElement text length as integer Example: Page model level exampleusing web elementvalue = self.get_text_length(self.TRIAL)
using representationvalue = self.get_text_length((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementvalue = self.common_utils.get_text_length(self.trial.TRIAL)
-
get_timestamp
()¶ Return timestamp
Format: ‘yyyyMMddhhmmss’ Returns: String which represents current time Example: Page model level examplevalue = self.get_timestamp()
Test level examplevalue = self.common_utils.get_timestamp()
-
get_value
(element)¶ Return element’s value
Parameters: element – Element representation (By, value) or WebElement Returns: Value of element Example: Page model level exampleusing web elementvalue = self.get_value(self.TRIAL)
using representationvalue = self.get_value((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementvalue = self.common_utils.get_value(self.trial.TRIAL)
-
get_web_response
(url, method, auth_file, data)¶ Return response from web service
Parameters: - url – Web service url
- method – Rest-api method. Get, post, put or delete.
- auth_file – Optional name of the auth_file. Blank if not needed.
- data – Optional data for request as string.
Returns: Web response from server
Example: Page model level examplevalue = self.get_web_response(u'http://api.openweathermap.org/data/2.5/weather?q=London&mode=xml', u'get', u'auth_file.txt', u'')
Test level examplevalue = self.common_utils.get_web_response(u'http://api.openweathermap.org/data/2.5/weather?q=London&mode=xml', u'get', u'auth_file.txt', u'')
-
go_to
(url, log=True)¶ Open specified url
Parameters: - url – Url to open
- log – Flag, if True prints action message
Example: Page model level exampleself.go_to("http://qautomate.fi/")
Test level exampleself.common_utils.go_to("http://qautomate.fi/")
-
ignore_fail
(enable=True)¶
-
input_text
(element, value, to_print=True)¶ Clear and types text to input element
Parameters: - element – Element representation (By, value) or WebElement
- value – String to type in
- to_print – Flag, if True prints action message
Example: Page model levelusing web elementself.input_text(self.ID_CONTACT_FIRST_NAME, "this is value")
using representationself.input_text((By.ID, u'contact_first_name'), "this is value")
Test levelusing web elementself.common_utils.input_text(self.trial.ID_CONTACT_FIRST_NAME, "this is value")
-
is_disabled
(element, timeout=None)¶ Return disability of element.
Parameters: - element – Element representation (By, value) or WebElement.
- timeout – No timeout used, unless custom value provided.
Returns: True if element disabled, else - False.
Example: Page model level exampleusing web elementself.is_disabled(self.TRIAL)
using representationself.is_disabled((By.LINK_TEXT, u'Trial'))
using timeoutself.is_disabled(self.TRIAL, 10)
self.is_disabled((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.is_disabled(self.trial.TRIAL)
using timeoutself.common_utils.is_disabled(self.trial.TRIAL, 10)
-
is_enabled
(element, timeout=None)¶ Return enablity of element.
Parameters: - element – Element representation (By, value) or WebElement.
- timeout – No timeout used, unless custom value provided.
Returns: True if element enabled, else - False.
Example: Page model level exampleusing web elementself.is_enabled(self.TRIAL)
using representationself.is_enabled((By.LINK_TEXT, u'Trial'))
using timeoutself.is_enabled(self.TRIAL, 10)
self.is_enabled((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.is_enabled(self.trial.TRIAL)
using timeoutself.common_utils.is_enabled(self.trial.TRIAL, 10)
-
is_visible
(element, timeout=None)¶ Return visibility of element.
Parameters: - element – Element representation (By, value) or WebElement.
- timeout – No timeout used, unless custom value provided.
Returns: visibility of element. True or False.
Example: Page model level exampleusing web elementself.is_visible(self.TRIAL)
using representationself.is_visible((By.LINK_TEXT, u'Trial'))
using timeoutself.is_visible(self.TRIAL, 10)
self.is_visible((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.is_visible(self.trial.TRIAL)
using timeoutself.common_utils.is_visible(self.trial.TRIAL, 10)
-
measure_async_screen_response_time
(measurement_name, timeout, reference_picture, element=None)¶ Return page loading time based on screenshot verification
Parameters: - measurement_name – String represents name of measure point
- timeout – Int represents how long (in seconds) to take screenshots
- reference_picture – String represents name of the reference picture
- element – Tuple represents element: (By, ‘value’)
Returns: return Time in seconds how long takes to find correct screenshot or if no match found return False
Example: Page model levelself.measure_async_screen_response_time("trial", 10, "trial_perf_pic")
Test levelself.common_utils.measure_async_screen_response_time("trial", 10, "trial_perf_pic")
-
open_browser
(browser_name=None, url=None, alias=None, size=None)¶ Open specified browser with url
Parameters: - browser_name – Browser to open
- url – Url to open
- alias – save driver with alias
- size – Browser window size. Fullscreen if none.
Returns: id
Example: Page model level exampleself.open_browser("ff", http://qautomate.fi/")
Test level exampleself.common_utils.open_browser("ff", "http://qautomate.fi/")
-
open_url
(url, log=True)¶ Open specified url
Parameters: - url – Url to open
- log – Flag, if True prints action message
Example: Page model level exampleself.open_url("http://qautomate.fi/")
Test level exampleself.common_utils.open_url("http://qautomate.fi/")
-
robot_script_runner
(robot_script)¶ Runs robot framework scripts
Parameters: robot_script – Robot framework script Example: Page model levelself.robot_script_runner("C:\Users\username\Documents\script.robot")
Test level exampleself.common_utils.robot_script_runner("C:\Users\username\Documents\script.robot")
-
send_keys
(element, value, to_print=True)¶ Type value to element
Parameters: - element – Element representation (By, value) or WebElement
- value – Value to type in to the element
- to_print – Flag, if True prints action message
Example: Page model levelusing web elementself.send_keys(self.ID_CONTACT_FIRST_NAME, "this is value")
using representationself.send_keys((By.ID, u'contact_first_name'), "this is value")
Test levelusing web elementself.common_utils.send_keys(self.trial.ID_CONTACT_FIRST_NAME, "this is value")
-
start_zapproxy_daemon
(installation_dir)¶ Start Zap proxy daemon
Note
Zapproxy UI and python client must be installed
Parameters: installation_dir – Zapproxy installation folder Returns: Zap daemon object, zap session name Example: Page model level examplezap, zap_session = self.start_zapproxy_daemon('C:\ZedAttackProxy\zap.bat')
Test level examplezap, zap_session = self.common_utils.start_zapproxy_daemon('C:\ZedAttackProxy\zap.bat')
-
stop_zapproxy_daemon
(zap)¶ Stop Zap proxy daemon
Note
Zapproxy UI and python client must be installed
Parameters: zap – Zap proxy object Example: Test level examplezap, zap_session = self.common_utils.start_zapproxy_daemon('C:\ZedAttackProxy\zap.bat')
self.common_utils.stop_zapproxy_daemon(zap)
-
switch_browser
(id_or_alias)¶ Switch between active browsers using id or alias
Parameters: id_or_alias – Identify new active browser Example: Page model level example with idid = self.open_browser("ff", "http://qautomate.fi/")
id2 = self.open_browser("ff", "http://qautomate.fi/")
run some stepsself.switch_browser(id)
Test level example with aliasself.common_utils.open_browser("ff", "http://qautomate.fi/", "alias1")
self.common_utils.open_browser("ff", "http://qautomate.fi/", "alias2")
run some stepsself.common_utils.switch_browser("alias1")
-
triple_click_element
(element, to_print=True)¶ Triple click at element
Parameters: - element – Element representation (By, value) or WebElement
- to_print – Flag, if True prints action message
Example: Page model level exampleusing web elementself.triple_click_element(self.TRIAL)
using representationself.triple_click_element((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementself.common_utils.triple_click_element(self.trial.TRIAL)
-
wait_until_element_is_disabled
(element, timeout=None, msg=None)¶ Wait until element is disabled.
Parameters: - element – Element representation (By, value) or WebElement object.
- timeout – Uses default timeout, unless custom value provided.
- msg – Message if element is not disabled
Exception: If time exceeds DEFAULT_TIMEOUT, then rise exception.
Example: Page model level exampleusing web elementself.wait_until_element_is_disabled(self.TRIAL)
using representationself.common_utils.wait_until_element_is_disabled((By.LINK_TEXT, u'Trial'))
using timeoutself.wait_until_element_is_disabled(self.TRIAL, 10)
self.wait_until_element_is_disabled((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.wait_until_element_is_disabled(self.trial.TRIAL)
using timeoutself.common_utils.wait_until_element_is_disabled(self.trial.TRIAL, 10)
-
wait_until_element_is_enabled
(element, timeout=None, msg=None)¶ Wait until element is enabled.
Parameters: - element – Element representation (By, value) or WebElement object.
- timeout – Uses default timeout, unless custom value provided.
- msg – Message if element is not enabled.
Exception: If time exceeds DEFAULT_TIMEOUT, then rise exception.
Example: Page model level exampleusing web elementself.wait_until_element_is_enabled(self.TRIAL)
using representationself.common_utils.wait_until_element_is_enabled((By.LINK_TEXT, u'Trial'))
using timeoutself.wait_until_element_is_enabled(self.TRIAL, 10)
self.wait_until_element_is_enabled((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.wait_until_element_is_enabled(self.trial.TRIAL)
using timeoutself.common_utils.wait_until_element_is_enabled(self.trial.TRIAL, 10)
-
wait_until_element_is_not_visible
(element, timeout=None, msg=None)¶ Wait until element specified is not visible
Parameters: - element – Element representation (By, value) or WebElement object.
- timeout – Uses default timeout, unless custom value provided.
- msg – Message if element is visible
Exception: If time exceeds DEFAULT_TIMEOUT, then rise exception.
Example: Page model level exampleusing web elementself.wait_until_element_is_not_visible(self.TRIAL)
using representationself.common_utils.wait_until_element_is_not_visible((By.LINK_TEXT, u'Trial'))
using timeoutself.wait_until_element_is_not_visible(self.TRIAL, 10)
self.wait_until_element_is_not_visible((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.wait_until_element_is_not_visible(self.trial.TRIAL)
using timeoutself.common_utils.wait_until_element_is_not_visible(self.trial.TRIAL, 10)
-
wait_until_element_is_visible
(element, timeout=None, msg=None)¶ Wait until element specified is visible
Parameters: - element – Element representation (By, value) or WebElement object.
- timeout – Uses default timeout, unless custom value provided.
- msg – Message if element is not visible
Exception: If time exceeds DEFAULT_TIMEOUT, then rise exception.
Example: Page model level exampleusing web elementself.wait_until_element_is_visible(self.TRIAL)
using representationself.common_utils.wait_until_element_is_visible((By.LINK_TEXT, u'Trial'))
using timeoutself.wait_until_element_is_visible(self.TRIAL, 10)
self.wait_until_element_is_visible((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.wait_until_element_is_visible(self.trial.TRIAL)
using timeoutself.common_utils.wait_until_element_is_visible(self.trial.TRIAL, 10)
-
warning
(message)¶ Adds warning to test report
Parameters: message – Message to print as a String Example: Page model level exampleself.warning("My message")
Test level exampleself.common_utils.warning("My message")
-
-
class
webframework.extension.util.common_utils.
CommonUtils
¶ Main class for all available methods
-
DATA_TEST_CASES_AND_DATA_FILES
= {}¶
-
accept_alert
()¶ Accepts current alert window
Example: Page model level exampleself.accept_alert()
Test level exampleself.common_utils.accept_alert()
-
add_dynamic_content_to_parameters
(parameters, name, value, section=None)¶ Add dynamic content to parameters dictionary
dynamic content is available in current test run
Parameters: - parameters – Parameters dictionary
- name – Name for added parameter as string
- value – Value for added parameter as string
- section – Optional section where parameter is added as string
Example: Page model level exampleself.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value")
self.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value", "my_section")
Using dynamic valueself.add_dynamic_content_to_parameters(self.ELEMENT_NAME, parameters["param_name"])
Test level exampleself.common_utils.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value")
self.common_utils.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value", "my_section")
Using dynamic valueself.trial.login(TESTDATA["my_section"])
-
alert_is_present
()¶ Check if alert is present
Returns: Alert as webdriver element alert if alert not found returns false Example: Page model level exampleself.alert_is_present()
Test level exampleself.common_utils.alert_is_present()
-
alert_should_be_present
()¶ Check if alert is present
Returns: Alert as webdriver element alert if alert not found returns false Example: Page model level exampleself.alert_is_present()
Test level exampleself.common_utils.alert_is_present()
-
alpha
(minlength, maxlength)¶ Alphabetical valid text validation
Parameters: - minlength – input minimum valid length
- maxlength – input maximum valid length
Returns: values dict of scenarios
Scenario1 valid: alpha “asafS” Scenario2 valid: alpha with min length “AbC” Scenario3 valid: alpha with max_length “ASsaSAV” Scenario4 invalid: alpha with invalid min_length “bC” Scenario5 invalid: alpha with invalid max_length “CsSASsSA” Scenario6 invalid: digit number “33323” Scenario7 invalid: alphadigit “as23B” Scenario8 invalid: alphachar “a@sSs”
-
alpha_lower
(minlength, maxlength)¶ Alphabetical lower input validation
Parameters: - minlength – input minimum valid length
- maxlength – maximum valid length
Returns: values dict of scenarios
Scenario1 valid: alpha with lower “assss” Scenario2 valid: alpha with lower min_length “abc” Scenario3 valid: alpha with lower max_length “assasav” Scenario4 invalid: alpha with lower invalid min_length “bc” Scenario5 invalid: alpha with lower invalid max_length “clsasasa” Scenario6 invalid: alpha with upper “ASSSS” Scenario7 invalid: digit “33323” Scenario8 invalid: alphadigit with lower “as23a” Scenario9 invalid: alphadigit with upper “A3BSA” Scenario10 invalid: alphachar with lower “a@sbs” Scenario11 invalid: alphachar with upper “@BAFK”
-
alpha_upper
(minlength, maxlength)¶ Alphabetical upper input validation
Parameters: - minlength – input minimum valid length
- maxlength – input maximum valid length
Returns: values dict of scenarios
Scenario1 valid: alpha with upper “ASSSS” Scenario2 valid: alpha with upper min_length “ABC” Scenario3 valid: alpha with upper max_length “ASSASAV” Scenario4 invalid: alpha with upper invalid min_length “BC” Scenario5 invalid: alpha with upper invalid max_length “CLSASASA” Scenario6 invalid: alpha with lower “sasfs” Scenario7 invalid: digit “33323” Scenario8 invalid: alphadigit with lower “as23a” Scenario9 invalid: alphadigit with upper “A3BSA” Scenario10 invalid: alphachar with lower “a@sbs” Scenario11 invalid: alphachar with upper “@BAFK”
-
alphachar
(minlength, maxlength)¶ Alphabetical and specialcharacters input validation
Parameters: - minlength – input minimum valid length
- maxlength – input maximum valid length
Returns: values dict of scenarios
Scenario1 valid: alphachar “as@ss” Scenario2 valid: alphachar with min_length “a@B” Scenario3 valid: alphachar with max_length “asBs@aa” Scenario4 invalid: alphachar with invalid min_length “b@” Scenario5 invalid: alphachar with invalid max_length “sasasRg@” Scenario6 invalid: alphadigitchar “a@23B”
-
alphadigit
(minlength, maxlength)¶ Alphabetical and numbers input validation
Parameters: - minlength – input minimum valid length
- maxlength – input maximum valid length
Returns: values dict of scenarios
Scenario1 valid: alphadigit “as23B” Scenario2 valid: alphadigit with min_length “a2B” Scenario3 valid: alphadigit with max_length “as23Bsa” Scenario4 invalid: alphadigit with invalid min length “B1” Scenario5 invalid: alphadigit with invalid max_length “SASAsGE1” Scenario6 invalid: alphadigitchar a@s1s”
-
alphadigit_lower
(minlength, maxlength)¶ Alphabetical lower and numbers input validation
Parameters: - minlength – input minimum valid length
- maxlength – input maximum valid length
Returns: values dict of scenarios
Scenario1 valid: alphadigit with lower “as1ss” Scenario2 valid: alphadigit with lower min_length “b1c” Scenario3 valid: alphadigit with lower max_length “safsd1a” Scenario4 invalid: alphadigit with lower invalid min_length “b1” Scenario5 invalid: alphadigit with lower invalid max_length “sasasrg1” Scenario6 invalid: alphadigitchar with lower “a3@ab”
-
alphadigit_upper
(minlength, maxlength)¶ Alphabetical upper and numbers input validation
Parameters: - minlength – input minimum valid length
- maxlength – input maximum valid length
Returns: values dict of scenarios
Scenario1 valid: alphadigit with upper “A3BSA” Scenario2 valid: alphadigit with upper min_length “B1C” Scenario3 valid: alphadigit with upper max_length “SASA1GE” Scenario4 invalid: alphadigit with upper invalid min_length “B1” Scenario5 invalid: alphadigit with upper invalid max_length “SASASGE1” Scenario6 invalid: alphadigitchar with upper “A3B@A”
-
alphadigitchar
(minlength, maxlength)¶ Alphabetical, numbers and specialcharacters input validation
Parameters: - minlength – input minimum valid length
- maxlength – input maximum valid length
Returns: values dict of scenarios
Scenario1 valid: alphadigitchar “a1@ss” Scenario2 valid: alphadigitchar with min_length “1@B” Scenario3 valid: alphadigitchar with max_length “asBs@a1” Scenario4 invalid: alphadigitchar with invalid min_length “B@” Scenario5 invalid: alphadigitchar with invalid max_length “sasasRg@”
-
android_back_key
(element)¶ Press BACK key in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_home_key
(element)¶ Press HOME key in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_power_key
(element)¶ Press POWER key in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_scroll_down
(element)¶ Scroll down in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_scroll_up
(element)¶ Scroll up in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_slide_center_to_bottom
(element)¶ Slide from element center to the bottom in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_slide_center_to_left
(element)¶ Slide from element center to the left in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_slide_center_to_right
(element)¶ Slide from element center to the right in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_slide_center_to_top
(element)¶ Slide from element center to the top in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_swipe_left_to_right
(element)¶ Swipe from left to right in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_swipe_right_to_left
(element)¶ Swipe from right to left in android native application
Parameters: element – Element representation (By, value) or WebElement
-
android_tap
(element)¶ Tap on element center in android native application
Parameters: element – Element representation (By, value) or WebElement
-
classmethod
catch_exc
(message, *args, **kwargs)¶ Python decorator should catch exceptions
Parameters: - message – Message to print on fail
- args – Function agruments
- kwargs – Function keyword arguments
Returns: wrapped function
Example: catch_exc("Fail to open url")
def open_url(url):
-
checkbox
()¶ Checkbox input validation is checked or unchecked)
Returns: values dict of scenarios Scenario1 valid: checked Scenario2 valid: unchecked
-
checkbox_checked
()¶ Checkbox input validation is checked
Returns: values dict of scenarios Scenario1 valid: checked Scenario2 invalid: unchecked
-
checkbox_should_be_selected
(element)¶ Check radiobutton is selected.
Parameters: element – Radiobutton element Example: self.checkbox_should_be_selected(self.CLASS_RADIO)
-
checkbox_should_not_be_selected
(element)¶ Check radiobutton is not selected.
Parameters: element – Radiobutton element Example: self.checkbox_should_not_be_selected(self.CLASS_RADIO)
-
checkbox_unchecked
()¶ Checkbox input validation is unchecked
Returns: values dict of scenarios Scenario1 valid: unchecked Scenario2 invalid: checked
-
click_canvas
(element)¶ Click at element
Parameters: element – Element representation (By, value) or WebElement
-
click_element
(element, to_print=True)¶ Click at element
Parameters: - element – Element representation (By, value) or WebElement
- to_print – Flag, if True prints action message
Example: Page model levelusing web elementself.click_element(self.TRIAL)
using representationself.click_element((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementself.common_utils.click_element(self.trial.TRIAL)
-
click_element_at_coordinates
(element, x, y, to_print=True)¶ Clicks at the specified coordinates at element
Parameters: - element – Element representation (By, value) or WebElement
- x – x-coordinate
- y – y-coordinate
- to_print – Flag, if True prints action message
Example: Page model levelusing web elementself.click_element_at_coordinates(self.TRIAL, 1, 1)
using representationself.click_element_at_coordinates((By.LINK_TEXT, u'Trial'), 1, 1)
Test levelusing web elementself.common_utils.click_element_at_coordinates(self.trial.TRIAL, 1, 1)
-
click_element_from_table_row
(element, row, element_path)¶ Click table cell by given row.
Parameters: - element – Table element representation (By, value) or WebElement object.
- row – Table row where is link or button to click
- element_path – Path to element which should be clicked
Example: Page model level exampleusing web elementself.click_table_cell_by_column_and_row(self.TABLE, 1, "TD/DIV/H4/A")
using representationself.click_table_cell_by_column_and_row((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), 1, "TD/DIV/H4/A")
Test level exampleusing web elementself.common_utils.click_table_cell_by_column_and_row(self.elements.TABLE, 1, "TD/DIV/H4/A")
-
click_table_cell_by_column_and_row
(element, column, row, cell='TD')¶ Click table cell by given column and row.
Parameters: - element – Table element representation (By, value) or WebElement object.
- column – Table column where to click
- row – Table row where to click
- cell – Xpath to element which should be clicked, default is ‘TD’
Example: Page model level exampleusing web elementself.click_table_cell_by_column_and_row(self.TABLE, 1, 1)
using representationself.click_table_cell_by_column_and_row((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), 1, 1)
Test level exampleusing web elementself.common_utils.click_table_cell_by_column_and_row(self.elements.TABLE, 1, 1)
-
close_all_browsers
()¶ Closes all opened browsers
Example: Page model level exampleself.close_all_browsers()
Test level exampleself.common_utils.close_all_browsers()
-
close_browser
()¶ Closes current active browser
Example: Page model level exampleself.close_browser()
Test level exampleself.common_utils.close_browser()
-
close_window
()¶ Close current window
Example: Page model level exampleself.close_window()
Test level exampleself.common_utils.close_window()
-
close_window_and_focus_to_previous
()¶ Close current window and focus to previous one
Example: Page model level exampleself.close_window_and_focus_to_previous()
Test level exampleself.common_utils.close_window_and_focus_to_previous()
-
compare_element_screenshots
(element, ref_scr_name)¶ Compares screenshots of elements
Parameters: - element – Element representation (By, value) or WebElement
- ref_scr_name – Screenshot name in string format
Example: Page model level example self.compare_element_screenshots(self.TRIAL,"ref_scr_name")
-
compare_element_screenshots_canvas
(element, ref_scr_name)¶ Compares screenshots of elements
Parameters: - element – Element representation (By, value)
- ref_scr_name – Screenshot name in string format
-
compare_screenshots
(ref_scr_name)¶ Compares screenshots or part of screenshots
Parameters: ref_scr_name – Screenshot name in string format Example: Page model level exampleself.compare_screenshots("ref_scr_name")
Test level exampleself.common_utils.compare_screenshots("ref_scr_name")
-
compare_screenshots_canvas
(ref_scr_name)¶ Compares screenshots or part of screenshots
Parameters: ref_scr_name – Screenshot name in string format
-
create_element_ref_screenshot
(element, ref_scr_name)¶ Creates refernece screenshot of an element
Parameters: - element – Element representation (By, value) or WebElement
- ref_scr_name – Reference screenshot image file name
Returns: element_found Boolen
-
create_ref_screenshot
(ref_scr_name, ref_scr_x, ref_scr_y, ref_scr_w, ref_scr_h)¶ Creates refernece screenshot of an area
Parameters: - ref_scr_name – Reference screenshot file image name
- ref_scr_x – Area’s x-coordination
- ref_scr_y – Area’s y-coordination
- ref_scr_w – Area’s width
- ref_scr_h – Area’s height
Returns: created screenshot
-
create_ref_screenshot_canvas
(ref_scr_name, x_coord, y_coord, width, height)¶ Creates reference screenshot of an element
Parameters: - ref_scr_name – Reference screenshot image file name
- x_coord – Element’s x coordination
- y_coord – Element’s y coordination
- width – Element’s width
- height – Element’s height
Returns: scr_created ref_scr_name Boolean Updated screenshot file name
-
data_test
(data_file)¶ Python decorator for test methods
Decorator sets information about method which will be used for creating tests with arguments from data file.
Parameters: data_file – path to data file
-
data_test_class
(test_class)¶ Python decorator for test classes
Decorator adds data tests to test class object
Parameters: test_class – test class object Returns: test class object
-
date_future_daymonthyear
()¶ Date in future format: day month year input validation
Returns: values dict of scenarios Scenario1 valid: future day.month.year Scenario2 invalid: future day.month.year Scenario3 invalid: future year.month.day Scenario4 invalid: invalid format
-
date_now_daymonthyear
()¶ Date now format: day month year input validation
Returns: values dict of scenarios Scenario1 valid: day.month.year “10.11.2016” Scenario2 invalid: past day.month.year Scenario3 invalid: now year.month.day Scenario4 invalid: invalid format
-
date_past_daymonthyear
()¶ Date in future format: day month year input validation
Returns: values dict of scenarios Scenario1 valid: past day.month.year Scenario2 invalid: future day.month.year Scenario3 invalid: past year.month.day Scenario4 invalid: invalid format
Deletes all cookies from current session
Example: Page model level exampleself.delete_all_cookies()
Test level exampleself.common_utils.delete_all_cookies()
-
digit
(minvalue, maxvalue)¶ Digit numbers input validation
Parameters: - minvalue – minlength input minimum valid length
- maxvalue – maxlength input maximum valid length
Returns: values dict of scenarios
Scenario1 valid: inrange 5 Scenario2 valid: min 2 Scenario3 valid: max 10 Scenario4 invalid: invalid min 1 Scenario5 invalid: invalid max 11 Scenario6 invalid: invalid chars “j@”
-
dismiss_alert
()¶ Dismisses current alert window
Example: Page model level exampleself.dismiss_alert()
Test level exampleself.common_utils.dismiss_alert()
-
double_click_element
(element, to_print=True)¶ Double click at element
Parameters: - element – Element representation (By, value) or WebElement
- to_print – Flag, if True prints action message
Example: Page model level exampleusing web elementself.double_click_element(self.TRIAL)
using representationself.double_click_element((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementself.common_utils.double_click_element(self.trial.TRIAL)
-
drag_and_drop
(draggable, droppable)¶ Drags draggable element onto droppable
Parameters: - draggable – Element to drag
- droppable – Element to drop onto
Example: self.drag_and_drop(self.ID_DRAG1, self.ID_DRAGDIV2)
-
drag_and_drop_by_offset
(element, xoffset, yoffset)¶ Drags draggable element onto x,y offset
Parameters: - element – Element to drag
- xoffset – Drag element from current position to xoffset
- yoffset – Drag element from current position to yoffset
Example: Page model level exampleusing web elementself.drag_and_drop_by_offset(self.ID_DRAG1, 0, 0)
using representationself.drag_and_drop_by_offset((By.CSS_SELECTOR, u'div>p'), 0, 0)
Test level exampleusing web elementself.common_utils.drag_and_drop_by_offset(self.elements.ID_DRAG1, 0, 0)
-
drag_and_drop_html5
(draggable, droppable)¶ Drags draggable element onto droppable (HTML5)
Parameters: - draggable – Element to drag
- droppable – Element to drop onto
Example: self.drag_and_drop_html5(self.ID_DRAG1, self.ID_DRAGDIV2)
-
element_attribute_should_be
(element, attribute, value)¶ Verifies if attribute of element corresponds to expected one
Parameters: - element – Element representation (By, value).
- attribute – Attribute of an element
- value – String text
Example: self.wait_until_element_should_not_be(self.element, attribute, value)
-
element_attribute_should_contains
(element, attr, expected_value)¶ Verify if attribute contains expected value
Parameters: - element – Element representation (By, value) or WebElement.
- attr – Element’s attribute
- expected_value – Element’s attribute value which should be contained
Example: self.element_attribute_should_contains(self.CONTACT_QAUTOMATE_FI, u'href', u'mailto')
-
element_should_be
(element, parameters)¶
-
element_should_be_disabled
(element)¶ Verify that element is disabled.
Use
unittest.assertTrue()
to verify that element is disabled.Parameters: element – Element representation (By, value). Example: rcm = (By.ID, "map-player-rcMenu")
element_should_be_disabled(self, rcm)
-
element_should_be_enabled
(element)¶ Verify that element is enabled.
Use
unittest.assertTrue()
to verify that element is disabled.Parameters: element – Element representation (By, value). Example: rcm = (By.ID, "map-player-rcMenu")
element_should_be_enabled(self, rcm)
-
element_should_be_present
(element)¶ Verify that element is present.
Use
unittest.assertTrue()
to verify that element is present.Parameters: element – Element representation (By, value). Example: rcm = (By.ID, "map-player-rcMenu")
element_should_be_present(self, rcm)
-
element_should_be_table_column_and_row
(element, text, column, row, cell='TD')¶ Verify that text from selected table column and row.
Use
unittest.assert_equal()
to verify that text is correct.Parameters: - element – Table element representation (By, value) or WebElement object.
- text – Element’s text which should be
- column – Table column where to verify text
- row – Table row where to verify text
- cell – Xpath to element where text should be, default is ‘TD’
Example: TABLE = (By.ID, "my-table")
element_should_be_table_column_and_row(self, TABLE, "text_to_verify", 2, 1)
-
element_should_be_visible
(element)¶ Verify that element is visible.
Use
unittest.assertTrue()
to verify that element is visible.Parameters: element – Element representation (By, value). Example: rcm = (By.ID, "map-player-rcMenu")
element_should_be_visible(self, rcm)
-
element_should_contain
(element, text)¶ Verifies if text in element contains given text
Parameters: - element – Element representation (By, value).
- text – String text
Example: self.element_should_contain(self.CLASS_MAIN_HEADER, text)
-
element_text_length_should_be
(element, expected_length)¶ Verifies if element text length is equal to expected. Spaces are also counted.
Parameters: - element – Element representation (By, value) or WebElement
- expected_length – User provided expected length
Example: self.verify_text_length(self.FEATURELIST_FEATURE, u'13')
-
element_text_should_be
(element, text)¶ Verifies if text in element corresponds to expected one
Parameters: - element – Element representation (By, value).
- text – String text
Example: self.element_text_should_be(self.element, text)
-
element_value_should_be
(element, value)¶ Verifies if value of element corresponds to expected one
Parameters: - element – Element representation (By, value).
- value – String
Example: self.element_text_should_be(self.element, value)
-
elements_count_should_be
(element, value_int)¶ Verifies if count of elements corresponds to expected one
Parameters: - element – Element representation (By, value).
- value_int – Integer number
Example: self.elements_count_should_be(self.element, value_int)
-
email
(normal_length, maxlength)¶ Email input validation
Parameters: - normal_length – input minimum valid length
- maxlength – input maximum valid lengt
Returns: values dict of scenarios
Scenario1 valid: email Scenario2 invalid: domain Scenario3 invalid: invalid email char Scenario4 invalid: invalid max length
-
execute_async_javascript
(js_script, log=True)¶ Execute async JavaScript code
Parameters: - js_script – String represents JavaScript code
- log – Flag, if True prints action message
Returns: Object return by JavaScript code else None
-
execute_javascript
(js_script, log=True)¶ Execute JavaScript code
Parameters: - js_script – String represents JavaScript code
- log – Flag, if True prints action message
Returns: Object return by JavaScript code else None
Example: age model level examplevalue = self.execute_javascript("run_function(variable)")
Test level examplevalue = self.common_utils.execute_javascript("run_function(variable)")
-
execute_javascript_with_args
(js_script, *args)¶ Execute JavaScript code with arguments
Parameters: - js_script – String represents JavaScript code
- args – Arguments
Returns: Object return by JavaScript code else None
-
fail
(message)¶ Message to print in report as a String
Parameters: message – Message to print as a string. Example: Page model level exampleself.fail("My message")
Test level exampleself.common_utils.fail("My message")
-
find_element
(element)¶ Return found WebElement
Parameters: element – Element representation (By, value) or WebElement Returns: WebElement Example: Page model levelelement = self.find_element((By.LINK_TEXT, u'Trial'))
-
find_element_canvas
(element)¶ Return found WebElement
Parameters: element – (By, ‘value’) Returns: found WebElement
-
find_elements
(element)¶ Return found list of WebElement’s
Parameters: element – Element representation (By, value) or WebElement Returns: List of WebElement’s Example: Page model levelall_elements = self.find_elements((By.CSS_SELECTOR, u"img"))
-
generate_zap_test_report
(installation_dir, session_name, report_name='qautomate_zap_report.html')¶ Generate zap test report html
Note
Zapproxy UI and python client must be installed
Parameters: - installation_dir – Zap installation dir
- session_name – Zap session name
- report_name – Zap report name
Example: Test level examplezap, zap_session = self.common_utils.start_zapproxy_daemon('C:\ZedAttackProxy\zap.bat')
self.common_utils.stop_zapproxy_daemon(zap)
self.oommon_utils.generate_zap_test_report('C:\ZedAttackProxy\zap.bat', zap_session)
or self.common_utils.generate_zap_test_report('C:\ZedAttackProxy\zap.bat', zap_session, "qautomate_zap.html")
-
get_android_element_center
(element)¶ Returns midpoint coordinates of an android element
Parameters: element – Element representation (By, value) or WebElement Returns: midpoint coordinates of an android element
-
get_android_element_coordinates
(element)¶ Returns coordinates top left and bottom right corner of an android element
Parameters: element – Element representation (By, value) or WebElement Returns: coordinates top left and bottom right corner of an android element
-
get_android_element_name
(element)¶ Returns name of an android element
Parameters: element – Element representation (By, value) or WebElement Returns: name of an android element
-
get_attribute
(element, attr)¶ Return element’s attribute
Parameters: - element – Element representation (By, value) or WebElement
- attr – Attribute of an element
Returns: element’s attribute
Example: Page model level exampleusing web elementself.get_attribute(self.ID_DROPDOWN, "name")
using representationself.get_attribute((By.ID, u'dropdown'), "name")
Test level exampleusing web elementself.common_utils.get_attribute(self.elements.ID_DROPDOWN, "name")
-
get_browser_version
()¶ Returns browser version
Returns: version as String
-
get_current_browser
()¶ Get current active webdriver object.
Returns: Current active webdriver object.
-
get_current_driver
()¶ Get current active webdriver object.
Returns: Current active webdriver object.
-
get_current_url
()¶ Get current active browsers url as a String.
Returns: Current active browser url as a String.
-
get_dom_element_count
(log=True)¶ Counting DOM-elements
Returns: Returns number of DOM-elements on web page. Example: Page model level exampleself.get_dom_element_count()
Test level exampleself.common_utils.get_dom_element_count()
-
get_elements_count
(element)¶ Return number of found elements
Parameters: element – Element representation Returns: Number of found elements Example: Page model level exampleself.get_elements_count((By.CSS_SELECTOR, u"img"))
Test level exampleself.common_utils.get_elements_count((By.CSS_SELECTOR, u"img"))
-
get_js_memory_heap
(measurement_name)¶ Returns memory heap
Parameters: measurement_name – String represents name of measurement point Example: Page model level exampleself.get_js_memory_heap(measurement_name)
Test level exampleself.common_utils.get_js_memory_heap(measurement_name)
-
get_list_row_by_attribute_value
(element, attribute, value, row='LI', cell='')¶ Find list item row number by attribute value contains from UL list
Parameters: - element – List element representation (By, value) or WebElement object.
- attribute – Element’s attribute
- value – Element’s attribute value should contains
- row – Xpath to element where text should be default id ‘LI’
- cell – Xpath to element where text should be default id ‘’
Returns: element_row, value_row
Example: Page model level exampleusing web elementself.get_list_row_by_attribute_value(self.LIST, "name", "value_to_find")
element_rowlist = self.get_list_row_by_attribute_value(self.LIST, "name", parameters[u'member_id'], "LI","span")
element_rowlist[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_list_row_by_attribute_value((By.CSS_SELECTOR, u'#list'), "name", "value_to_find")
Test level exampleusing web elementself.common_utils.get_list_row_by_attribute_value(self.elements.LIST, "name", "value_to_find")
-
get_list_row_by_attribute_value_contains
(element, attribute, value, row='LI', cell='')¶ Find list item row number by attribute value contains from UL list
Parameters: - element – List element representation (By, value) or WebElement object.
- attribute – Element’s attribute
- value – Element’s attribute value should contains
- row – Xpath to element where text should be default id ‘LI’
- cell – Xpath to element where text should be default id ‘’
Returns: element_row, value_row
Example: Page model level exampleusing web elementself.get_list_row_by_attribute_value_contains(self.LIST, "name", "value_to_find","span")
element_rowlist = self.get_list_row_by_attribute_value_contains(self.LIST, "name", parameters[u'member_id'],"LI")
element_rowlist[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_list_row_by_attribute_value_contains((By.CSS_SELECTOR, u'#list'), "name", "value_to_find")
Test level exampleusing web elementself.common_utils.get_list_row_by_attribute_value_contains(self.elements.LIST, "name", "value_to_find")
-
get_list_row_by_text
(element, text, row='LI', cell='')¶ Find list item row number by text from UL list
Parameters: - element – List element representation (By, value) or WebElement object.
- text – Element’s text which should be
- row – Xpath to element where text should be default id ‘LI’
- cell – Xpath to element where text should be default id ‘’
Returns: element_row, text_row
Example: Page model level exampleusing web elementself.get_list_row_by_text(self.LIST, "text_to_find")
element_rowlist = self.get_list_row_by_text(self.LIST, parameters[u'member_id'],"LI")
element_rowlist[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_list_row_by_text((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "text_to_find")
Test level exampleusing web elementself.common_utils.get_list_row_by_text(self.elements.LIST, "text_to_find")
-
get_list_row_by_text_contains
(element, text, row='LI', cell='')¶ Find list item row number by contains text from UL list
Parameters: - element – List element representation (By, value) or WebElement object.
- text – Element’s text should contains
- row – Xpath to element where text should be default id ‘LI’
- cell – Xpath to element where text should be default id ‘’
Returns: element_row, text_row
Example: Page model level exampleusing web elementself.get_list_row_by_text_contains(self.LIST, "text_to_find")
element_rowlist = self.get_list_row_by_text_contains(self.ID_LIST, parameters[u'member_id'],"LI")
element_rowlist[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_list_row_by_text_contains((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "text_to_find")
Test level exampleusing web elementself.common_utils.get_list_row_by_text_contains(self.elements.LIST, "text_to_find")
-
get_list_row_by_value
(element, value, row='LI', cell='')¶ Find list item row number by value from UL list
Parameters: - element – List element representation (By, value) or WebElement object.
- value – Element’s value which should be
- row – Xpath to element where text should be default id ‘LI’
- cell – Xpath to element where text should be default id ‘’
Returns: element_row, value_row
Example: Page model level exampleusing web elementself.get_list_row_by_value(self.LIST, "value_to_find")
element_rowlist = self.get_list_row_by_value(self.LIST, parameters[u'member_id'],"LI")
element_rowlist[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_list_row_by_value((By.CSS_SELECTOR, u'#list'), "value_to_find")
Test level exampleusing web elementself.common_utils.get_list_row_by_value(self.elements.LIST, "value_to_find")
-
get_list_row_by_value_contains
(element, value, row='LI', cell='')¶ Find list item row number by value contains from UL list
Parameters: - element – List element representation (By, value) or WebElement object.
- value – Element’s value should contains
- row – Xpath to element where text should be default id ‘LI’
- cell – Xpath to element where text should be default id ‘’
Returns: element_row, value_row
Example: Page model level exampleusing web elementself.get_list_row_by_value_contains(self.LIST, "value_to_find")
element_rowlist = self.get_list_row_by_value_contains(self.LIST, parameters[u'member_id'],"LI","span")
element_rowlist[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_list_row_by_value_contains((By.CSS_SELECTOR, u'#list'), "value_to_find")
Test level exampleusing web elementself.common_utils.get_list_row_by_value_contains(self.elements.LIST, "value_to_find")
-
get_measurements
(measurement_name)¶ Return measurements
Parameters: measurement_name – String represents name of measurement point Returns: Measured time in specific point Example: Page model level exampleself.get_measurements("trial")
Test level exampleself.common_utils.get_measurements("trial")
-
get_number_from_string
(pattern, text)¶ Gets integer from string using regex
Parameters: - pattern – String, represents regex, can be used to get specific number from string if it contains many numbers
- text – String, which contains numbers
Returns: Number from string
Example: getNumberFromString("\d+ mins", "From to 11 stops left and time 36 mins") #returns 36
getNumberFromString("\d+", "From to 11 stops left and time 36 mins") #returns 11
getNumberFromString(":\d+", "11:56) #returns 56
-
get_page_source
()¶ Returns page source
Returns: page source Example: self.go_to("http://www.maps.nokia.com")
html_source = self.get_page_source()
if "City and Country Maps" in html_source:
do something
else:
do something else
-
get_random_value
(_list, *val_to_skip)¶ Return random value from list
Parameters: - _list – List of objects
- val_to_skip – Values to skip
Returns: Random value from list
Example: val_to skip = ["chart_months_6"]
RADIO_BTNS = (By.NAME, "chart_months")
get_random_value(RADI, val_to skip)
-
get_resource_timings
(measurement_name)¶ Return resource timings
Parameters: measurement_name – String represents name of measurement point Returns: Measured time in specific resource Example: Page model level exampleself.get_resource_timings("trial")
Test level exampleself.common_utils.get_resource_timings("trial")
-
get_selected_list_label
(element)¶ Return selected option text from dropdown list
Parameters: element – Element representation (By, value) or WebElement Returns: String text of selected option Example: Page model level exampleusing web elementself.get_selected_list_label(self.ID_DROPDOWN)
using representationself.get_selected_list_label((By.ID, u'dropdown'))
Test level exampleusing web elementself.common_utils.get_selected_list_label(self.elements.ID_DROPDOWN)
-
get_selected_list_labels
(element)¶ Return texts of list dropdown options
Parameters: element – Element representation (By, value) or WebElement Returns: List strings, which represent dropdown options texts Example: Page model level exampleusing web elementtext_list = self.get_selected_list_labels(self.ID_DROPDOWN)
using representationtext_list = self.get_selected_list_labels((By.ID, u'dropdown'))
Test level exampleusing web elementtext_list = self.common_utils.get_selected_list_labels(self.elements.ID_DROPDOWN)
-
get_selected_list_value
(element)¶ Return selected option value from dropdown list
Parameters: element – Element representation (By, value) or WebElement Returns: String value of selected option Example: Page model level exampleusing web elementself.get_selected_list_value(self.ID_DROPDOWN)
using representationself.get_selected_list_value((By.ID, u'dropdown'))
Test level exampleusing web elementself.common_utils.get_selected_list_value(self.elements.ID_DROPDOWN)
-
get_selected_list_values
(element)¶ Return values of list dropdown options
Parameters: element – Element representation (By, value) or WebElement Returns: List strings, which represent dropdown options texts Example: Page model level exampleusing web elementtext_list = self.get_selected_list_values(self.ID_DROPDOWN)
using representationtext_list = self.get_selected_list_values((By.ID, u'dropdown'))
Test level exampleusing web elementtext_list = self.common_utils.get_selected_list_values(self.elements.ID_DROPDOWN)
-
get_soap_response
(url, request_file_xml)¶ Gets SOAP response from web service to be used in verify_soap_api
Parameters: - url – Web service url
- request_file_xml – Request xml file in ../data/soap/requests/
Example: Page model level examplevalue = self.get_soap_response(u'http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL', u'soap_xml.xml')
Test level examplevalue = self.common_utils.get_soap_response(u'http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL', u'soap_xml.xml')
-
get_table_cell_text_by_column_and_row
(element, column, row, cell='TD')¶ get table cell text by given column and row.
Parameters: - element – Table element representation (By, value) or WebElement object.
- column – Table column where to click
- row – Table row where to click
- cell – Xpath to element which should be clicked, default is ‘TD’
Returns: Xpath to element which should be clicked, default is ‘TD’
Example: Page model level exampleusing web elementself.get_table_cell_text_by_column_and_row(self.TABLE, 1, 1)
using representationself.get_table_cell_text_by_column_and_row((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), 1, 1)
Test level exampleusing web elementself.common_utils.get_table_cell_text_by_column_and_row(self.elements.TABLE, 1, 1)
-
get_table_column_and_row_by_attribute_value
(element, attribute, value, row='TBODY/TR', cell='TD')¶ Find table column and row number by attribute value
Parameters: - element – Table element representation (By, value) or WebElement object.
- attribute – Element’s attribute
- value – Element’s attribute value should contains
- row – Xpath to element where text should be default id ‘TBODY/TR’
- cell – Xpath to element where text should be default id ‘TD’
Returns: element_row, element_col, text_row, text_col
Example: Page model level exampleusing web elementself.get_table_column_and_row_by_attribute_value(self.TABLE, "name", "attribute_to_find")
element_rowtable = self.get_table_column_and_row_by_attribute_value(self.ID_TABLE, "name", parameters[u'member_id'],"TBODY/TR","TD/SPAN")
element_rowtable[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_table_column_and_row_by_attribute_value((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "name", "attribute_to_find")
Test level exampleusing web elementself.common_utils.get_table_column_and_row_by_attribute_value(self.elements.TABLE, "name", "attribute_to_find")
-
get_table_column_and_row_by_attribute_value_contains
(element, attribute, value, row='TBODY/TR', cell='TD')¶ Find table column and row number by attribute value contains
Parameters: - element – Table element representation (By, value) or WebElement object.
- attribute – Element’s attribute
- value – Element’s attribute value should contains
- row – Xpath to element where text should be default id ‘TBODY/TR’
- cell – Xpath to element where text should be default id ‘TD’
Returns: element_row, element_col, text_row, text_col
Example: Page model level exampleusing web elementself.get_table_column_and_row_by_attribute_value_contains(self.TABLE, "name", "attribute_to_find")
element_rowtable = self.get_table_column_and_row_by_attribute_value_contains(self.ID_TABLE, "name", parameters[u'member_id'],"TBODY/TR","TD/SPAN")
element_rowtable[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_table_column_and_row_by_attribute_value_contains((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "name", "attribute_to_find")
Test level exampleusing web elementself.common_utils.get_table_column_and_row_by_attribute_value_contains(self.elements.TABLE, "name", "attribute_to_find")
-
get_table_column_and_row_by_multiple_text
(element, text1, text2, row='TBODY/TR', cell='TD')¶ Find table column and row number by text
Parameters: - element – Table element representation (By, value) or WebElement object.
- text1 – Element’s text1 which should be (match text1 and text2)
- text2 – Element’s text2 which should be (match text1 and text2)
- row – Xpath to element where text should be default id ‘TBODY/TR’
- cell – Xpath to element where text should be default id ‘TD’
Returns: element1_row, element1_col, text1_row, text1_column, element2_row, element2_col, text2_row, text2_column
Example: Page model level exampleusing web elementself.get_table_column_and_row_by_multiple_text(self.TABLE, "text_to_find1", "text_to_find2")
element_rowtable = self.get_table_column_and_row_by_multiple_text(self.ID_TABLE, parameters[u'member_id'], parameters[u'group_id'],"TBODY/TR","TD/SPAN")
element_rowtable[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_table_column_and_row_by_multiple_text((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "text_to_find")
Test level exampleusing web elementself.common_utils.get_table_column_and_row_by_text(self.elements.TABLE, "text_to_find")
-
get_table_column_and_row_by_text
(element, text, row='TBODY/TR', cell='TD')¶ Find table column and row number by text
Parameters: - element – Table element representation (By, value) or WebElement object.
- text – Element’s text which should be
- row – Xpath to element where text should be default id ‘TBODY/TR’
- cell – Xpath to element where text should be default i:d ‘TD’
Returns: element_row, element_col, text_row, text_col
Example: Page model level exampleusing web elementself.get_table_column_and_row_by_text(self.TABLE, "text_to_find")
element_rowtable = self.get_table_column_and_row_by_text(self.ID_TABLE, parameters[u'member_id'],"TBODY/TR","TD/SPAN")
element_rowtable[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_table_column_and_row_by_text((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "text_to_find")
Test level exampleusing web elementself.common_utils.get_table_column_and_row_by_text(self.elements.TABLE, "text_to_find")
-
get_table_column_and_row_by_text_contains
(element, text, row='TBODY/TR', cell='TD')¶ Find table column and row number by contains text
Parameters: - element – Table element representation (By, value) or WebElement object.
- text – Element’s text should contains
- row – Xpath to element where text should be default id ‘TBODY/TR’
- cell – Xpath to element where text should be default id ‘TD’
Returns: element_row, element_col, text_row, text_col
Example: Page model level exampleusing web elementself.get_table_column_and_row_by_text_contains(self.TABLE, "text_to_find")
element_rowtable = self.get_table_column_and_row_by_text_contains(self.ID_TABLE, parameters[u'member_id'],"TBODY/TR","TD/SPAN")
element_rowtable[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_table_column_and_row_by_text_contains((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "text_to_find_contains")
Test level exampleusing web elementself.common_utils.get_table_column_and_row_by_text_contains(self.elements.TABLE, "text_to_find_contains")
-
get_table_column_and_row_by_value
(element, value, row='TBODY/TR', cell='TD')¶ Find table column and row number by value
Parameters: - element – Table element representation (By, value) or WebElement object.
- value – Element’s value which should be
- row – Xpath to element where text should be default id ‘TBODY/TR’
- cell – Xpath to element where text should be default id ‘TD’
Returns: element_row, element_col, text_row, text_col
Example: Page model level exampleusing web elementself.get_table_column_and_row_by_value(self.TABLE, "text_to_find")
element_rowtable = self.get_table_column_and_row_by_value(self.ID_TABLE, parameters[u'member_id'],"TBODY/TR","TD/SPAN")
element_rowtable[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_table_column_and_row_by_value((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "text_to_find")
Test level exampleusing web elementself.common_utils.get_table_column_and_row_by_value(self.elements.TABLE, "text_to_find")
-
get_table_column_and_row_by_value_contains
(element, value, row='TBODY/TR', cell='TD')¶ Find table column and row number by contains value
Parameters: - element – Table element representation (By, value) or WebElement object.
- value – Element’s value should contains
- row – Xpath to element where text should be default id ‘TBODY/TR’
- cell – Xpath to element where text should be default id ‘TD’
Returns: element_row, element_col, text_row, text_col
Example: Page model level exampleusing web elementself.get_table_column_and_row_by_value_contains(self.TABLE, "text_to_find")
element_rowtable = self.get_table_column_and_row_by_value_contains(self.ID_TABLE, parameters[u'member_id'],"TBODY/TR","TD/SPAN")
element_rowtable[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_table_column_and_row_by_value_contains((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "text_to_find_contains")
Test level exampleusing web elementself.common_utils.get_table_column_and_row_by_value_contains(self.elements.TABLE, "text_to_find_contains")
-
get_table_size
(element)¶ Get table size
Parameters: element – Table element representation (By, value) or WebElement object. Returns: table_size, table_rows, table_columns Example: Page model level exampleusing web elementself.get_table_size(self.TABLE)
element_rowtable = self.get_table_size(self.ID_TABLE)
using representationself.get_table_size((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'))
Test level exampleusing web elementself.common_utils.get_table_size(self.elements.TABLE)
-
get_text
(element)¶ Return element’s text
Parameters: element – Element representation (By, value) or WebElement Returns: Text of element Example: Page model level exampleusing web elementvalue = self.get_text(self.TRIAL)
using representationvalue = self.get_text((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementvalue = self.common_utils.get_text(self.trial.TRIAL)
-
get_text_length
(element)¶ Return element text length. Spaces are also counted.
Parameters: element – Element representation (By, value) or WebElement Returns: WebElement text length as integer Example: Page model level exampleusing web elementvalue = self.get_text_length(self.TRIAL)
using representationvalue = self.get_text_length((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementvalue = self.common_utils.get_text_length(self.trial.TRIAL)
-
get_timestamp
()¶ Return timestamp
Format: ‘yyyyMMddhhmmss’ Returns: String which represents current time Example: Page model level examplevalue = self.get_timestamp()
Test level examplevalue = self.common_utils.get_timestamp()
-
get_value
(element)¶ Return element’s value
Parameters: element – Element representation (By, value) or WebElement Returns: Value of element Example: Page model level exampleusing web elementvalue = self.get_value(self.TRIAL)
using representationvalue = self.get_value((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementvalue = self.common_utils.get_value(self.trial.TRIAL)
-
get_web_response
(url, method, auth_file, data)¶ Return response from web service
Parameters: - url – Web service url
- method – Rest-api method. Get, post, put or delete.
- auth_file – Optional name of the auth_file. Blank if not needed.
- data – Optional data for request as string.
Returns: Web response from server
Example: Page model level examplevalue = self.get_web_response(u'http://api.openweathermap.org/data/2.5/weather?q=London&mode=xml', u'get', u'auth_file.txt', u'')
Test level examplevalue = self.common_utils.get_web_response(u'http://api.openweathermap.org/data/2.5/weather?q=London&mode=xml', u'get', u'auth_file.txt', u'')
-
get_window_size
()¶ Returns current window size width, height
Example: Page model level exampleself.get_window_size()
Test level exampleself.common_utils.get_window_size()
-
go_back
()¶ Simulates pressing Back button in browser window
Example: Page model level exampleself.go_back()
Test level exampleself.common_utils.go_back()
-
go_to
(url, log=True)¶ Open specified url
Parameters: - url – Url to open
- log – Flag, if True prints action message
Example: Page model level exampleself.go_to("http://qautomate.fi/")
Test level exampleself.common_utils.go_to("http://qautomate.fi/")
-
ignore_fail
(enable=True)¶
-
input_text
(element, value, to_print=True)¶ Clear and types text to input element
Parameters: - element – Element representation (By, value) or WebElement
- value – String to type in
- to_print – Flag, if True prints action message
Example: Page model levelusing web elementself.input_text(self.ID_CONTACT_FIRST_NAME, "this is value")
using representationself.input_text((By.ID, u'contact_first_name'), "this is value")
Test levelusing web elementself.common_utils.input_text(self.trial.ID_CONTACT_FIRST_NAME, "this is value")
-
is_aa
()¶ Returns True is browser is Android Application, else - False.
Returns: True is browser is Android Application, else - False.
-
is_ac
()¶ Returns True is browser is Android Chrome, else - False.
Returns: True is browser is Android Chrome, else - False.
-
is_current_driver
()¶ Is there current active webdriver object.
Returns: True or False
-
is_disabled
(element, timeout=None)¶ Return disability of element.
Parameters: - element – Element representation (By, value) or WebElement.
- timeout – No timeout used, unless custom value provided.
Returns: True if element disabled, else - False.
Example: Page model level exampleusing web elementself.is_disabled(self.TRIAL)
using representationself.is_disabled((By.LINK_TEXT, u'Trial'))
using timeoutself.is_disabled(self.TRIAL, 10)
self.is_disabled((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.is_disabled(self.trial.TRIAL)
using timeoutself.common_utils.is_disabled(self.trial.TRIAL, 10)
-
is_enabled
(element, timeout=None)¶ Return enablity of element.
Parameters: - element – Element representation (By, value) or WebElement.
- timeout – No timeout used, unless custom value provided.
Returns: True if element enabled, else - False.
Example: Page model level exampleusing web elementself.is_enabled(self.TRIAL)
using representationself.is_enabled((By.LINK_TEXT, u'Trial'))
using timeoutself.is_enabled(self.TRIAL, 10)
self.is_enabled((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.is_enabled(self.trial.TRIAL)
using timeoutself.common_utils.is_enabled(self.trial.TRIAL, 10)
-
is_ff
()¶ Returns True is browser is Firefox, else - False.
Returns: True is browser is Firefox, else - False.
-
is_gc
()¶ Returns True is browser is Google Chrome, else - False.
Returns: True is browser is Google Chrome, else - False.
-
is_ie
()¶ Returns True is browser is Internet Explorer, else - False.
Returns: True is browser is Internet Explorer, else - False.
-
is_op
()¶ Returns True is browser is Opera, else - False.
Returns: True is browser is Opera, else - False.
-
is_present
(element, timeout=None)¶ Return True if element presents in source code, else - False
Parameters: - element – Element representation (By, value).
- timeout – No timeout used, unless custom value provided.
Returns: True if element presents in source code, else - False.
Example: Page model level exampleusing web elementself.is_present(self.ID_TESTINPUT)
using representationself.is_present((By.ID, u'testInput'))
using timeoutself.is_present(self.ID_TESTINPUT, 10)
self.is_present(By.ID, u'testInput'), 10)
Test level exampleusing web elementself.common_utils.is_present(self.elements.ID_TESTINPUT)
using timeoutself.common_utils.is_present(self.elements.ID_TESTINPUT, 10)
-
is_visible
(element, timeout=None)¶ Return visibility of element.
Parameters: - element – Element representation (By, value) or WebElement.
- timeout – No timeout used, unless custom value provided.
Returns: visibility of element. True or False.
Example: Page model level exampleusing web elementself.is_visible(self.TRIAL)
using representationself.is_visible((By.LINK_TEXT, u'Trial'))
using timeoutself.is_visible(self.TRIAL, 10)
self.is_visible((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.is_visible(self.trial.TRIAL)
using timeoutself.common_utils.is_visible(self.trial.TRIAL, 10)
-
list_label_should_be
(element, text)¶ Verifies if text of selected item in drop-down list corresponds to expected one
Parameters: - element – Element representation (By, value).
- text – String text
Example: self.list_label_should_be(self.element, text)
-
list_value_should_be
(element, value)¶ Verifies if value of selected item in drop-down list corresponds to expected one
Parameters: - element – Element representation (By, value).
- value – Value of the item
Example: self.list_value_should_be(self.element, value)
-
measure_async_screen_response_time
(measurement_name, timeout, reference_picture, element=None)¶ Return page loading time based on screenshot verification
Parameters: - measurement_name – String represents name of measure point
- timeout – Int represents how long (in seconds) to take screenshots
- reference_picture – String represents name of the reference picture
- element – Tuple represents element: (By, ‘value’)
Returns: return Time in seconds how long takes to find correct screenshot or if no match found return False
Example: Page model levelself.measure_async_screen_response_time("trial", 10, "trial_perf_pic")
Test levelself.common_utils.measure_async_screen_response_time("trial", 10, "trial_perf_pic")
-
measure_exc_time
(func, *args, **kwargs)¶ Python decorator
Use it for measuring function elapsed time
Usage: simply add “@measure_exc_time” before measuring function
Parameters: - func – Function which will be executed
- args – Function agruments
- kwargs – Function keyword arguments
Returns: wrapped Function
Example: @measure_exc_time
def go_to(url):
-
mouse_down
(element)¶ Click and hold mouse left button at element. Element is pressed without releasing button
Parameters: element – Element representation (By, value) or WebElement object. Example: Page model level exampleusing web elementself.mouse_down(self.TRIAL)
using representationself.mouse_down((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementself.common_utils.mouse_down(self.trial.TRIAL)
-
mouse_over
(element)¶ Mouse overhover element
Parameters: element – Element representation (By, value) or WebElement object. Example: Page model level exampleusing web elementself.mouse_over(self.TRIAL)
using representationself.mouse_over((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementself.common_utils.mouse_over(self.trial.TRIAL)
-
mouse_over_by_offset
(element, xoffset, yoffset)¶ Mouse overhover element by offset
Parameters: - element – Element representation (By, value) or WebElement object.
- xoffset – X coordinate offset
- yoffset – coordinate offset
Example: Page model level exampleusing web elementself.mouse_over_by_offset(self.TRIAL, 0, 0)
using representationself.mouse_over_by_offset((By.LINK_TEXT, u'Trial'), 0, 0)
Test level exampleusing web elementself.common_utils.mouse_over_by_offset(self.trial.TRIAL, 0, 0)
-
mouse_right_click_by_offset
(element, xoffset, yoffset)¶ Mouse right click at element by offset
Parameters: - element – Element representation (By, value) or WebElement object.
- xoffset – X coordinate offset
- yoffset – Y coordinate offset
Example: Page model level exampleusing web elementself.mouse_right_click_by_offset(self.TRIAL, 0, 0)
using representationself.mouse_right_click_by_offset((By.LINK_TEXT, u'Trial'), 0, 0)
Test level exampleusing web elementself.common_utils.mouse_right_click_by_offset(self.trial.TRIAL, 0, 0)
-
mouse_up
(element)¶ Releases mouse left button at element. Element
Parameters: element – Element representation (By, value) or WebElement object. Example: Page model level exampleusing web elementself.mouse_up(self.TRIAL)
using representationself.mouse_up((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementself.common_utils.mouse_up(self.trial.TRIAL)
-
open_browser
(browser_name=None, url=None, alias=None, size=None)¶ Open specified browser with url
Parameters: - browser_name – Browser to open
- url – Url to open
- alias – save driver with alias
- size – Browser window size. Fullscreen if none.
Returns: id
Example: Page model level exampleself.open_browser("ff", http://qautomate.fi/")
Test level exampleself.common_utils.open_browser("ff", "http://qautomate.fi/")
Mouse right click at element opening context menu
Parameters: element – Element representation (By, value) or WebElement object. Example: Page model level exampleusing web elementself.open_context_menu(self.TRIAL)
using representationself.open_context_menu((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementself.common_utils.open_context_menu(self.trial.TRIAL)
-
open_url
(url, log=True)¶ Open specified url
Parameters: - url – Url to open
- log – Flag, if True prints action message
Example: Page model level exampleself.open_url("http://qautomate.fi/")
Test level exampleself.common_utils.open_url("http://qautomate.fi/")
-
optional
()¶ Optional input validation
Returns: values dict of scenarios Scenario1 valid: empty
Radiobutton checked input validation
Returns: values dict of scenarios Scenario1 valid: checked
Radiobutton input validation
Returns: values dict of scenarios Scenario1 valid: unchecked
-
reload_page
()¶ Refreshes page
Example: Page model level exampleself.refresh_page()
Test level exampleself.common_utils.refresh_page()
-
required
()¶ Required input validation
Returns: values dict of scenarios Scenario1 invalid: empty
-
robot_script_runner
(robot_script)¶ Runs robot framework scripts
Parameters: robot_script – Robot framework script Example: Page model levelself.robot_script_runner("C:\Users\username\Documents\script.robot")
Test level exampleself.common_utils.robot_script_runner("C:\Users\username\Documents\script.robot")
-
save_screenshot
(saving_dir=None, action='')¶ Take browser view screenshot.
Note
Default place of screenshots is temp directory.
Parameters: - saving_dir – Directory where screenshot is placed
- action – String which is added to file name
Example: save_screenshot(os.path.join(os.pardir, "test_results"), 'clicking')
-
select_checkbox
(element, status='checked')¶ Checks the checkbox
Parameters: - element – checkbox element
- status – final state of the checkbox “checked” or “unchecked”
Example: Page model level exampleusing web elementself.select_checkbox(self.ID_CHECKBOX1)
self.select_checkbox(self.ID_CHECKBOX1, "unchecked")
using representationself.select_checkbox((By.ID, u'checkbox1'))
self.select_checkbox((By.ID, u'checkbox1'), "unchecked")
Test level exampleusing web elementself.common_utils.select_checkbox(self.elements.ID_CHECKBOX1)
-
select_frame
(element)¶ Switch focus to frame
Parameters: element – Element representation (By, value), WebElement or frame name. Example: Page model level exampleusing web elementself.select_frame(self.IFRAME)
using representationself.select_frame((By.CSS_SELECTOR, u'iframe'))
Test level exampleusing web elementself.common_utils.select_frame(self.home.IFRAME)
-
select_frame_default_content
()¶ Switch focus to default content
Example: Page model level exampleself.select_frame_default_content()
Test level exampleself.common_utils.select_frame_default_content()
-
select_from_list_by_label
(element, text)¶ Select option from dropdown list by text
Parameters: - element – Element representation (By, value) or WebElement
- text – Dropdown option visible text
Example: Page model level exampleusing web elementself.select_from_list_by_label(self.ID_DROPDOWN, "value")
using representationself.select_from_list_by_label((By.ID, u'dropdown'), "value")
Test level exampleusing web elementself.common_utils.select_from_list_by_label(self.elements.ID_DROPDOWN, "value")
-
select_from_list_by_random_option
(element, *val_to_skip)¶ Select random option from dropdown list
Parameters: - element – Element representation (By, value) or WebElement
- val_to_skip – Values to skip
Example: Page model level exampleusing web elementself.select_from_list_by_random_option(self.ID_DROPDOWN)
using representationself.select_from_list_by_random_option((By.ID, u'dropdown'))
Test level exampleusing web elementself.common_utils.select_from_list_by_random_option(self.elements.ID_DROPDOWN)
-
select_from_list_by_value
(element, value)¶ Select option from dropdown list by value
Parameters: - element – Element representation (By, value) or WebElement
- value – Dropdown option value
Example: Page model level exampleusing web elementself.select_from_list_by_value(self.ID_DROPDOWN, 10)
using representationself.select_from_list_by_value((By.ID, u'dropdown'), 10)
Test level exampleusing web elementself.common_utils.select_from_list_by_value(self.elements.ID_DROPDOWN, 10)
-
select_window
(function, *args)¶ Switch focus to new window
Parameters: - function – Function which opens new window
- args – list of arguments for function
Example: terms_of_use = (By.CLASS_NAME, 'MCCopyrightTerms')
function = find_element(terms_of_use).click
select_window(function)
select_window(self.click, terms_of_use)
-
send_keys
(element, value, to_print=True)¶ Type value to element
Parameters: - element – Element representation (By, value) or WebElement
- value – Value to type in to the element
- to_print – Flag, if True prints action message
Example: Page model levelusing web elementself.send_keys(self.ID_CONTACT_FIRST_NAME, "this is value")
using representationself.send_keys((By.ID, u'contact_first_name'), "this is value")
Test levelusing web elementself.common_utils.send_keys(self.trial.ID_CONTACT_FIRST_NAME, "this is value")
-
set_window_size
(width, height)¶ Set current window size width, height
Parameters: - width – window width
- height – window height
Example: Page model level exampleself.set_window_size(800, 600)
Test level exampleself.common_utils.set_window_size(800, 600)
-
start_zapproxy_daemon
(installation_dir)¶ Start Zap proxy daemon
Note
Zapproxy UI and python client must be installed
Parameters: installation_dir – Zapproxy installation folder Returns: Zap daemon object, zap session name Example: Page model level examplezap, zap_session = self.start_zapproxy_daemon('C:\ZedAttackProxy\zap.bat')
Test level examplezap, zap_session = self.common_utils.start_zapproxy_daemon('C:\ZedAttackProxy\zap.bat')
-
stop_zapproxy_daemon
(zap)¶ Stop Zap proxy daemon
Note
Zapproxy UI and python client must be installed
Parameters: zap – Zap proxy object Example: Test level examplezap, zap_session = self.common_utils.start_zapproxy_daemon('C:\ZedAttackProxy\zap.bat')
self.common_utils.stop_zapproxy_daemon(zap)
-
switch_browser
(id_or_alias)¶ Switch between active browsers using id or alias
Parameters: id_or_alias – Identify new active browser Example: Page model level example with idid = self.open_browser("ff", "http://qautomate.fi/")
id2 = self.open_browser("ff", "http://qautomate.fi/")
run some stepsself.switch_browser(id)
Test level example with aliasself.common_utils.open_browser("ff", "http://qautomate.fi/", "alias1")
self.common_utils.open_browser("ff", "http://qautomate.fi/", "alias2")
run some stepsself.common_utils.switch_browser("alias1")
-
table_contains_text
(element, value)¶ Checks if table contains text
Parameters: - element – Table element representation (By, value) or WebElement object.
- value – String
Returns: Boolean value
Example: using web elementself.table_contains_text(self.TABLE, u'in_table')
using representationself.table_contains_text((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'in_table')
Test level exampleusing web elementself.common_utils.table_contains_text(self.elements.TABLE, u'in_table')
-
take_full_screenshot
(pic_name, height_override=None)¶
-
tel
(minlength, maxlength)¶ Telephone input validation
Parameters: - minlength – input minimum valid length
- maxlength – input maximum valid length
Returns: values dict of scenarios
Scenario1 valid: number without country code Scenario2 valid: number with country code Scenario3 valid: min length number without country code Scenario4 valid: max length number without country code Scenario5 valid: min length number with country code Scenario6 valid: max length number with country code Scenario7 invalid: min length number with country code Scenario8 invalid: max length number with country code
-
title_should_be
(string)¶ Verifies if page title corresponds to expected one
Parameters: string – expected page title
-
triple_click_element
(element, to_print=True)¶ Triple click at element
Parameters: - element – Element representation (By, value) or WebElement
- to_print – Flag, if True prints action message
Example: Page model level exampleusing web elementself.triple_click_element(self.TRIAL)
using representationself.triple_click_element((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementself.common_utils.triple_click_element(self.trial.TRIAL)
-
unselect_checkbox
(element, status='unchecked')¶ Unchecks the checkbox
Parameters: - element – checkbox element
- status – final state of the checkbox “checked” or “unchecked”
Example: Page model level exampleusing web elementself.unselect_checkbox(self.ID_CHECKBOX1)
using representationself.unselect_checkbox((By.ID, u'checkbox1'))
Test level exampleusing web elementself.common_utils.unselect_checkbox(self.elements.ID_CHECKBOX1)
-
verify_rest_api_json_value
(url, method, expected_file, auth_file, request_file_json)¶ Verifies if REST-API values are equal to expected ones. Supports get, post, put and delete methods. Only JSON format.
Directories for request, response and login files are in your working directory
../data/..
Key example: coord.latParameters: - url – Web request url
- method – Rest-api method. Get, post, put or delete.
- expected_file – Text file which includes key/value pairs to verify. One verification per line: key expected_value.
- auth_file – Optional login credentials text file. Only one line: username password. Leave blank if not needed.
- request_file_json – Name of the request file. Leave blank if not needed.
Example: url = u'http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=2de143494c0b295cca9337e1e96b00e0'
self.verify_rest_api_json_value(url, u'get', u'expected.txt', u'', u'')
self.verify_rest_api_json_value(u'http://exampleurl.com', u'post', u'expected_response.txt', u'auth.txt', u'request.txt')
-
verify_rest_api_xml_value
(url, method, expected_file, auth_file, request_file_xml)¶ Verifies if REST-API values are equal to expected ones. Supports get, post, put and delete methods. Only XML format.
Xpath examples:
"//city[1]/country[1]/text()"
,"//city[1]/coord[1]/@lat"
Parameters: - url – Web request url
- method – get, post, put or delete
- expected_file – Text file which includes xpaths and expected values to verify. One verification per line: xpath expected_value
- auth_file – Optional login credentials text file. Only one line: username password. Leave blank if not needed.
- request_file_xml – Name of the request xml file. Leave blank if not needed.
Example: url = u'http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=2de143494c0b295cca9337e1e96b00e0&mode=xml'
self.verify_rest_api_xml_value(url, u'get', u'expected.txt', u'', u'')
self.verify_rest_api_xml_value(u'http://exampleurl.com', u'post', u'expected_response.txt', u'auth.txt', u'request.xml')
-
verify_soap_api_value
(url, request_file_xml, response_file, full_file=True)¶ Verifies if SOAP-API values are equal to expected ones.
Place for request and response files:
../data/soap/..
If verifying single values: One verification per line in response file. xpath expected_value
Parameters: - url – Web service url
- request_file_xml – Request xml filename
- response_file – File which includes expectes response or key/value pairs
- full_file – Boolean: If true verify full reponse, if false verify single values
Example: self.verify_soap_api(u'http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL', u'soap_xml.xml', response_file.txt)
-
verify_text
(element, value)¶ Verifies if text in the element corresponds to expected one
-
verify_value
(element, value)¶ Verifies if value of element corresponds to expected one
-
wait_for_condition
(js_script, value, msg=None)¶ Wait for condition JavaScript returns value
Parameters: - js_script – Executable JavaScript
- value – Expected value which should be returned by JavaScript
- msg – Message
Example: wait_for_condition("document.title", "javascript - hide index.html in the URL - Stack Overflow")
-
wait_until_document_ready
()¶ Wait until browser finish loading webpage
Execute JS to check readyState of DOM page object.
Example: Page model level exampleself.wait_until_document_ready()
Test level exampleself.common_utils.wait_until_document_ready()
-
wait_until_element_attribute_contains
(element, attr, expected_value, timeout=None)¶ Wait until element’s attribute contains value
Parameters: - element – Element representation (By, value) or WebElement.
- attr – Element’s attribute
- expected_value – Element’s attribute value which should be
- timeout – Uses default timeout, unless custom value provided.
Example: Page model level exampleusing web elementself.wait_until_element_attribute_contains(self.ID_DROPDOWN, "name", "dropdown")
using representationself.wait_until_element_attribute_contains((By.ID, u'dropdown'), "name", "dropdown")
using timeoutself.wait_until_element_attribute_contains(self.ID_DROPDOWN, "name", "dropdown", 10)
self.wait_until_element_attribute_contains((By.ID, u'dropdown'), "name", "dropdown", 10)
Test level exampleusing web elementself.common_utils.wait_until_element_attribute_contains(self.elements.ID_DROPDOWN, "name" "dropdown")
using timeoutself.common_utils.wait_until_element_attribute_contains(self.elements.ID_DROPDOWN, "name" "dropdown", 10)
-
wait_until_element_contains
(element, text, timeout=None)¶ Wait until element’s contains text
Parameters: - element – Element representation (By, value) or WebElement.
- text – Element’s text which should be
- timeout – Uses default timeout, unless custom value provided.
Example: Page model level exampleusing web elementself.common_utils.wait_until_element_contains(self.elements.TEST, u'Cell text is this')
self.wait_until_element_contains((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text is this'1', 10)
Test level exampleusing web elementself.common_utils.wait_until_element_contains(self.elements.TEST, u'Cell text is this')
using timeoutself.common_utils.wait_until_element_contains(self.elements.TEST, u'Cell text is this', 10)
-
wait_until_element_does_not_contain
(element, text, timeout=None)¶ Wait until element’s does not contains text
Parameters: - element – Element representation (By, value) or WebElement.
- text – Element’s text which should not be
- timeout – Uses default timeout, unless custom value provided.
Example: Page model level exampleusing web elementself.wait_until_element_does_not_contain(self.TEST, u'Cell text changed')
using representationself.wait_until_element_does_not_contain((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text changed')
using timeoutself.wait_until_element_does_not_contain(self.TEST, u'Cell text changed', 10)
self.wait_until_element_does_not_contain((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text changed', 10)
Test level exampleusing web elementself.common_utils.wait_until_element_does_not_contain(self.elements.TEST, u'Cell text changed')
using timeoutself.common_utils.wait_until_element_does_not_contain(self.elements.TEST, u'Cell text changed', 10)
-
wait_until_element_is_disabled
(element, timeout=None, msg=None)¶ Wait until element is disabled.
Parameters: - element – Element representation (By, value) or WebElement object.
- timeout – Uses default timeout, unless custom value provided.
- msg – Message if element is not disabled
Exception: If time exceeds DEFAULT_TIMEOUT, then rise exception.
Example: Page model level exampleusing web elementself.wait_until_element_is_disabled(self.TRIAL)
using representationself.common_utils.wait_until_element_is_disabled((By.LINK_TEXT, u'Trial'))
using timeoutself.wait_until_element_is_disabled(self.TRIAL, 10)
self.wait_until_element_is_disabled((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.wait_until_element_is_disabled(self.trial.TRIAL)
using timeoutself.common_utils.wait_until_element_is_disabled(self.trial.TRIAL, 10)
-
wait_until_element_is_enabled
(element, timeout=None, msg=None)¶ Wait until element is enabled.
Parameters: - element – Element representation (By, value) or WebElement object.
- timeout – Uses default timeout, unless custom value provided.
- msg – Message if element is not enabled.
Exception: If time exceeds DEFAULT_TIMEOUT, then rise exception.
Example: Page model level exampleusing web elementself.wait_until_element_is_enabled(self.TRIAL)
using representationself.common_utils.wait_until_element_is_enabled((By.LINK_TEXT, u'Trial'))
using timeoutself.wait_until_element_is_enabled(self.TRIAL, 10)
self.wait_until_element_is_enabled((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.wait_until_element_is_enabled(self.trial.TRIAL)
using timeoutself.common_utils.wait_until_element_is_enabled(self.trial.TRIAL, 10)
-
wait_until_element_is_not_present
(element, timeout=None)¶ Wait for element is not present in source code.
Raises: Exception – if time exceeds DEFAULT_TIMEOUT, then rise exception.
Parameters: - element – Element representation (By, value).
- timeout – Uses default timeout, unless custom value provided.
Example: Page model level exampleusing web elementself.wait_until_element_is_not_present(self.ID_TESTINPUT)
using representationself.wait_until_element_is_not_present((By.ID, u'testInput'))
using timeoutself.wait_until_element_is_not_present(self.ID_TESTINPUT, 10)
self.wait_until_element_is_not_present((By.ID, u'testInput'), 10)
Test level exampleusing web elementself.common_utils.wait_until_element_is_not_present(self.elements.ID_TESTINPUT)
using timeoutself.common_utils.wait_until_element_is_not_present(self.elements.ID_TESTINPUT, 10)
-
wait_until_element_is_not_visible
(element, timeout=None, msg=None)¶ Wait until element specified is not visible
Parameters: - element – Element representation (By, value) or WebElement object.
- timeout – Uses default timeout, unless custom value provided.
- msg – Message if element is visible
Exception: If time exceeds DEFAULT_TIMEOUT, then rise exception.
Example: Page model level exampleusing web elementself.wait_until_element_is_not_visible(self.TRIAL)
using representationself.common_utils.wait_until_element_is_not_visible((By.LINK_TEXT, u'Trial'))
using timeoutself.wait_until_element_is_not_visible(self.TRIAL, 10)
self.wait_until_element_is_not_visible((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.wait_until_element_is_not_visible(self.trial.TRIAL)
using timeoutself.common_utils.wait_until_element_is_not_visible(self.trial.TRIAL, 10)
-
wait_until_element_is_present
(element, timeout=None)¶ Wait for element is present in source code.
Raises: Exception – if time exceeds DEFAULT_TIMEOUT, then rise exception.
Parameters: - element – Element representation (By, value).
- timeout – Uses default timeout, unless custom value provided.
Example: Page model level exampleusing web elementself.wait_until_element_is_present(self.ID_TESTINPUT)
using representationself.wait_until_element_is_present((By.ID, u'testInput'))
using timeoutself.wait_until_element_is_present(self.ID_TESTINPUT, 10)
self.wait_until_element_is_present((By.ID, u'testInput'), 10)
Test level exampleusing web elementself.common_utils.wait_until_element_is_present(self.elements.ID_TESTINPUT)
using timeoutself.common_utils.wait_until_element_is_present(self.elements.ID_TESTINPUT, 10)
-
wait_until_element_is_visible
(element, timeout=None, msg=None)¶ Wait until element specified is visible
Parameters: - element – Element representation (By, value) or WebElement object.
- timeout – Uses default timeout, unless custom value provided.
- msg – Message if element is not visible
Exception: If time exceeds DEFAULT_TIMEOUT, then rise exception.
Example: Page model level exampleusing web elementself.wait_until_element_is_visible(self.TRIAL)
using representationself.common_utils.wait_until_element_is_visible((By.LINK_TEXT, u'Trial'))
using timeoutself.wait_until_element_is_visible(self.TRIAL, 10)
self.wait_until_element_is_visible((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.wait_until_element_is_visible(self.trial.TRIAL)
using timeoutself.common_utils.wait_until_element_is_visible(self.trial.TRIAL, 10)
-
wait_until_element_is_visible_canvas
(element, msg=None, timeout=None)¶ Wait until visible
Parameters: - element – element: (By, ‘value’)
- msg – Message
- timeout – Using default timeout
-
wait_until_element_should_be
(element, text, timeout=None)¶ Wait until element’s text is equal
Parameters: - element – Element representation (By, value) or WebElement.
- text – Element’s text which should be
- timeout – Uses default timeout, unless custom value provided.
Example: Page model level exampleusing web elementself.wait_until_element_should_be(self.TEST, u'Cell text is this')
using representationself.wait_until_element_should_be((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text is this')
using timeoutself.wait_until_element_should_be(self.TEST, u'Cell text is this', 10)
self.wait_until_element_should_be((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text is this'1', 10)
Test level exampleusing web elementself.common_utils.wait_until_element_should_be(self.elements.TEST, u'Cell text is this')
using timeoutself.common_utils.wait_until_element_should_be(self.elements.TEST, u'Cell text is this', 10)
-
wait_until_element_should_not_be
(element, text, timeout=None)¶ Wait until element’s text is not equal
Parameters: - element – Element representation (By, value) or WebElement.
- text – Element’s text which should not be
- timeout – Uses default timeout, unless custom value provided.
Example: Page model level exampleusing web elementself.wait_until_element_should_not_be(self.TEST, u'Cell text changed')
using representationself.wait_until_element_should_not_be((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text changed')
using timeoutself.wait_until_element_should_not_be(self.TEST, u'Cell text changed', 10)
self.wait_until_element_should_not_be((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text changed', 10)
Test level exampleusing web elementself.common_utils.wait_until_element_should_not_be(self.elements.TEST, u'Cell text changed')
using timeoutself.common_utils.wait_until_element_should_not_be(self.elements.TEST, u'Cell text changed', 10)
-
wait_until_jquery_ajax_loaded
(timeout=None)¶ Wait until browser is finished loading jQuery
Execute JS to check is jQuery active.
Parameters: timeout – Uses default timeout, unless custom value provided. Example: Page model level exampleself.wait_until_jquery_ajax_loaded()
Test level exampleself.common_utils.wait_until_jquery_ajax_loaded()
-
wait_until_page_contains
(text, timeout=None)¶ Wait until page’s contains text
Parameters: - text – Element’s text which should be
- timeout – Uses default timeout, unless custom value provided.
Example: Page model level exampleusing web elementself.wait_until_page_contains(u'Cell text is this')
using representationself.wait_until_page_contains((u'Cell text is this')
using timeoutself.wait_until_page_contains(u'Cell text is this', 10)
self.wait_until_page_contains(u'Cell text is this', 10)
Test level exampleusing web elementself.common_utils.wait_until_page_contains(u'Cell text is this')
using timeoutself.common_utils.wait_until_page_contains(u'Cell text is this', 10)
-
wait_until_page_does_not_contain
(text, timeout=None)¶ Wait until page’s does not contain text
Parameters: - text – Element’s text which should be
- timeout – Uses default timeout, unless custom value provided.
Example: Page model level exampleusing web elementself.wait_until_page_contain(u'Cell text is this')
using representationself.wait_until_page_contain((u'Cell text is this')
using timeoutself.wait_until_page_contain(u'Cell text is this', 10)
self.wait_until_page_contain(u'Cell text is this', 10)
Test level exampleusing web elementself.common_utils.wait_until_page_contain(u'Cell text is this')
using timeoutself.common_utils.wait_until_page_contain(u'Cell text is this', 10)
-
wait_until_table_size_changes
(element, timeout=None, msg=None)¶ Wait until table size changes
Raises: Exception – if time exceeds DEFAULT_TIMEOUT, then rise exception.
Parameters: - element – Element representation (By, value) or WebElement object.
- timeout – Uses default timeout, unless custom value provided.
- msg – Message
Example: Page model level exampleusing web elementself.wait_until_table_size_changes(self.ID_TABLETEST)
using representationself.wait_until_table_size_changes((By.ID, u'tableTest'))
using timeoutself.wait_until_table_size_changes(self.ID_TABLETEST, 10)
self.wait_until_table_size_changes((By.ID, u'tableTest'), 10)
Test level exampleusing web elementself.common_utils.wait_until_table_size_changes(self.demo.tableTest)
using timeoutself.common_utils.wait_until_table_size_changes(self.demo.tableTest, 10)
-
warning
(message)¶ Adds warning to test report
Parameters: message – Message to print as a String Example: Page model level exampleself.warning("My message")
Test level exampleself.common_utils.warning("My message")
-
classmethod
write_value_jtl_file
(measurement_name, sample)¶ Writes given value to file in jtl format
Parameters: - measurement_name – label of the measurement (also file name) as a String
- sample – value to save in the file as Int (seconds)
-
-
class
webframework.extension.util.common_utils.
CommonWrappers
(driver_cache=None)¶ -
click_element
(element)¶
-
click_element_at_coordinates
(x, y)¶
-
compare_element_screenshots
(element, parameters)¶
-
compare_screenshots
(parameters)¶
-
element_should_be
(element, parameters)¶
-
element_value_should_be
(element, parameters)¶
-
fail
(message)¶
-
input_text
(element, parameters)¶
-
send_keys
(element, parameters)¶
-
wait_until_element_is_visible
(element)¶
-
-
class
webframework.extension.util.common_utils.
TextGenerator
¶ -
static
random_alpha
(minlength, maxlength)¶
-
static
random_alpha_invalid_max
(maxlength)¶
-
static
random_alpha_invalid_min
(minlength)¶
-
static
random_alpha_lower
(minlength, maxlength)¶
-
static
random_alpha_lower_invalid_max
(maxlength)¶
-
static
random_alpha_lower_invalid_min
(minlength)¶
-
static
random_alpha_lower_max
(maxlength)¶
-
static
random_alpha_lower_min
(minlength)¶
-
static
random_alpha_max
(maxlength)¶
-
static
random_alpha_min
(minlength)¶
-
static
random_alpha_upper
(minlength, maxlength)¶
-
static
random_alpha_upper_invalid_max
(maxlength)¶
-
static
random_alpha_upper_invalid_min
(minlength)¶
-
static
random_alpha_upper_max
(maxlength)¶
-
static
random_alpha_upper_min
(minlength)¶
-
static
random_alphachar
(minlength, maxlength)¶
-
static
random_alphachar_invalid_max
(maxlength)¶
-
static
random_alphachar_invalid_min
(minlength)¶
-
static
random_alphachar_lower
(minlength, maxlength)¶
-
static
random_alphachar_max
(maxlength)¶
-
static
random_alphachar_min
(minlength)¶
-
static
random_alphachar_upper
(minlength, maxlength)¶
-
static
random_alphadigit
(minlength, maxlength)¶
-
static
random_alphadigit_invalid_max
(maxlength)¶
-
static
random_alphadigit_invalid_min
(minlength)¶
-
static
random_alphadigit_lower
(minlength, maxlength)¶
-
static
random_alphadigit_lower_invalid_max
(maxlength)¶
-
static
random_alphadigit_lower_invalid_min
(minlength)¶
-
static
random_alphadigit_lower_max
(maxlength)¶
-
static
random_alphadigit_lower_min
(minlength)¶
-
static
random_alphadigit_max
(maxlength)¶
-
static
random_alphadigit_min
(minlength)¶
-
static
random_alphadigit_upper
(minlength, maxlength)¶
-
static
random_alphadigit_upper_invalid_max
(maxlength)¶
-
static
random_alphadigit_upper_invalid_min
(minlength)¶
-
static
random_alphadigit_upper_max
(maxlength)¶
-
static
random_alphadigit_upper_min
(minlength)¶
-
static
random_alphadigitchar
(minlength, maxlength)¶
-
static
random_alphadigitchar_invalid_max
(maxlength)¶
-
static
random_alphadigitchar_invalid_min
(minlength)¶
-
static
random_alphadigitchar_max
(maxlength)¶
-
static
random_alphadigitchar_min
(minlength)¶
-
static
random_date_dot_format_future_daymonthyear
()¶
-
static
random_date_dot_format_future_monthdayyear
()¶
-
static
random_date_dot_format_future_yearmonthday
()¶
-
static
random_date_dot_format_invalid_format
()¶
-
static
random_date_dot_format_now_daymonthyear
()¶
-
static
random_date_dot_format_now_monthdayyear
()¶
-
static
random_date_dot_format_now_yearmonthday
()¶
-
static
random_date_dot_format_past_daymonthyear
()¶
-
static
random_date_dot_format_past_monthdayyear
()¶
-
static
random_date_dot_format_past_yearmonthday
()¶
-
static
random_date_line_format_now_daymonthyear
()¶
-
static
random_date_line_format_now_monthdayyear
()¶
-
static
random_date_line_format_now_yearmonthday
()¶
-
static
random_digit
(minvalue, maxvalue)¶
-
static
random_email_invalid_domain
(length)¶
-
static
random_email_invalid_missing_email_char
(length)¶
-
static
random_valid_email
(length)¶
-
static
-
class
webframework.extension.util.common_utils.
TextGenerator2
¶ Class that contains methods for generating String values
-
random_alphabetical_string
(length)¶ Generates a random string using alphabetical characters.
Parameters: length – Length of string to generate Returns: A random alphabetical string
-
random_char_string
(length)¶ Generates a random string using ASCII characters 32-64.
Parameters: length – Length of string to generate Returns: A random string of special characters
-
random_email
(nameLength, hostLength)¶ Generates a random email
Parameters: - nameLength – Length of name part of the email
- hostLength – Length of host part of the email
Returns: Email as string
-
random_length_string
(defaultmaxlength=20)¶ Generates a random length string.
Parameters: defaultmaxlength – Length of string to generate Returns: A random string of special characters
-
random_number_string
(length)¶ Generates a random decimal string
Parameters: length – Length of string to generate Returns: A random string in range [0-9]
-
random_string
(fromChar, toChar, length)¶ Generates a random string in range of [fromChar-toChar]
Parameters: - fromChar – First character in range
- toChar – Last character in range
- length – Length of string to generate
Returns: A random string
-
-
class
webframework.extension.util.common_utils.
Timer
¶ Class allows to measure time
-
get_elapsed_time
()¶ Get elapsed time
Returns: Time difference between start and stop
-
start
()¶ Start timer
-
stop
()¶ Stop timer
-
-
class
webframework.extension.util.common_utils.
ValidationListsWrappers
¶ -
alpha
(minlength, maxlength)¶ Alphabetical valid text validation
Parameters: - minlength – input minimum valid length
- maxlength – input maximum valid length
Returns: values dict of scenarios
Scenario1 valid: alpha “asafS” Scenario2 valid: alpha with min length “AbC” Scenario3 valid: alpha with max_length “ASsaSAV” Scenario4 invalid: alpha with invalid min_length “bC” Scenario5 invalid: alpha with invalid max_length “CsSASsSA” Scenario6 invalid: digit number “33323” Scenario7 invalid: alphadigit “as23B” Scenario8 invalid: alphachar “a@sSs”
-
alpha_lower
(minlength, maxlength)¶ Alphabetical lower input validation
Parameters: - minlength – input minimum valid length
- maxlength – maximum valid length
Returns: values dict of scenarios
Scenario1 valid: alpha with lower “assss” Scenario2 valid: alpha with lower min_length “abc” Scenario3 valid: alpha with lower max_length “assasav” Scenario4 invalid: alpha with lower invalid min_length “bc” Scenario5 invalid: alpha with lower invalid max_length “clsasasa” Scenario6 invalid: alpha with upper “ASSSS” Scenario7 invalid: digit “33323” Scenario8 invalid: alphadigit with lower “as23a” Scenario9 invalid: alphadigit with upper “A3BSA” Scenario10 invalid: alphachar with lower “a@sbs” Scenario11 invalid: alphachar with upper “@BAFK”
-
alpha_upper
(minlength, maxlength)¶ Alphabetical upper input validation
Parameters: - minlength – input minimum valid length
- maxlength – input maximum valid length
Returns: values dict of scenarios
Scenario1 valid: alpha with upper “ASSSS” Scenario2 valid: alpha with upper min_length “ABC” Scenario3 valid: alpha with upper max_length “ASSASAV” Scenario4 invalid: alpha with upper invalid min_length “BC” Scenario5 invalid: alpha with upper invalid max_length “CLSASASA” Scenario6 invalid: alpha with lower “sasfs” Scenario7 invalid: digit “33323” Scenario8 invalid: alphadigit with lower “as23a” Scenario9 invalid: alphadigit with upper “A3BSA” Scenario10 invalid: alphachar with lower “a@sbs” Scenario11 invalid: alphachar with upper “@BAFK”
-
alphachar
(minlength, maxlength)¶ Alphabetical and specialcharacters input validation
Parameters: - minlength – input minimum valid length
- maxlength – input maximum valid length
Returns: values dict of scenarios
Scenario1 valid: alphachar “as@ss” Scenario2 valid: alphachar with min_length “a@B” Scenario3 valid: alphachar with max_length “asBs@aa” Scenario4 invalid: alphachar with invalid min_length “b@” Scenario5 invalid: alphachar with invalid max_length “sasasRg@” Scenario6 invalid: alphadigitchar “a@23B”
-
alphadigit
(minlength, maxlength)¶ Alphabetical and numbers input validation
Parameters: - minlength – input minimum valid length
- maxlength – input maximum valid length
Returns: values dict of scenarios
Scenario1 valid: alphadigit “as23B” Scenario2 valid: alphadigit with min_length “a2B” Scenario3 valid: alphadigit with max_length “as23Bsa” Scenario4 invalid: alphadigit with invalid min length “B1” Scenario5 invalid: alphadigit with invalid max_length “SASAsGE1” Scenario6 invalid: alphadigitchar a@s1s”
-
alphadigit_lower
(minlength, maxlength)¶ Alphabetical lower and numbers input validation
Parameters: - minlength – input minimum valid length
- maxlength – input maximum valid length
Returns: values dict of scenarios
Scenario1 valid: alphadigit with lower “as1ss” Scenario2 valid: alphadigit with lower min_length “b1c” Scenario3 valid: alphadigit with lower max_length “safsd1a” Scenario4 invalid: alphadigit with lower invalid min_length “b1” Scenario5 invalid: alphadigit with lower invalid max_length “sasasrg1” Scenario6 invalid: alphadigitchar with lower “a3@ab”
-
alphadigit_upper
(minlength, maxlength)¶ Alphabetical upper and numbers input validation
Parameters: - minlength – input minimum valid length
- maxlength – input maximum valid length
Returns: values dict of scenarios
Scenario1 valid: alphadigit with upper “A3BSA” Scenario2 valid: alphadigit with upper min_length “B1C” Scenario3 valid: alphadigit with upper max_length “SASA1GE” Scenario4 invalid: alphadigit with upper invalid min_length “B1” Scenario5 invalid: alphadigit with upper invalid max_length “SASASGE1” Scenario6 invalid: alphadigitchar with upper “A3B@A”
-
alphadigitchar
(minlength, maxlength)¶ Alphabetical, numbers and specialcharacters input validation
Parameters: - minlength – input minimum valid length
- maxlength – input maximum valid length
Returns: values dict of scenarios
Scenario1 valid: alphadigitchar “a1@ss” Scenario2 valid: alphadigitchar with min_length “1@B” Scenario3 valid: alphadigitchar with max_length “asBs@a1” Scenario4 invalid: alphadigitchar with invalid min_length “B@” Scenario5 invalid: alphadigitchar with invalid max_length “sasasRg@”
-
checkbox
()¶ Checkbox input validation is checked or unchecked)
Returns: values dict of scenarios Scenario1 valid: checked Scenario2 valid: unchecked
-
checkbox_checked
()¶ Checkbox input validation is checked
Returns: values dict of scenarios Scenario1 valid: checked Scenario2 invalid: unchecked
-
checkbox_unchecked
()¶ Checkbox input validation is unchecked
Returns: values dict of scenarios Scenario1 valid: unchecked Scenario2 invalid: checked
-
date_future_daymonthyear
()¶ Date in future format: day month year input validation
Returns: values dict of scenarios Scenario1 valid: future day.month.year Scenario2 invalid: future day.month.year Scenario3 invalid: future year.month.day Scenario4 invalid: invalid format
-
date_now_daymonthyear
()¶ Date now format: day month year input validation
Returns: values dict of scenarios Scenario1 valid: day.month.year “10.11.2016” Scenario2 invalid: past day.month.year Scenario3 invalid: now year.month.day Scenario4 invalid: invalid format
-
date_past_daymonthyear
()¶ Date in future format: day month year input validation
Returns: values dict of scenarios Scenario1 valid: past day.month.year Scenario2 invalid: future day.month.year Scenario3 invalid: past year.month.day Scenario4 invalid: invalid format
-
digit
(minvalue, maxvalue)¶ Digit numbers input validation
Parameters: - minvalue – minlength input minimum valid length
- maxvalue – maxlength input maximum valid length
Returns: values dict of scenarios
Scenario1 valid: inrange 5 Scenario2 valid: min 2 Scenario3 valid: max 10 Scenario4 invalid: invalid min 1 Scenario5 invalid: invalid max 11 Scenario6 invalid: invalid chars “j@”
-
email
(normal_length, maxlength)¶ Email input validation
Parameters: - normal_length – input minimum valid length
- maxlength – input maximum valid lengt
Returns: values dict of scenarios
Scenario1 valid: email Scenario2 invalid: domain Scenario3 invalid: invalid email char Scenario4 invalid: invalid max length
-
optional
()¶ Optional input validation
Returns: values dict of scenarios Scenario1 valid: empty
Radiobutton checked input validation
Returns: values dict of scenarios Scenario1 valid: checked
Radiobutton input validation
Returns: values dict of scenarios Scenario1 valid: unchecked
-
required
()¶ Required input validation
Returns: values dict of scenarios Scenario1 invalid: empty
-
tel
(minlength, maxlength)¶ Telephone input validation
Parameters: - minlength – input minimum valid length
- maxlength – input maximum valid length
Returns: values dict of scenarios
Scenario1 valid: number without country code Scenario2 valid: number with country code Scenario3 valid: min length number without country code Scenario4 valid: max length number without country code Scenario5 valid: min length number with country code Scenario6 valid: max length number with country code Scenario7 invalid: min length number with country code Scenario8 invalid: max length number with country code
-
-
class
webframework.extension.util.common_utils.
WebMethods
(driver_cache=None)¶ Class that contains methods for web
-
accept_alert
()¶ Accepts current alert window
Example: Page model level exampleself.accept_alert()
Test level exampleself.common_utils.accept_alert()
-
add_dynamic_content_to_parameters
(parameters, name, value, section=None)¶ Add dynamic content to parameters dictionary
dynamic content is available in current test run
Parameters: - parameters – Parameters dictionary
- name – Name for added parameter as string
- value – Value for added parameter as string
- section – Optional section where parameter is added as string
Example: Page model level exampleself.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value")
self.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value", "my_section")
Using dynamic valueself.add_dynamic_content_to_parameters(self.ELEMENT_NAME, parameters["param_name"])
Test level exampleself.common_utils.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value")
self.common_utils.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value", "my_section")
Using dynamic valueself.trial.login(TESTDATA["my_section"])
-
alert_is_present
()¶ Check if alert is present
Returns: Alert as webdriver element alert if alert not found returns false Example: Page model level exampleself.alert_is_present()
Test level exampleself.common_utils.alert_is_present()
-
alert_should_be_present
()¶ Check if alert is present
Returns: Alert as webdriver element alert if alert not found returns false Example: Page model level exampleself.alert_is_present()
Test level exampleself.common_utils.alert_is_present()
-
click_element
(element, to_print=True)¶ Click at element
Parameters: - element – Element representation (By, value) or WebElement
- to_print – Flag, if True prints action message
Example: Page model levelusing web elementself.click_element(self.TRIAL)
using representationself.click_element((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementself.common_utils.click_element(self.trial.TRIAL)
-
click_element_at_coordinates
(element, x, y, to_print=True)¶ Clicks at the specified coordinates at element
Parameters: - element – Element representation (By, value) or WebElement
- x – x-coordinate
- y – y-coordinate
- to_print – Flag, if True prints action message
Example: Page model levelusing web elementself.click_element_at_coordinates(self.TRIAL, 1, 1)
using representationself.click_element_at_coordinates((By.LINK_TEXT, u'Trial'), 1, 1)
Test levelusing web elementself.common_utils.click_element_at_coordinates(self.trial.TRIAL, 1, 1)
-
click_element_from_table_row
(element, row, element_path)¶ Click table cell by given row.
Parameters: - element – Table element representation (By, value) or WebElement object.
- row – Table row where is link or button to click
- element_path – Path to element which should be clicked
Example: Page model level exampleusing web elementself.click_table_cell_by_column_and_row(self.TABLE, 1, "TD/DIV/H4/A")
using representationself.click_table_cell_by_column_and_row((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), 1, "TD/DIV/H4/A")
Test level exampleusing web elementself.common_utils.click_table_cell_by_column_and_row(self.elements.TABLE, 1, "TD/DIV/H4/A")
-
click_table_cell_by_column_and_row
(element, column, row, cell='TD')¶ Click table cell by given column and row.
Parameters: - element – Table element representation (By, value) or WebElement object.
- column – Table column where to click
- row – Table row where to click
- cell – Xpath to element which should be clicked, default is ‘TD’
Example: Page model level exampleusing web elementself.click_table_cell_by_column_and_row(self.TABLE, 1, 1)
using representationself.click_table_cell_by_column_and_row((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), 1, 1)
Test level exampleusing web elementself.common_utils.click_table_cell_by_column_and_row(self.elements.TABLE, 1, 1)
-
close_all_browsers
()¶ Closes all opened browsers
Example: Page model level exampleself.close_all_browsers()
Test level exampleself.common_utils.close_all_browsers()
-
close_browser
()¶ Closes current active browser
Example: Page model level exampleself.close_browser()
Test level exampleself.common_utils.close_browser()
-
close_window
()¶ Close current window
Example: Page model level exampleself.close_window()
Test level exampleself.common_utils.close_window()
-
close_window_and_focus_to_previous
()¶ Close current window and focus to previous one
Example: Page model level exampleself.close_window_and_focus_to_previous()
Test level exampleself.common_utils.close_window_and_focus_to_previous()
-
compare_element_screenshots
(element, ref_scr_name)¶ Compares screenshots of elements
Parameters: - element – Element representation (By, value) or WebElement
- ref_scr_name – Screenshot name in string format
Example: Page model level example self.compare_element_screenshots(self.TRIAL,"ref_scr_name")
-
compare_screenshots
(ref_scr_name)¶ Compares screenshots or part of screenshots
Parameters: ref_scr_name – Screenshot name in string format Example: Page model level exampleself.compare_screenshots("ref_scr_name")
Test level exampleself.common_utils.compare_screenshots("ref_scr_name")
Deletes all cookies from current session
Example: Page model level exampleself.delete_all_cookies()
Test level exampleself.common_utils.delete_all_cookies()
-
dismiss_alert
()¶ Dismisses current alert window
Example: Page model level exampleself.dismiss_alert()
Test level exampleself.common_utils.dismiss_alert()
-
double_click_element
(element, to_print=True)¶ Double click at element
Parameters: - element – Element representation (By, value) or WebElement
- to_print – Flag, if True prints action message
Example: Page model level exampleusing web elementself.double_click_element(self.TRIAL)
using representationself.double_click_element((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementself.common_utils.double_click_element(self.trial.TRIAL)
-
drag_and_drop_by_offset
(element, xoffset, yoffset)¶ Drags draggable element onto x,y offset
Parameters: - element – Element to drag
- xoffset – Drag element from current position to xoffset
- yoffset – Drag element from current position to yoffset
Example: Page model level exampleusing web elementself.drag_and_drop_by_offset(self.ID_DRAG1, 0, 0)
using representationself.drag_and_drop_by_offset((By.CSS_SELECTOR, u'div>p'), 0, 0)
Test level exampleusing web elementself.common_utils.drag_and_drop_by_offset(self.elements.ID_DRAG1, 0, 0)
-
execute_async_javascript
(js_script, log=True)¶ Execute async JavaScript code
Parameters: - js_script – String represents JavaScript code
- log – Flag, if True prints action message
Returns: Object return by JavaScript code else None
-
execute_javascript
(js_script, log=True)¶ Execute JavaScript code
Parameters: - js_script – String represents JavaScript code
- log – Flag, if True prints action message
Returns: Object return by JavaScript code else None
Example: age model level examplevalue = self.execute_javascript("run_function(variable)")
Test level examplevalue = self.common_utils.execute_javascript("run_function(variable)")
-
fail
(message)¶ Message to print in report as a String
Parameters: message – Message to print as a string. Example: Page model level exampleself.fail("My message")
Test level exampleself.common_utils.fail("My message")
-
find_element
(element)¶ Return found WebElement
Parameters: element – Element representation (By, value) or WebElement Returns: WebElement Example: Page model levelelement = self.find_element((By.LINK_TEXT, u'Trial'))
-
find_elements
(element)¶ Return found list of WebElement’s
Parameters: element – Element representation (By, value) or WebElement Returns: List of WebElement’s Example: Page model levelall_elements = self.find_elements((By.CSS_SELECTOR, u"img"))
-
generate_zap_test_report
(installation_dir, session_name, report_name='qautomate_zap_report.html')¶ Generate zap test report html
Note
Zapproxy UI and python client must be installed
Parameters: - installation_dir – Zap installation dir
- session_name – Zap session name
- report_name – Zap report name
Example: Test level examplezap, zap_session = self.common_utils.start_zapproxy_daemon('C:\ZedAttackProxy\zap.bat')
self.common_utils.stop_zapproxy_daemon(zap)
self.oommon_utils.generate_zap_test_report('C:\ZedAttackProxy\zap.bat', zap_session)
or self.common_utils.generate_zap_test_report('C:\ZedAttackProxy\zap.bat', zap_session, "qautomate_zap.html")
-
get_attribute
(element, attr)¶ Return element’s attribute
Parameters: - element – Element representation (By, value) or WebElement
- attr – Attribute of an element
Returns: element’s attribute
Example: Page model level exampleusing web elementself.get_attribute(self.ID_DROPDOWN, "name")
using representationself.get_attribute((By.ID, u'dropdown'), "name")
Test level exampleusing web elementself.common_utils.get_attribute(self.elements.ID_DROPDOWN, "name")
-
get_dom_element_count
(log=True)¶ Counting DOM-elements
Returns: Returns number of DOM-elements on web page. Example: Page model level exampleself.get_dom_element_count()
Test level exampleself.common_utils.get_dom_element_count()
-
get_elements_count
(element)¶ Return number of found elements
Parameters: element – Element representation Returns: Number of found elements Example: Page model level exampleself.get_elements_count((By.CSS_SELECTOR, u"img"))
Test level exampleself.common_utils.get_elements_count((By.CSS_SELECTOR, u"img"))
-
get_js_memory_heap
(measurement_name)¶ Returns memory heap
Parameters: measurement_name – String represents name of measurement point Example: Page model level exampleself.get_js_memory_heap(measurement_name)
Test level exampleself.common_utils.get_js_memory_heap(measurement_name)
-
get_list_row_by_attribute_value
(element, attribute, value, row='LI', cell='')¶ Find list item row number by attribute value contains from UL list
Parameters: - element – List element representation (By, value) or WebElement object.
- attribute – Element’s attribute
- value – Element’s attribute value should contains
- row – Xpath to element where text should be default id ‘LI’
- cell – Xpath to element where text should be default id ‘’
Returns: element_row, value_row
Example: Page model level exampleusing web elementself.get_list_row_by_attribute_value(self.LIST, "name", "value_to_find")
element_rowlist = self.get_list_row_by_attribute_value(self.LIST, "name", parameters[u'member_id'], "LI","span")
element_rowlist[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_list_row_by_attribute_value((By.CSS_SELECTOR, u'#list'), "name", "value_to_find")
Test level exampleusing web elementself.common_utils.get_list_row_by_attribute_value(self.elements.LIST, "name", "value_to_find")
-
get_list_row_by_attribute_value_contains
(element, attribute, value, row='LI', cell='')¶ Find list item row number by attribute value contains from UL list
Parameters: - element – List element representation (By, value) or WebElement object.
- attribute – Element’s attribute
- value – Element’s attribute value should contains
- row – Xpath to element where text should be default id ‘LI’
- cell – Xpath to element where text should be default id ‘’
Returns: element_row, value_row
Example: Page model level exampleusing web elementself.get_list_row_by_attribute_value_contains(self.LIST, "name", "value_to_find","span")
element_rowlist = self.get_list_row_by_attribute_value_contains(self.LIST, "name", parameters[u'member_id'],"LI")
element_rowlist[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_list_row_by_attribute_value_contains((By.CSS_SELECTOR, u'#list'), "name", "value_to_find")
Test level exampleusing web elementself.common_utils.get_list_row_by_attribute_value_contains(self.elements.LIST, "name", "value_to_find")
-
get_list_row_by_text
(element, text, row='LI', cell='')¶ Find list item row number by text from UL list
Parameters: - element – List element representation (By, value) or WebElement object.
- text – Element’s text which should be
- row – Xpath to element where text should be default id ‘LI’
- cell – Xpath to element where text should be default id ‘’
Returns: element_row, text_row
Example: Page model level exampleusing web elementself.get_list_row_by_text(self.LIST, "text_to_find")
element_rowlist = self.get_list_row_by_text(self.LIST, parameters[u'member_id'],"LI")
element_rowlist[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_list_row_by_text((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "text_to_find")
Test level exampleusing web elementself.common_utils.get_list_row_by_text(self.elements.LIST, "text_to_find")
-
get_list_row_by_text_contains
(element, text, row='LI', cell='')¶ Find list item row number by contains text from UL list
Parameters: - element – List element representation (By, value) or WebElement object.
- text – Element’s text should contains
- row – Xpath to element where text should be default id ‘LI’
- cell – Xpath to element where text should be default id ‘’
Returns: element_row, text_row
Example: Page model level exampleusing web elementself.get_list_row_by_text_contains(self.LIST, "text_to_find")
element_rowlist = self.get_list_row_by_text_contains(self.ID_LIST, parameters[u'member_id'],"LI")
element_rowlist[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_list_row_by_text_contains((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "text_to_find")
Test level exampleusing web elementself.common_utils.get_list_row_by_text_contains(self.elements.LIST, "text_to_find")
-
get_list_row_by_value
(element, value, row='LI', cell='')¶ Find list item row number by value from UL list
Parameters: - element – List element representation (By, value) or WebElement object.
- value – Element’s value which should be
- row – Xpath to element where text should be default id ‘LI’
- cell – Xpath to element where text should be default id ‘’
Returns: element_row, value_row
Example: Page model level exampleusing web elementself.get_list_row_by_value(self.LIST, "value_to_find")
element_rowlist = self.get_list_row_by_value(self.LIST, parameters[u'member_id'],"LI")
element_rowlist[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_list_row_by_value((By.CSS_SELECTOR, u'#list'), "value_to_find")
Test level exampleusing web elementself.common_utils.get_list_row_by_value(self.elements.LIST, "value_to_find")
-
get_list_row_by_value_contains
(element, value, row='LI', cell='')¶ Find list item row number by value contains from UL list
Parameters: - element – List element representation (By, value) or WebElement object.
- value – Element’s value should contains
- row – Xpath to element where text should be default id ‘LI’
- cell – Xpath to element where text should be default id ‘’
Returns: element_row, value_row
Example: Page model level exampleusing web elementself.get_list_row_by_value_contains(self.LIST, "value_to_find")
element_rowlist = self.get_list_row_by_value_contains(self.LIST, parameters[u'member_id'],"LI","span")
element_rowlist[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_list_row_by_value_contains((By.CSS_SELECTOR, u'#list'), "value_to_find")
Test level exampleusing web elementself.common_utils.get_list_row_by_value_contains(self.elements.LIST, "value_to_find")
-
get_measurements
(measurement_name)¶ Return measurements
Parameters: measurement_name – String represents name of measurement point Returns: Measured time in specific point Example: Page model level exampleself.get_measurements("trial")
Test level exampleself.common_utils.get_measurements("trial")
-
get_resource_timings
(measurement_name)¶ Return resource timings
Parameters: measurement_name – String represents name of measurement point Returns: Measured time in specific resource Example: Page model level exampleself.get_resource_timings("trial")
Test level exampleself.common_utils.get_resource_timings("trial")
-
get_selected_list_label
(element)¶ Return selected option text from dropdown list
Parameters: element – Element representation (By, value) or WebElement Returns: String text of selected option Example: Page model level exampleusing web elementself.get_selected_list_label(self.ID_DROPDOWN)
using representationself.get_selected_list_label((By.ID, u'dropdown'))
Test level exampleusing web elementself.common_utils.get_selected_list_label(self.elements.ID_DROPDOWN)
-
get_selected_list_labels
(element)¶ Return texts of list dropdown options
Parameters: element – Element representation (By, value) or WebElement Returns: List strings, which represent dropdown options texts Example: Page model level exampleusing web elementtext_list = self.get_selected_list_labels(self.ID_DROPDOWN)
using representationtext_list = self.get_selected_list_labels((By.ID, u'dropdown'))
Test level exampleusing web elementtext_list = self.common_utils.get_selected_list_labels(self.elements.ID_DROPDOWN)
-
get_selected_list_value
(element)¶ Return selected option value from dropdown list
Parameters: element – Element representation (By, value) or WebElement Returns: String value of selected option Example: Page model level exampleusing web elementself.get_selected_list_value(self.ID_DROPDOWN)
using representationself.get_selected_list_value((By.ID, u'dropdown'))
Test level exampleusing web elementself.common_utils.get_selected_list_value(self.elements.ID_DROPDOWN)
-
get_selected_list_values
(element)¶ Return values of list dropdown options
Parameters: element – Element representation (By, value) or WebElement Returns: List strings, which represent dropdown options texts Example: Page model level exampleusing web elementtext_list = self.get_selected_list_values(self.ID_DROPDOWN)
using representationtext_list = self.get_selected_list_values((By.ID, u'dropdown'))
Test level exampleusing web elementtext_list = self.common_utils.get_selected_list_values(self.elements.ID_DROPDOWN)
-
get_soap_response
(url, request_file_xml)¶ Gets SOAP response from web service to be used in verify_soap_api
Parameters: - url – Web service url
- request_file_xml – Request xml file in ../data/soap/requests/
Example: Page model level examplevalue = self.get_soap_response(u'http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL', u'soap_xml.xml')
Test level examplevalue = self.common_utils.get_soap_response(u'http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL', u'soap_xml.xml')
-
get_table_cell_text_by_column_and_row
(element, column, row, cell='TD')¶ get table cell text by given column and row.
Parameters: - element – Table element representation (By, value) or WebElement object.
- column – Table column where to click
- row – Table row where to click
- cell – Xpath to element which should be clicked, default is ‘TD’
Returns: Xpath to element which should be clicked, default is ‘TD’
Example: Page model level exampleusing web elementself.get_table_cell_text_by_column_and_row(self.TABLE, 1, 1)
using representationself.get_table_cell_text_by_column_and_row((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), 1, 1)
Test level exampleusing web elementself.common_utils.get_table_cell_text_by_column_and_row(self.elements.TABLE, 1, 1)
-
get_table_column_and_row_by_attribute_value
(element, attribute, value, row='TBODY/TR', cell='TD')¶ Find table column and row number by attribute value
Parameters: - element – Table element representation (By, value) or WebElement object.
- attribute – Element’s attribute
- value – Element’s attribute value should contains
- row – Xpath to element where text should be default id ‘TBODY/TR’
- cell – Xpath to element where text should be default id ‘TD’
Returns: element_row, element_col, text_row, text_col
Example: Page model level exampleusing web elementself.get_table_column_and_row_by_attribute_value(self.TABLE, "name", "attribute_to_find")
element_rowtable = self.get_table_column_and_row_by_attribute_value(self.ID_TABLE, "name", parameters[u'member_id'],"TBODY/TR","TD/SPAN")
element_rowtable[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_table_column_and_row_by_attribute_value((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "name", "attribute_to_find")
Test level exampleusing web elementself.common_utils.get_table_column_and_row_by_attribute_value(self.elements.TABLE, "name", "attribute_to_find")
-
get_table_column_and_row_by_attribute_value_contains
(element, attribute, value, row='TBODY/TR', cell='TD')¶ Find table column and row number by attribute value contains
Parameters: - element – Table element representation (By, value) or WebElement object.
- attribute – Element’s attribute
- value – Element’s attribute value should contains
- row – Xpath to element where text should be default id ‘TBODY/TR’
- cell – Xpath to element where text should be default id ‘TD’
Returns: element_row, element_col, text_row, text_col
Example: Page model level exampleusing web elementself.get_table_column_and_row_by_attribute_value_contains(self.TABLE, "name", "attribute_to_find")
element_rowtable = self.get_table_column_and_row_by_attribute_value_contains(self.ID_TABLE, "name", parameters[u'member_id'],"TBODY/TR","TD/SPAN")
element_rowtable[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_table_column_and_row_by_attribute_value_contains((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "name", "attribute_to_find")
Test level exampleusing web elementself.common_utils.get_table_column_and_row_by_attribute_value_contains(self.elements.TABLE, "name", "attribute_to_find")
-
get_table_column_and_row_by_multiple_text
(element, text1, text2, row='TBODY/TR', cell='TD')¶ Find table column and row number by text
Parameters: - element – Table element representation (By, value) or WebElement object.
- text1 – Element’s text1 which should be (match text1 and text2)
- text2 – Element’s text2 which should be (match text1 and text2)
- row – Xpath to element where text should be default id ‘TBODY/TR’
- cell – Xpath to element where text should be default id ‘TD’
Returns: element1_row, element1_col, text1_row, text1_column, element2_row, element2_col, text2_row, text2_column
Example: Page model level exampleusing web elementself.get_table_column_and_row_by_multiple_text(self.TABLE, "text_to_find1", "text_to_find2")
element_rowtable = self.get_table_column_and_row_by_multiple_text(self.ID_TABLE, parameters[u'member_id'], parameters[u'group_id'],"TBODY/TR","TD/SPAN")
element_rowtable[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_table_column_and_row_by_multiple_text((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "text_to_find")
Test level exampleusing web elementself.common_utils.get_table_column_and_row_by_text(self.elements.TABLE, "text_to_find")
-
get_table_column_and_row_by_text
(element, text, row='TBODY/TR', cell='TD')¶ Find table column and row number by text
Parameters: - element – Table element representation (By, value) or WebElement object.
- text – Element’s text which should be
- row – Xpath to element where text should be default id ‘TBODY/TR’
- cell – Xpath to element where text should be default i:d ‘TD’
Returns: element_row, element_col, text_row, text_col
Example: Page model level exampleusing web elementself.get_table_column_and_row_by_text(self.TABLE, "text_to_find")
element_rowtable = self.get_table_column_and_row_by_text(self.ID_TABLE, parameters[u'member_id'],"TBODY/TR","TD/SPAN")
element_rowtable[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_table_column_and_row_by_text((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "text_to_find")
Test level exampleusing web elementself.common_utils.get_table_column_and_row_by_text(self.elements.TABLE, "text_to_find")
-
get_table_column_and_row_by_text_contains
(element, text, row='TBODY/TR', cell='TD')¶ Find table column and row number by contains text
Parameters: - element – Table element representation (By, value) or WebElement object.
- text – Element’s text should contains
- row – Xpath to element where text should be default id ‘TBODY/TR’
- cell – Xpath to element where text should be default id ‘TD’
Returns: element_row, element_col, text_row, text_col
Example: Page model level exampleusing web elementself.get_table_column_and_row_by_text_contains(self.TABLE, "text_to_find")
element_rowtable = self.get_table_column_and_row_by_text_contains(self.ID_TABLE, parameters[u'member_id'],"TBODY/TR","TD/SPAN")
element_rowtable[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_table_column_and_row_by_text_contains((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "text_to_find_contains")
Test level exampleusing web elementself.common_utils.get_table_column_and_row_by_text_contains(self.elements.TABLE, "text_to_find_contains")
-
get_table_column_and_row_by_value
(element, value, row='TBODY/TR', cell='TD')¶ Find table column and row number by value
Parameters: - element – Table element representation (By, value) or WebElement object.
- value – Element’s value which should be
- row – Xpath to element where text should be default id ‘TBODY/TR’
- cell – Xpath to element where text should be default id ‘TD’
Returns: element_row, element_col, text_row, text_col
Example: Page model level exampleusing web elementself.get_table_column_and_row_by_value(self.TABLE, "text_to_find")
element_rowtable = self.get_table_column_and_row_by_value(self.ID_TABLE, parameters[u'member_id'],"TBODY/TR","TD/SPAN")
element_rowtable[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_table_column_and_row_by_value((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "text_to_find")
Test level exampleusing web elementself.common_utils.get_table_column_and_row_by_value(self.elements.TABLE, "text_to_find")
-
get_table_column_and_row_by_value_contains
(element, value, row='TBODY/TR', cell='TD')¶ Find table column and row number by contains value
Parameters: - element – Table element representation (By, value) or WebElement object.
- value – Element’s value should contains
- row – Xpath to element where text should be default id ‘TBODY/TR’
- cell – Xpath to element where text should be default id ‘TD’
Returns: element_row, element_col, text_row, text_col
Example: Page model level exampleusing web elementself.get_table_column_and_row_by_value_contains(self.TABLE, "text_to_find")
element_rowtable = self.get_table_column_and_row_by_value_contains(self.ID_TABLE, parameters[u'member_id'],"TBODY/TR","TD/SPAN")
element_rowtable[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representationself.get_table_column_and_row_by_value_contains((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "text_to_find_contains")
Test level exampleusing web elementself.common_utils.get_table_column_and_row_by_value_contains(self.elements.TABLE, "text_to_find_contains")
-
get_table_size
(element)¶ Get table size
Parameters: element – Table element representation (By, value) or WebElement object. Returns: table_size, table_rows, table_columns Example: Page model level exampleusing web elementself.get_table_size(self.TABLE)
element_rowtable = self.get_table_size(self.ID_TABLE)
using representationself.get_table_size((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'))
Test level exampleusing web elementself.common_utils.get_table_size(self.elements.TABLE)
-
get_text
(element)¶ Return element’s text
Parameters: element – Element representation (By, value) or WebElement Returns: Text of element Example: Page model level exampleusing web elementvalue = self.get_text(self.TRIAL)
using representationvalue = self.get_text((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementvalue = self.common_utils.get_text(self.trial.TRIAL)
-
get_text_length
(element)¶ Return element text length. Spaces are also counted.
Parameters: element – Element representation (By, value) or WebElement Returns: WebElement text length as integer Example: Page model level exampleusing web elementvalue = self.get_text_length(self.TRIAL)
using representationvalue = self.get_text_length((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementvalue = self.common_utils.get_text_length(self.trial.TRIAL)
-
get_timestamp
()¶ Return timestamp
Format: ‘yyyyMMddhhmmss’ Returns: String which represents current time Example: Page model level examplevalue = self.get_timestamp()
Test level examplevalue = self.common_utils.get_timestamp()
-
get_value
(element)¶ Return element’s value
Parameters: element – Element representation (By, value) or WebElement Returns: Value of element Example: Page model level exampleusing web elementvalue = self.get_value(self.TRIAL)
using representationvalue = self.get_value((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementvalue = self.common_utils.get_value(self.trial.TRIAL)
-
get_web_response
(url, method, auth_file, data)¶ Return response from web service
Parameters: - url – Web service url
- method – Rest-api method. Get, post, put or delete.
- auth_file – Optional name of the auth_file. Blank if not needed.
- data – Optional data for request as string.
Returns: Web response from server
Example: Page model level examplevalue = self.get_web_response(u'http://api.openweathermap.org/data/2.5/weather?q=London&mode=xml', u'get', u'auth_file.txt', u'')
Test level examplevalue = self.common_utils.get_web_response(u'http://api.openweathermap.org/data/2.5/weather?q=London&mode=xml', u'get', u'auth_file.txt', u'')
-
get_window_size
()¶ Returns current window size width, height
Example: Page model level exampleself.get_window_size()
Test level exampleself.common_utils.get_window_size()
-
go_back
()¶ Simulates pressing Back button in browser window
Example: Page model level exampleself.go_back()
Test level exampleself.common_utils.go_back()
-
go_to
(url, log=True)¶ Open specified url
Parameters: - url – Url to open
- log – Flag, if True prints action message
Example: Page model level exampleself.go_to("http://qautomate.fi/")
Test level exampleself.common_utils.go_to("http://qautomate.fi/")
-
ignore_fail
(enable=True)¶
-
input_text
(element, value, to_print=True)¶ Clear and types text to input element
Parameters: - element – Element representation (By, value) or WebElement
- value – String to type in
- to_print – Flag, if True prints action message
Example: Page model levelusing web elementself.input_text(self.ID_CONTACT_FIRST_NAME, "this is value")
using representationself.input_text((By.ID, u'contact_first_name'), "this is value")
Test levelusing web elementself.common_utils.input_text(self.trial.ID_CONTACT_FIRST_NAME, "this is value")
-
is_disabled
(element, timeout=None)¶ Return disability of element.
Parameters: - element – Element representation (By, value) or WebElement.
- timeout – No timeout used, unless custom value provided.
Returns: True if element disabled, else - False.
Example: Page model level exampleusing web elementself.is_disabled(self.TRIAL)
using representationself.is_disabled((By.LINK_TEXT, u'Trial'))
using timeoutself.is_disabled(self.TRIAL, 10)
self.is_disabled((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.is_disabled(self.trial.TRIAL)
using timeoutself.common_utils.is_disabled(self.trial.TRIAL, 10)
-
is_enabled
(element, timeout=None)¶ Return enablity of element.
Parameters: - element – Element representation (By, value) or WebElement.
- timeout – No timeout used, unless custom value provided.
Returns: True if element enabled, else - False.
Example: Page model level exampleusing web elementself.is_enabled(self.TRIAL)
using representationself.is_enabled((By.LINK_TEXT, u'Trial'))
using timeoutself.is_enabled(self.TRIAL, 10)
self.is_enabled((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.is_enabled(self.trial.TRIAL)
using timeoutself.common_utils.is_enabled(self.trial.TRIAL, 10)
-
is_present
(element, timeout=None)¶ Return True if element presents in source code, else - False
Parameters: - element – Element representation (By, value).
- timeout – No timeout used, unless custom value provided.
Returns: True if element presents in source code, else - False.
Example: Page model level exampleusing web elementself.is_present(self.ID_TESTINPUT)
using representationself.is_present((By.ID, u'testInput'))
using timeoutself.is_present(self.ID_TESTINPUT, 10)
self.is_present(By.ID, u'testInput'), 10)
Test level exampleusing web elementself.common_utils.is_present(self.elements.ID_TESTINPUT)
using timeoutself.common_utils.is_present(self.elements.ID_TESTINPUT, 10)
-
is_visible
(element, timeout=None)¶ Return visibility of element.
Parameters: - element – Element representation (By, value) or WebElement.
- timeout – No timeout used, unless custom value provided.
Returns: visibility of element. True or False.
Example: Page model level exampleusing web elementself.is_visible(self.TRIAL)
using representationself.is_visible((By.LINK_TEXT, u'Trial'))
using timeoutself.is_visible(self.TRIAL, 10)
self.is_visible((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.is_visible(self.trial.TRIAL)
using timeoutself.common_utils.is_visible(self.trial.TRIAL, 10)
-
measure_async_screen_response_time
(measurement_name, timeout, reference_picture, element=None)¶ Return page loading time based on screenshot verification
Parameters: - measurement_name – String represents name of measure point
- timeout – Int represents how long (in seconds) to take screenshots
- reference_picture – String represents name of the reference picture
- element – Tuple represents element: (By, ‘value’)
Returns: return Time in seconds how long takes to find correct screenshot or if no match found return False
Example: Page model levelself.measure_async_screen_response_time("trial", 10, "trial_perf_pic")
Test levelself.common_utils.measure_async_screen_response_time("trial", 10, "trial_perf_pic")
-
mouse_down
(element)¶ Click and hold mouse left button at element. Element is pressed without releasing button
Parameters: element – Element representation (By, value) or WebElement object. Example: Page model level exampleusing web elementself.mouse_down(self.TRIAL)
using representationself.mouse_down((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementself.common_utils.mouse_down(self.trial.TRIAL)
-
mouse_over
(element)¶ Mouse overhover element
Parameters: element – Element representation (By, value) or WebElement object. Example: Page model level exampleusing web elementself.mouse_over(self.TRIAL)
using representationself.mouse_over((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementself.common_utils.mouse_over(self.trial.TRIAL)
-
mouse_over_by_offset
(element, xoffset, yoffset)¶ Mouse overhover element by offset
Parameters: - element – Element representation (By, value) or WebElement object.
- xoffset – X coordinate offset
- yoffset – coordinate offset
Example: Page model level exampleusing web elementself.mouse_over_by_offset(self.TRIAL, 0, 0)
using representationself.mouse_over_by_offset((By.LINK_TEXT, u'Trial'), 0, 0)
Test level exampleusing web elementself.common_utils.mouse_over_by_offset(self.trial.TRIAL, 0, 0)
-
mouse_right_click_by_offset
(element, xoffset, yoffset)¶ Mouse right click at element by offset
Parameters: - element – Element representation (By, value) or WebElement object.
- xoffset – X coordinate offset
- yoffset – Y coordinate offset
Example: Page model level exampleusing web elementself.mouse_right_click_by_offset(self.TRIAL, 0, 0)
using representationself.mouse_right_click_by_offset((By.LINK_TEXT, u'Trial'), 0, 0)
Test level exampleusing web elementself.common_utils.mouse_right_click_by_offset(self.trial.TRIAL, 0, 0)
-
mouse_up
(element)¶ Releases mouse left button at element. Element
Parameters: element – Element representation (By, value) or WebElement object. Example: Page model level exampleusing web elementself.mouse_up(self.TRIAL)
using representationself.mouse_up((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementself.common_utils.mouse_up(self.trial.TRIAL)
-
open_browser
(browser_name=None, url=None, alias=None, size=None)¶ Open specified browser with url
Parameters: - browser_name – Browser to open
- url – Url to open
- alias – save driver with alias
- size – Browser window size. Fullscreen if none.
Returns: id
Example: Page model level exampleself.open_browser("ff", http://qautomate.fi/")
Test level exampleself.common_utils.open_browser("ff", "http://qautomate.fi/")
Mouse right click at element opening context menu
Parameters: element – Element representation (By, value) or WebElement object. Example: Page model level exampleusing web elementself.open_context_menu(self.TRIAL)
using representationself.open_context_menu((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementself.common_utils.open_context_menu(self.trial.TRIAL)
-
open_url
(url, log=True)¶ Open specified url
Parameters: - url – Url to open
- log – Flag, if True prints action message
Example: Page model level exampleself.open_url("http://qautomate.fi/")
Test level exampleself.common_utils.open_url("http://qautomate.fi/")
-
reload_page
()¶ Refreshes page
Example: Page model level exampleself.refresh_page()
Test level exampleself.common_utils.refresh_page()
-
robot_script_runner
(robot_script)¶ Runs robot framework scripts
Parameters: robot_script – Robot framework script Example: Page model levelself.robot_script_runner("C:\Users\username\Documents\script.robot")
Test level exampleself.common_utils.robot_script_runner("C:\Users\username\Documents\script.robot")
-
select_checkbox
(element, status='checked')¶ Checks the checkbox
Parameters: - element – checkbox element
- status – final state of the checkbox “checked” or “unchecked”
Example: Page model level exampleusing web elementself.select_checkbox(self.ID_CHECKBOX1)
self.select_checkbox(self.ID_CHECKBOX1, "unchecked")
using representationself.select_checkbox((By.ID, u'checkbox1'))
self.select_checkbox((By.ID, u'checkbox1'), "unchecked")
Test level exampleusing web elementself.common_utils.select_checkbox(self.elements.ID_CHECKBOX1)
-
select_frame
(element)¶ Switch focus to frame
Parameters: element – Element representation (By, value), WebElement or frame name. Example: Page model level exampleusing web elementself.select_frame(self.IFRAME)
using representationself.select_frame((By.CSS_SELECTOR, u'iframe'))
Test level exampleusing web elementself.common_utils.select_frame(self.home.IFRAME)
-
select_frame_default_content
()¶ Switch focus to default content
Example: Page model level exampleself.select_frame_default_content()
Test level exampleself.common_utils.select_frame_default_content()
-
select_from_list_by_label
(element, text)¶ Select option from dropdown list by text
Parameters: - element – Element representation (By, value) or WebElement
- text – Dropdown option visible text
Example: Page model level exampleusing web elementself.select_from_list_by_label(self.ID_DROPDOWN, "value")
using representationself.select_from_list_by_label((By.ID, u'dropdown'), "value")
Test level exampleusing web elementself.common_utils.select_from_list_by_label(self.elements.ID_DROPDOWN, "value")
-
select_from_list_by_random_option
(element, *val_to_skip)¶ Select random option from dropdown list
Parameters: - element – Element representation (By, value) or WebElement
- val_to_skip – Values to skip
Example: Page model level exampleusing web elementself.select_from_list_by_random_option(self.ID_DROPDOWN)
using representationself.select_from_list_by_random_option((By.ID, u'dropdown'))
Test level exampleusing web elementself.common_utils.select_from_list_by_random_option(self.elements.ID_DROPDOWN)
-
select_from_list_by_value
(element, value)¶ Select option from dropdown list by value
Parameters: - element – Element representation (By, value) or WebElement
- value – Dropdown option value
Example: Page model level exampleusing web elementself.select_from_list_by_value(self.ID_DROPDOWN, 10)
using representationself.select_from_list_by_value((By.ID, u'dropdown'), 10)
Test level exampleusing web elementself.common_utils.select_from_list_by_value(self.elements.ID_DROPDOWN, 10)
-
send_keys
(element, value, to_print=True)¶ Type value to element
Parameters: - element – Element representation (By, value) or WebElement
- value – Value to type in to the element
- to_print – Flag, if True prints action message
Example: Page model levelusing web elementself.send_keys(self.ID_CONTACT_FIRST_NAME, "this is value")
using representationself.send_keys((By.ID, u'contact_first_name'), "this is value")
Test levelusing web elementself.common_utils.send_keys(self.trial.ID_CONTACT_FIRST_NAME, "this is value")
-
set_window_size
(width, height)¶ Set current window size width, height
Parameters: - width – window width
- height – window height
Example: Page model level exampleself.set_window_size(800, 600)
Test level exampleself.common_utils.set_window_size(800, 600)
-
start_zapproxy_daemon
(installation_dir)¶ Start Zap proxy daemon
Note
Zapproxy UI and python client must be installed
Parameters: installation_dir – Zapproxy installation folder Returns: Zap daemon object, zap session name Example: Page model level examplezap, zap_session = self.start_zapproxy_daemon('C:\ZedAttackProxy\zap.bat')
Test level examplezap, zap_session = self.common_utils.start_zapproxy_daemon('C:\ZedAttackProxy\zap.bat')
-
stop_zapproxy_daemon
(zap)¶ Stop Zap proxy daemon
Note
Zapproxy UI and python client must be installed
Parameters: zap – Zap proxy object Example: Test level examplezap, zap_session = self.common_utils.start_zapproxy_daemon('C:\ZedAttackProxy\zap.bat')
self.common_utils.stop_zapproxy_daemon(zap)
-
switch_browser
(id_or_alias)¶ Switch between active browsers using id or alias
Parameters: id_or_alias – Identify new active browser Example: Page model level example with idid = self.open_browser("ff", "http://qautomate.fi/")
id2 = self.open_browser("ff", "http://qautomate.fi/")
run some stepsself.switch_browser(id)
Test level example with aliasself.common_utils.open_browser("ff", "http://qautomate.fi/", "alias1")
self.common_utils.open_browser("ff", "http://qautomate.fi/", "alias2")
run some stepsself.common_utils.switch_browser("alias1")
-
table_contains_text
(element, value)¶ Checks if table contains text
Parameters: - element – Table element representation (By, value) or WebElement object.
- value – String
Returns: Boolean value
Example: using web elementself.table_contains_text(self.TABLE, u'in_table')
using representationself.table_contains_text((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'in_table')
Test level exampleusing web elementself.common_utils.table_contains_text(self.elements.TABLE, u'in_table')
-
triple_click_element
(element, to_print=True)¶ Triple click at element
Parameters: - element – Element representation (By, value) or WebElement
- to_print – Flag, if True prints action message
Example: Page model level exampleusing web elementself.triple_click_element(self.TRIAL)
using representationself.triple_click_element((By.LINK_TEXT, u'Trial'))
Test level exampleusing web elementself.common_utils.triple_click_element(self.trial.TRIAL)
-
unselect_checkbox
(element, status='unchecked')¶ Unchecks the checkbox
Parameters: - element – checkbox element
- status – final state of the checkbox “checked” or “unchecked”
Example: Page model level exampleusing web elementself.unselect_checkbox(self.ID_CHECKBOX1)
using representationself.unselect_checkbox((By.ID, u'checkbox1'))
Test level exampleusing web elementself.common_utils.unselect_checkbox(self.elements.ID_CHECKBOX1)
-
wait_for_condition
(js_script, value, msg=None)¶ Wait for condition JavaScript returns value
Parameters: - js_script – Executable JavaScript
- value – Expected value which should be returned by JavaScript
- msg – Message
Example: wait_for_condition("document.title", "javascript - hide index.html in the URL - Stack Overflow")
-
wait_until_document_ready
()¶ Wait until browser finish loading webpage
Execute JS to check readyState of DOM page object.
Example: Page model level exampleself.wait_until_document_ready()
Test level exampleself.common_utils.wait_until_document_ready()
-
wait_until_element_attribute_contains
(element, attr, expected_value, timeout=None)¶ Wait until element’s attribute contains value
Parameters: - element – Element representation (By, value) or WebElement.
- attr – Element’s attribute
- expected_value – Element’s attribute value which should be
- timeout – Uses default timeout, unless custom value provided.
Example: Page model level exampleusing web elementself.wait_until_element_attribute_contains(self.ID_DROPDOWN, "name", "dropdown")
using representationself.wait_until_element_attribute_contains((By.ID, u'dropdown'), "name", "dropdown")
using timeoutself.wait_until_element_attribute_contains(self.ID_DROPDOWN, "name", "dropdown", 10)
self.wait_until_element_attribute_contains((By.ID, u'dropdown'), "name", "dropdown", 10)
Test level exampleusing web elementself.common_utils.wait_until_element_attribute_contains(self.elements.ID_DROPDOWN, "name" "dropdown")
using timeoutself.common_utils.wait_until_element_attribute_contains(self.elements.ID_DROPDOWN, "name" "dropdown", 10)
-
wait_until_element_contains
(element, text, timeout=None)¶ Wait until element’s contains text
Parameters: - element – Element representation (By, value) or WebElement.
- text – Element’s text which should be
- timeout – Uses default timeout, unless custom value provided.
Example: Page model level exampleusing web elementself.common_utils.wait_until_element_contains(self.elements.TEST, u'Cell text is this')
self.wait_until_element_contains((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text is this'1', 10)
Test level exampleusing web elementself.common_utils.wait_until_element_contains(self.elements.TEST, u'Cell text is this')
using timeoutself.common_utils.wait_until_element_contains(self.elements.TEST, u'Cell text is this', 10)
-
wait_until_element_does_not_contain
(element, text, timeout=None)¶ Wait until element’s does not contains text
Parameters: - element – Element representation (By, value) or WebElement.
- text – Element’s text which should not be
- timeout – Uses default timeout, unless custom value provided.
Example: Page model level exampleusing web elementself.wait_until_element_does_not_contain(self.TEST, u'Cell text changed')
using representationself.wait_until_element_does_not_contain((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text changed')
using timeoutself.wait_until_element_does_not_contain(self.TEST, u'Cell text changed', 10)
self.wait_until_element_does_not_contain((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text changed', 10)
Test level exampleusing web elementself.common_utils.wait_until_element_does_not_contain(self.elements.TEST, u'Cell text changed')
using timeoutself.common_utils.wait_until_element_does_not_contain(self.elements.TEST, u'Cell text changed', 10)
-
wait_until_element_is_disabled
(element, timeout=None, msg=None)¶ Wait until element is disabled.
Parameters: - element – Element representation (By, value) or WebElement object.
- timeout – Uses default timeout, unless custom value provided.
- msg – Message if element is not disabled
Exception: If time exceeds DEFAULT_TIMEOUT, then rise exception.
Example: Page model level exampleusing web elementself.wait_until_element_is_disabled(self.TRIAL)
using representationself.common_utils.wait_until_element_is_disabled((By.LINK_TEXT, u'Trial'))
using timeoutself.wait_until_element_is_disabled(self.TRIAL, 10)
self.wait_until_element_is_disabled((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.wait_until_element_is_disabled(self.trial.TRIAL)
using timeoutself.common_utils.wait_until_element_is_disabled(self.trial.TRIAL, 10)
-
wait_until_element_is_enabled
(element, timeout=None, msg=None)¶ Wait until element is enabled.
Parameters: - element – Element representation (By, value) or WebElement object.
- timeout – Uses default timeout, unless custom value provided.
- msg – Message if element is not enabled.
Exception: If time exceeds DEFAULT_TIMEOUT, then rise exception.
Example: Page model level exampleusing web elementself.wait_until_element_is_enabled(self.TRIAL)
using representationself.common_utils.wait_until_element_is_enabled((By.LINK_TEXT, u'Trial'))
using timeoutself.wait_until_element_is_enabled(self.TRIAL, 10)
self.wait_until_element_is_enabled((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.wait_until_element_is_enabled(self.trial.TRIAL)
using timeoutself.common_utils.wait_until_element_is_enabled(self.trial.TRIAL, 10)
-
wait_until_element_is_not_present
(element, timeout=None)¶ Wait for element is not present in source code.
Raises: Exception – if time exceeds DEFAULT_TIMEOUT, then rise exception.
Parameters: - element – Element representation (By, value).
- timeout – Uses default timeout, unless custom value provided.
Example: Page model level exampleusing web elementself.wait_until_element_is_not_present(self.ID_TESTINPUT)
using representationself.wait_until_element_is_not_present((By.ID, u'testInput'))
using timeoutself.wait_until_element_is_not_present(self.ID_TESTINPUT, 10)
self.wait_until_element_is_not_present((By.ID, u'testInput'), 10)
Test level exampleusing web elementself.common_utils.wait_until_element_is_not_present(self.elements.ID_TESTINPUT)
using timeoutself.common_utils.wait_until_element_is_not_present(self.elements.ID_TESTINPUT, 10)
-
wait_until_element_is_not_visible
(element, timeout=None, msg=None)¶ Wait until element specified is not visible
Parameters: - element – Element representation (By, value) or WebElement object.
- timeout – Uses default timeout, unless custom value provided.
- msg – Message if element is visible
Exception: If time exceeds DEFAULT_TIMEOUT, then rise exception.
Example: Page model level exampleusing web elementself.wait_until_element_is_not_visible(self.TRIAL)
using representationself.common_utils.wait_until_element_is_not_visible((By.LINK_TEXT, u'Trial'))
using timeoutself.wait_until_element_is_not_visible(self.TRIAL, 10)
self.wait_until_element_is_not_visible((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.wait_until_element_is_not_visible(self.trial.TRIAL)
using timeoutself.common_utils.wait_until_element_is_not_visible(self.trial.TRIAL, 10)
-
wait_until_element_is_present
(element, timeout=None)¶ Wait for element is present in source code.
Raises: Exception – if time exceeds DEFAULT_TIMEOUT, then rise exception.
Parameters: - element – Element representation (By, value).
- timeout – Uses default timeout, unless custom value provided.
Example: Page model level exampleusing web elementself.wait_until_element_is_present(self.ID_TESTINPUT)
using representationself.wait_until_element_is_present((By.ID, u'testInput'))
using timeoutself.wait_until_element_is_present(self.ID_TESTINPUT, 10)
self.wait_until_element_is_present((By.ID, u'testInput'), 10)
Test level exampleusing web elementself.common_utils.wait_until_element_is_present(self.elements.ID_TESTINPUT)
using timeoutself.common_utils.wait_until_element_is_present(self.elements.ID_TESTINPUT, 10)
-
wait_until_element_is_visible
(element, timeout=None, msg=None)¶ Wait until element specified is visible
Parameters: - element – Element representation (By, value) or WebElement object.
- timeout – Uses default timeout, unless custom value provided.
- msg – Message if element is not visible
Exception: If time exceeds DEFAULT_TIMEOUT, then rise exception.
Example: Page model level exampleusing web elementself.wait_until_element_is_visible(self.TRIAL)
using representationself.common_utils.wait_until_element_is_visible((By.LINK_TEXT, u'Trial'))
using timeoutself.wait_until_element_is_visible(self.TRIAL, 10)
self.wait_until_element_is_visible((By.LINK_TEXT, u'Trial'), 10)
Test level exampleusing web elementself.common_utils.wait_until_element_is_visible(self.trial.TRIAL)
using timeoutself.common_utils.wait_until_element_is_visible(self.trial.TRIAL, 10)
-
wait_until_element_should_be
(element, text, timeout=None)¶ Wait until element’s text is equal
Parameters: - element – Element representation (By, value) or WebElement.
- text – Element’s text which should be
- timeout – Uses default timeout, unless custom value provided.
Example: Page model level exampleusing web elementself.wait_until_element_should_be(self.TEST, u'Cell text is this')
using representationself.wait_until_element_should_be((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text is this')
using timeoutself.wait_until_element_should_be(self.TEST, u'Cell text is this', 10)
self.wait_until_element_should_be((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text is this'1', 10)
Test level exampleusing web elementself.common_utils.wait_until_element_should_be(self.elements.TEST, u'Cell text is this')
using timeoutself.common_utils.wait_until_element_should_be(self.elements.TEST, u'Cell text is this', 10)
-
wait_until_element_should_not_be
(element, text, timeout=None)¶ Wait until element’s text is not equal
Parameters: - element – Element representation (By, value) or WebElement.
- text – Element’s text which should not be
- timeout – Uses default timeout, unless custom value provided.
Example: Page model level exampleusing web elementself.wait_until_element_should_not_be(self.TEST, u'Cell text changed')
using representationself.wait_until_element_should_not_be((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text changed')
using timeoutself.wait_until_element_should_not_be(self.TEST, u'Cell text changed', 10)
self.wait_until_element_should_not_be((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text changed', 10)
Test level exampleusing web elementself.common_utils.wait_until_element_should_not_be(self.elements.TEST, u'Cell text changed')
using timeoutself.common_utils.wait_until_element_should_not_be(self.elements.TEST, u'Cell text changed', 10)
-
wait_until_jquery_ajax_loaded
(timeout=None)¶ Wait until browser is finished loading jQuery
Execute JS to check is jQuery active.
Parameters: timeout – Uses default timeout, unless custom value provided. Example: Page model level exampleself.wait_until_jquery_ajax_loaded()
Test level exampleself.common_utils.wait_until_jquery_ajax_loaded()
-
wait_until_page_contains
(text, timeout=None)¶ Wait until page’s contains text
Parameters: - text – Element’s text which should be
- timeout – Uses default timeout, unless custom value provided.
Example: Page model level exampleusing web elementself.wait_until_page_contains(u'Cell text is this')
using representationself.wait_until_page_contains((u'Cell text is this')
using timeoutself.wait_until_page_contains(u'Cell text is this', 10)
self.wait_until_page_contains(u'Cell text is this', 10)
Test level exampleusing web elementself.common_utils.wait_until_page_contains(u'Cell text is this')
using timeoutself.common_utils.wait_until_page_contains(u'Cell text is this', 10)
-
wait_until_page_does_not_contain
(text, timeout=None)¶ Wait until page’s does not contain text
Parameters: - text – Element’s text which should be
- timeout – Uses default timeout, unless custom value provided.
Example: Page model level exampleusing web elementself.wait_until_page_contain(u'Cell text is this')
using representationself.wait_until_page_contain((u'Cell text is this')
using timeoutself.wait_until_page_contain(u'Cell text is this', 10)
self.wait_until_page_contain(u'Cell text is this', 10)
Test level exampleusing web elementself.common_utils.wait_until_page_contain(u'Cell text is this')
using timeoutself.common_utils.wait_until_page_contain(u'Cell text is this', 10)
-
wait_until_table_size_changes
(element, timeout=None, msg=None)¶ Wait until table size changes
Raises: Exception – if time exceeds DEFAULT_TIMEOUT, then rise exception.
Parameters: - element – Element representation (By, value) or WebElement object.
- timeout – Uses default timeout, unless custom value provided.
- msg – Message
Example: Page model level exampleusing web elementself.wait_until_table_size_changes(self.ID_TABLETEST)
using representationself.wait_until_table_size_changes((By.ID, u'tableTest'))
using timeoutself.wait_until_table_size_changes(self.ID_TABLETEST, 10)
self.wait_until_table_size_changes((By.ID, u'tableTest'), 10)
Test level exampleusing web elementself.common_utils.wait_until_table_size_changes(self.demo.tableTest)
using timeoutself.common_utils.wait_until_table_size_changes(self.demo.tableTest, 10)
-
warning
(message)¶ Adds warning to test report
Parameters: message – Message to print as a String Example: Page model level exampleself.warning("My message")
Test level exampleself.common_utils.warning("My message")
-
-
class
webframework.extension.util.common_utils.
Wrappers
(driver_cache=None)¶ -
click_element
(element)¶
-
click_element_at_coordinates
(x, y)¶
-
compare_element_screenshots
(element, parameters)¶
-
compare_screenshots
(parameters)¶
-
element_should_be
(element, parameters)¶
-
element_value_should_be
(element, parameters)¶
-
fail
(message)¶
-
get_js_memory_heap
(measurement_name)¶
-
get_measurements
(parameters)¶
-
get_resource_timings
(measurement_name)¶
-
go_to
(parameters)¶
-
input_text
(element, parameters)¶
-
select_frame
(element)¶
-
select_frame_default_content
()¶
-
select_from_list_by_label
(element, parameters)¶
-
select_from_list_by_value
(element, parameters)¶
-
send_keys
(element, parameters)¶
-
wait_until_document_ready
()¶
-
wait_until_element_is_visible
(element)¶
-
wait_until_jquery_ajax_loaded
(timeout=None)¶
-
-
webframework.extension.util.common_utils.
for_all_methods
(decorator)¶
-
webframework.extension.util.common_utils.
my_decorator
(f)¶