QAutoLibrary keyword library

# QAutomate Ltd 2020. All rights reserved. # # Copyright and all other rights including without limitation all intellectual property rights and title in or # pertaining to this material, all information contained herein, related documentation and their modifications and # new versions and other amendments (QAutomate Material) vest in QAutomate Ltd or its licensor’s. # Any reproduction, transfer, distribution or storage or any other use or disclosure of QAutomate Material or part # thereof without the express prior written consent of QAutomate Ltd is strictly prohibited. # # Distributed with QAutomate license. # All rights reserved, see LICENSE for details.

class QAutoLibrary.QAutoSelenium.Asserts(driver_cache=None)

Class that contains methods for making verifications

checkbox_should_be_selected(element)

Check checkbox is selected.

Parameters

element – Checkbox element

Example
QAutoRobot.checkbox_should_be_selected(self.CLASS_CHECKBOX)
checkbox_should_not_be_selected(element)

Check radiobutton is not selected.

Parameters

element – Radiobutton element

Example
QAutoRobot.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
QAutoRobot.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
QAutoRobot.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
QAutoRobot.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
QAutoRobot.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
QAutoRobot.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
QAutoRobot.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
QAutoRobot.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
QAutoRobot.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
QAutoRobot.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.lat

Parameters
  • 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'
QAutoRobot.verify_rest_api_json_value(url, u'get', u'expected.txt', u'', u'')

QAutoRobot.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'
QAutoRobot.verify_rest_api_xml_value(url, u'get', u'expected.txt', u'', u'')

QAutoRobot.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
QAutoRobot.verify_soap_api(u'http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL', u'soap_xml.xml', response_file.txt)
class QAutoLibrary.QAutoSelenium.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

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 QAutoLibrary.QAutoSelenium.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 QAutoLibrary.QAutoSelenium.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 example
QAutoRobot.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value")
QAutoRobot.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value", "my_section")
Using dynamic value
QAutoRobot.add_dynamic_content_to_parameters(self.ELEMENT_NAME, parameters["param_name"])
click_checkbox_with_javascript(element)
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 level
using web element
QAutoRobot.click_element(self.TRIAL)
using representation
QAutoRobot.click_element((By.LINK_TEXT, u'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 level
using web element
QAutoRobot.click_element_at_coordinates(self.TRIAL, 1, 1)
using representation
QAutoRobot.click_element_at_coordinates((By.LINK_TEXT, u'Trial'), 1, 1)
close_all_browsers()

Closes all opened browsers

Example
Page model level example
QAutoRobot.close_all_browsers()
close_browser()

Closes current active browser

Example
Page model level example
QAutoRobot.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 QAutoRobot.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 example
QAutoRobot.compare_screenshots("ref_scr_name")
decrypt(encrypted)

Decrypts encrypted string back to plain text.

Parameters

encrypted – Encrypted string that needs to decrypt

Returns

decrypted string

Example
Page model level
QAutoRobot.decrypt("encrypted-key-string")
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 example
using web element
QAutoRobot.double_click_element(self.TRIAL)
using representation
QAutoRobot.double_click_element((By.LINK_TEXT, u'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 example
value = QAutoRobot.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 example
QAutoRobot.fail("My message")
fallback_element(element, action, value='')
find_element(element)

Return found WebElement

Parameters

element – Element representation (By, value) or WebElement

Returns

WebElement

Example
Page model level
element = QAutoRobot.find_element((By.LINK_TEXT, u'Trial'))
find_element_if_not_webelement(element)

Find element if its not selenium web element

Parameters

element – element to find

Returns

Web element

find_element_with_coordinates(x, y)

Finds web element with coordinates

Parameters
  • x – x position

  • y – y position

Returns

Web element

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 level
all_elements = QAutoRobot.find_elements((By.CSS_SELECTOR, u"img"))
find_last_searched_element_details(element=None)

Find element with last searched elements information

Returns

Element details or none

generate_zap_test_report(installation_dir, session_name, report_name='qautorobot_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
Pagemodel level example

QAutoRobot.generate_zap_test_report('C:\ZedAttackProxy\zap.bat', zap_session)
or QAutoRobot.generate_zap_test_report('C:\ZedAttackProxy\zap.bat', zap_session, "qautorobot_zap.html")
get_browser_console_log()

Return browser console log

Returns

console log

Example
Page model level example
value = QAutoRobot.get_browser_console_log()
get_current_window_handle()
get_dom_element_count(log=True)

Counting DOM-elements

Returns

Returns number of DOM-elements on web page.

Example
Page model level example
QAutoRobot.get_dom_element_count()
get_download_time(downloads_folder='', max_download_time=120)

Return file download time in Chrome

Parameters
  • downloads_folder – Chrome download folder

  • max_download_time – Max timeout to download

Returns

time

Example
Page model level example
value = QAutoRobot.get_download_time()
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 example
QAutoRobot.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 example
QAutoRobot.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 example
value = QAutoRobot.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 example
using web element
value = QAutoRobot.get_text(self.TRIAL)
using representation
value = QAutoRobot.get_text((By.LINK_TEXT, u'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 example
using web element
value = QAutoRobot.get_text_length(self.TRIAL)
using representation
value = QAutoRobot.get_text_length((By.LINK_TEXT, u'Trial'))
classmethod get_timestamp()

Return timestamp

Format

‘yyyyMMddhhmmss’

Returns

String which represents current time

Example
Page model level example
value = QAutoRobot.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 example
using web element
value = QAutoRobot.get_value(self.TRIAL)
using representation
value = QAutoRobot.get_value((By.LINK_TEXT, u'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 example
value = QAutoRobot.get_web_response(u'http://api.openweathermap.org/data/2.5/weather?q=London&mode=xml', u'get', u'auth_file.txt', u'')
get_xpath(element)
go_to(url, log=True)

Open specified url

Parameters
  • url – Url to open

  • log – Flag, if True prints action message

Example
Page model level example
QAutoRobot.go_to("http://qautomate.fi/")
input_text(element, value, to_print=True, encrypt=False)

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 level
using web element
QAutoRobot.input_text(self.ID_CONTACT_FIRST_NAME, "this is value")
using representation
QAutoRobot.input_text((By.ID, u'contact_first_name'), "this is value")
input_text_element_at_coordinates(element, x, y, text, 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 level
using web element
self.input_text_element_at_coordinates(self.TRIAL, 1, 1)
using representation
self.input_text_element_at_coordinates((By.LINK_TEXT, u'Trial'), 1, 1)

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 example
using web element
QAutoRobot.is_disabled(self.TRIAL)
using representation
QAutoRobot.is_disabled((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.is_disabled(self.TRIAL, 10)
QAutoRobot.is_disabled((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.is_enabled(self.TRIAL)
using representation
QAutoRobot.is_enabled((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.is_enabled(self.TRIAL, 10)
QAutoRobot.is_enabled((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.is_visible(self.TRIAL)
using representation
QAutoRobot.is_visible((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.is_visible(self.TRIAL, 10)
QAutoRobot.is_visible((By.LINK_TEXT, u'Trial'), 10)
last_element_details(fallback=False, action='')
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 level
QAutoRobot.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 example
QAutoRobot.open_browser("ff", http://qautomate.fi/")
open_remote_chrome_driver(port=9321)

Creates a driver to a remote debugging chrome instance

Parameters

port – Port specified when Chrome instance was created.

open_url(url, log=True)

Open specified url

Parameters
  • url – Url to open

  • log – Flag, if True prints action message

Example
Page model level example
QAutoRobot.open_url("http://qautomate.fi/")
send_email(smtp_username, smtp_password, receiver, mail_subject, mail_content)

Send mail from qautomate support to receiver

Parameters
  • smtp_username – Email server user

  • smtp_password – Email server user password

  • receiver – Email address of the receiver

  • mail_subject – Subject of the email

  • mail_content – Content part of the email

Example

Page model level example QAutoRobot.send_email(email_client, email_secret, "employee@company.com", "Test_Subject", "This is a test message")

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 level
using web element
QAutoRobot.send_keys(self.ID_CONTACT_FIRST_NAME, "this is value")
using representation
QAutoRobot.send_keys((By.ID, u'contact_first_name'), "this is value")
set_speed(timeout)

Set selenium speed

Parameters

timeout – timeout in seconds

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 example
zap, zap_session = QAutoRobot.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
Pagemodel level example
zap, zap_session = QAutoRobot.start_zapproxy_daemon('C:\ZedAttackProxy\zap.bat')
QAutoRobot.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 id
id = QAutoRobot.open_browser("ff", "http://qautomate.fi/")
id2 = QAutoRobot.open_browser("ff", "http://qautomate.fi/")
run some steps
QAutoRobot.switch_browser(id)
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 example
using web element
QAutoRobot.triple_click_element(self.TRIAL)
using representation
QAutoRobot.triple_click_element((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.wait_until_element_is_disabled(self.TRIAL)
using representation
QAutoRobot.common_utils.wait_until_element_is_disabled((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.wait_until_element_is_disabled(self.TRIAL, 10)
QAutoRobot.wait_until_element_is_disabled((By.LINK_TEXT, u'Trial'), 10)
wait_until_element_is_enabled(element, timeout=None, msg=None, fallback=False)

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 example
using web element
QAutoRobot.wait_until_element_is_enabled(self.TRIAL)
using representation
QAutoRobot.common_utils.wait_until_element_is_enabled((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.wait_until_element_is_enabled(self.TRIAL, 10)
QAutoRobot.wait_until_element_is_enabled((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.wait_until_element_is_not_visible(self.TRIAL)
using representation
QAutoRobot.common_utils.wait_until_element_is_not_visible((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.wait_until_element_is_not_visible(self.TRIAL, 10)
QAutoRobot.wait_until_element_is_not_visible((By.LINK_TEXT, u'Trial'), 10)
wait_until_element_is_visible(element, timeout=None, msg=None, fallback=False)

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 example
using web element
QAutoRobot.wait_until_element_is_visible(self.TRIAL)
using representation
QAutoRobot.common_utils.wait_until_element_is_visible((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.wait_until_element_is_visible(self.TRIAL, 10)
QAutoRobot.wait_until_element_is_visible((By.LINK_TEXT, u'Trial'), 10)
wait_until_spinner_is_not_visible(timeout=None)

Wait until page loading spinner is not visible

This method is already build in some of the common methods. Used locator for spinner element can be added in ‘/config/project_config/spinner_locators.txt’ file

Parameters

timeout – Uses default timeout, unless custom value provided.

Exception

If time exceeds DEFAULT_TIMEOUT, then rise exception.

Example
Page model level example
using web element
QAutoRobot.wait_until_spinner_is_not_visible()
using timeout
QAutoRobot.wait_until_spinner_is_not_visible(10)
warning(message)

Adds warning to test report

Parameters

message – Message to print as a String

Example
Page model level example
QAutoRobot.warning("My message")
class QAutoLibrary.QAutoSelenium.CommonUtils

Main class for all available methods

DATA_TEST_CASES_AND_DATA_FILES = {}
accept_alert()

Accepts current alert window

Example
Page model level example
QAutoRobot.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 example
QAutoRobot.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value")
QAutoRobot.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value", "my_section")
Using dynamic value
QAutoRobot.add_dynamic_content_to_parameters(self.ELEMENT_NAME, parameters["param_name"])
alert_is_present()

Check if alert is present

Returns

Alert as webdriver element alert if alert not found returns false

Example
Page model level example
QAutoRobot.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 example
QAutoRobot.alert_is_present()
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_should_be_selected(element)

Check checkbox is selected.

Parameters

element – Checkbox element

Example
QAutoRobot.checkbox_should_be_selected(self.CLASS_CHECKBOX)
checkbox_should_not_be_selected(element)

Check radiobutton is not selected.

Parameters

element – Radiobutton element

Example
QAutoRobot.checkbox_should_not_be_selected(self.CLASS_RADIO)
click_canvas(element)

Click at element

Parameters

element – Element representation (By, value) or WebElement

click_checkbox_with_javascript(element)
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 level
using web element
QAutoRobot.click_element(self.TRIAL)
using representation
QAutoRobot.click_element((By.LINK_TEXT, u'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 level
using web element
QAutoRobot.click_element_at_coordinates(self.TRIAL, 1, 1)
using representation
QAutoRobot.click_element_at_coordinates((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.click_table_cell_by_column_and_row(self.TABLE, 1, "TD/DIV/H4/A")
using representation
QAutoRobot.click_table_cell_by_column_and_row((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), 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 example
using web element
QAutoRobot.click_table_cell_by_column_and_row(self.TABLE, 1, 1)
using representation
QAutoRobot.click_table_cell_by_column_and_row((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), 1, 1)
close_all_browsers()

Closes all opened browsers

Example
Page model level example
QAutoRobot.close_all_browsers()
close_browser()

Closes current active browser

Example
Page model level example
QAutoRobot.close_browser()
close_window()

Close current window

Example
Page model level example
QAutoRobot.close_window()
close_window_and_focus_to_previous()

Close current window and focus to previous one

Example
Page model level example
QAutoRobot.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 QAutoRobot.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 example
QAutoRobot.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

decrypt(encrypted)

Decrypts encrypted string back to plain text.

Parameters

encrypted – Encrypted string that needs to decrypt

Returns

decrypted string

Example
Page model level
QAutoRobot.decrypt("encrypted-key-string")
delete_all_cookies()

Deletes all cookies from current session

Example
Page model level example
QAutoRobot.delete_all_cookies()
dismiss_alert()

Dismisses current alert window

Example
Page model level example
QAutoRobot.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 example
using web element
QAutoRobot.double_click_element(self.TRIAL)
using representation
QAutoRobot.double_click_element((By.LINK_TEXT, u'Trial'))
drag_and_drop(draggable, droppable)

Drags draggable element onto droppable

Parameters
  • draggable – Element to drag

  • droppable – Element to drop onto

Example
QAutoRobot.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 example
using web element
QAutoRobot.drag_and_drop_by_offset(self.ID_DRAG1, 0, 0)
using representation
QAutoRobot.drag_and_drop_by_offset((By.CSS_SELECTOR, u'div>p'), 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
QAutoRobot.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
QAutoRobot.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
QAutoRobot.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
QAutoRobot.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
QAutoRobot.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
QAutoRobot.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
QAutoRobot.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
QAutoRobot.elements_count_should_be(self.element, value_int)
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 example
value = QAutoRobot.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 example
QAutoRobot.fail("My message")
fallback_element(element, action, value='')
find_element(element)

Return found WebElement

Parameters

element – Element representation (By, value) or WebElement

Returns

WebElement

Example
Page model level
element = QAutoRobot.find_element((By.LINK_TEXT, u'Trial'))
find_element_if_not_webelement(element)

Find element if its not selenium web element

Parameters

element – element to find

Returns

Web element

find_element_with_coordinates(x, y)

Finds web element with coordinates

Parameters
  • x – x position

  • y – y position

Returns

Web element

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 level
all_elements = QAutoRobot.find_elements((By.CSS_SELECTOR, u"img"))
find_last_searched_element_details(element=None)

Find element with last searched elements information

Returns

Element details or none

generate_zap_test_report(installation_dir, session_name, report_name='qautorobot_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
Pagemodel level example

QAutoRobot.generate_zap_test_report('C:\ZedAttackProxy\zap.bat', zap_session)
or QAutoRobot.generate_zap_test_report('C:\ZedAttackProxy\zap.bat', zap_session, "qautorobot_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 example
using web element
QAutoRobot.get_attribute(self.ID_DROPDOWN, "name")
using representation
QAutoRobot.get_attribute((By.ID, u'dropdown'), "name")
get_browser_console_log()

Return browser console log

Returns

console log

Example
Page model level example
value = QAutoRobot.get_browser_console_log()
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.
return

Current active browser url as a String.

get_current_window_handle()
get_dom_element_count(log=True)

Counting DOM-elements

Returns

Returns number of DOM-elements on web page.

Example
Page model level example
QAutoRobot.get_dom_element_count()
get_download_time(downloads_folder='', max_download_time=120)

Return file download time in Chrome

Parameters
  • downloads_folder – Chrome download folder

  • max_download_time – Max timeout to download

Returns

time

Example
Page model level example
value = QAutoRobot.get_download_time()
get_elements_count(element)

Return number of found elements

Parameters

element – Element representation

Returns

Number of found elements

Example
Page model level example
QAutoRobot.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 example
QAutoRobot.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 example
using web element
QAutoRobot.get_list_row_by_attribute_value(self.LIST, "name", "value_to_find")
element_rowlist = QAutoRobot.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 representation
QAutoRobot.get_list_row_by_attribute_value((By.CSS_SELECTOR, u'#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 example
using web element
QAutoRobot.get_list_row_by_attribute_value_contains(self.LIST, "name", "value_to_find","span")
element_rowlist = QAutoRobot.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 representation
QAutoRobot.get_list_row_by_attribute_value_contains((By.CSS_SELECTOR, u'#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 example
using web element
QAutoRobot.get_list_row_by_text(self.LIST, "text_to_find")
element_rowlist = QAutoRobot.get_list_row_by_text(self.LIST, parameters[u'member_id'],"LI")
element_rowlist[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representation
QAutoRobot.get_list_row_by_text((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "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 example
using web element
QAutoRobot.get_list_row_by_text_contains(self.LIST, "text_to_find")
element_rowlist = QAutoRobot.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 representation
QAutoRobot.get_list_row_by_text_contains((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "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 example
using web element
QAutoRobot.get_list_row_by_value(self.LIST, "value_to_find")
element_rowlist = QAutoRobot.get_list_row_by_value(self.LIST, parameters[u'member_id'],"LI")
element_rowlist[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representation
QAutoRobot.get_list_row_by_value((By.CSS_SELECTOR, u'#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 example
using web element
QAutoRobot.get_list_row_by_value_contains(self.LIST, "value_to_find")
element_rowlist = QAutoRobot.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 representation
QAutoRobot.get_list_row_by_value_contains((By.CSS_SELECTOR, u'#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 example
QAutoRobot.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
QAutoRobot.go_to("http://www.maps.nokia.com")
html_source = QAutoRobot.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 example
QAutoRobot.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 example
using web element
QAutoRobot.get_selected_list_label(self.ID_DROPDOWN)
using representation
QAutoRobot.get_selected_list_label((By.ID, u'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 example
using web element
text_list = QAutoRobot.get_selected_list_labels(self.ID_DROPDOWN)
using representation
text_list = QAutoRobot.get_selected_list_labels((By.ID, u'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 example
using web element
QAutoRobot.get_selected_list_value(self.ID_DROPDOWN)
using representation
QAutoRobot.get_selected_list_value((By.ID, u'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 example
using web element
text_list = QAutoRobot.get_selected_list_values(self.ID_DROPDOWN)
using representation
text_list = QAutoRobot.get_selected_list_values((By.ID, u'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 example
value = QAutoRobot.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 example
using web element
QAutoRobot.get_table_cell_text_by_column_and_row(self.TABLE, 1, 1)
using representation
QAutoRobot.get_table_cell_text_by_column_and_row((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), 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 example
using web element
QAutoRobot.get_table_column_and_row_by_attribute_value(self.TABLE, "name", "attribute_to_find")
element_rowtable = QAutoRobot.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 representation
QAutoRobot.get_table_column_and_row_by_attribute_value((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "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 example
using web element
QAutoRobot.get_table_column_and_row_by_attribute_value_contains(self.TABLE, "name", "attribute_to_find")
element_rowtable = QAutoRobot.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 representation
QAutoRobot.get_table_column_and_row_by_attribute_value_contains((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "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 example
using web element
QAutoRobot.get_table_column_and_row_by_multiple_text(self.TABLE, "text_to_find1", "text_to_find2")
element_rowtable = QAutoRobot.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 representation
QAutoRobot.get_table_column_and_row_by_multiple_text((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "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 example
using web element
QAutoRobot.get_table_column_and_row_by_text(self.TABLE, "text_to_find")
element_rowtable = QAutoRobot.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 representation
QAutoRobot.get_table_column_and_row_by_text((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "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 example
using web element
QAutoRobot.get_table_column_and_row_by_text_contains(self.TABLE, "text_to_find")
element_rowtable = QAutoRobot.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 representation
QAutoRobot.get_table_column_and_row_by_text_contains((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "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 example
using web element
QAutoRobot.get_table_column_and_row_by_value(self.TABLE, "text_to_find")
element_rowtable = QAutoRobot.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 representation
QAutoRobot.get_table_column_and_row_by_value((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "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 example
using web element
QAutoRobot.get_table_column_and_row_by_value_contains(self.TABLE, "text_to_find")
element_rowtable = QAutoRobot.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 representation
QAutoRobot.get_table_column_and_row_by_value_contains((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "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 example
using web element
QAutoRobot.get_table_size(self.TABLE)
element_rowtable = QAutoRobot.get_table_size(self.ID_TABLE)
using representation
QAutoRobot.get_table_size((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'))
get_text(element)

Return element’s text

Parameters

element – Element representation (By, value) or WebElement

Returns

Text of element

Example
Page model level example
using web element
value = QAutoRobot.get_text(self.TRIAL)
using representation
value = QAutoRobot.get_text((By.LINK_TEXT, u'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 example
using web element
value = QAutoRobot.get_text_length(self.TRIAL)
using representation
value = QAutoRobot.get_text_length((By.LINK_TEXT, u'Trial'))
classmethod get_timestamp()

Return timestamp

Format

‘yyyyMMddhhmmss’

Returns

String which represents current time

Example
Page model level example
value = QAutoRobot.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 example
using web element
value = QAutoRobot.get_value(self.TRIAL)
using representation
value = QAutoRobot.get_value((By.LINK_TEXT, u'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 example
value = QAutoRobot.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 example
QAutoRobot.get_window_size()
get_xpath(element)
go_back()

Simulates pressing Back button in browser window

Example
Page model level example
QAutoRobot.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 example
QAutoRobot.go_to("http://qautomate.fi/")
input_text(element, value, to_print=True, encrypt=False)

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 level
using web element
QAutoRobot.input_text(self.ID_CONTACT_FIRST_NAME, "this is value")
using representation
QAutoRobot.input_text((By.ID, u'contact_first_name'), "this is value")
input_text_element_at_coordinates(element, x, y, text, 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 level
using web element
self.input_text_element_at_coordinates(self.TRIAL, 1, 1)
using representation
self.input_text_element_at_coordinates((By.LINK_TEXT, u'Trial'), 1, 1)

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 example
using web element
QAutoRobot.is_disabled(self.TRIAL)
using representation
QAutoRobot.is_disabled((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.is_disabled(self.TRIAL, 10)
QAutoRobot.is_disabled((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.is_enabled(self.TRIAL)
using representation
QAutoRobot.is_enabled((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.is_enabled(self.TRIAL, 10)
QAutoRobot.is_enabled((By.LINK_TEXT, u'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_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 example
using web element
QAutoRobot.is_present(self.ID_TESTINPUT)
using representation
QAutoRobot.is_present((By.ID, u'testInput'))
using timeout
QAutoRobot.is_present(self.ID_TESTINPUT, 10)
QAutoRobot.is_present(By.ID, u'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 example
using web element
QAutoRobot.is_visible(self.TRIAL)
using representation
QAutoRobot.is_visible((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.is_visible(self.TRIAL, 10)
QAutoRobot.is_visible((By.LINK_TEXT, u'Trial'), 10)
last_element_details(fallback=False, action='')
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
QAutoRobot.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
QAutoRobot.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 level
QAutoRobot.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 example
using web element
QAutoRobot.mouse_down(self.TRIAL)
using representation
QAutoRobot.mouse_down((By.LINK_TEXT, u'Trial'))
mouse_over(element)

Mouse overhover element

Parameters

element – Element representation (By, value) or WebElement object.

Example
Page model level example
using web element
QAutoRobot.mouse_over(self.TRIAL)
using representation
QAutoRobot.mouse_over((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.mouse_over_by_offset(self.TRIAL, 0, 0)
using representation
QAutoRobot.mouse_over_by_offset((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.mouse_right_click_by_offset(self.TRIAL, 0, 0)
using representation
QAutoRobot.mouse_right_click_by_offset((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.mouse_up(self.TRIAL)
using representation
QAutoRobot.mouse_up((By.LINK_TEXT, u'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 example
QAutoRobot.open_browser("ff", http://qautomate.fi/")
open_context_menu(element)

Mouse right click at element opening context menu

Parameters

element – Element representation (By, value) or WebElement object.

Example
Page model level example
using web element
QAutoRobot.open_context_menu(self.TRIAL)
using representation
QAutoRobot.open_context_menu((By.LINK_TEXT, u'Trial'))
open_remote_chrome_driver(port=9321)

Creates a driver to a remote debugging chrome instance

Parameters

port – Port specified when Chrome instance was created.

open_url(url, log=True)

Open specified url

Parameters
  • url – Url to open

  • log – Flag, if True prints action message

Example
Page model level example
QAutoRobot.open_url("http://qautomate.fi/")
reload_page()

Refreshes page

Example
Page model level example
QAutoRobot.refresh_page()
save_page_source(testname)

Writes page source to file in test reports folder, used in teardown

Returns

page source

Example
QAutoRobot.go_to("http://www.maps.nokia.com")
html_source = QAutoRobot.save_page_source()
if "City and Country Maps" in html_source:
do something
else:
do something else
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)

Checks the checkbox

Parameters

element – checkbox element

Example
Page model level example
using web element
QAutoRobot.select_checkbox(self.ID_CHECKBOX1)
using representation
QAutoRobot.select_checkbox((By.ID, u'checkbox1'))
select_frame(element)

Switch focus to frame

Parameters

element – Element representation (By, value), WebElement or frame name.

Example
Page model level example
using web element
QAutoRobot.select_frame(self.IFRAME)
using representation
QAutoRobot.select_frame((By.CSS_SELECTOR, u'iframe'))
select_frame_default_content()

Switch focus to default content

Example
Page model level example
QAutoRobot.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 example
using web element
QAutoRobot.select_from_list_by_label(self.ID_DROPDOWN, "value")
using representation
QAutoRobot.select_from_list_by_label((By.ID, u'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 example
using web element
QAutoRobot.select_from_list_by_random_option(self.ID_DROPDOWN)
using representation
QAutoRobot.select_from_list_by_random_option((By.ID, u'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 example
using web element
QAutoRobot.select_from_list_by_value(self.ID_DROPDOWN, 10)
using representation
QAutoRobot.select_from_list_by_value((By.ID, u'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_email(smtp_username, smtp_password, receiver, mail_subject, mail_content)

Send mail from qautomate support to receiver

Parameters
  • smtp_username – Email server user

  • smtp_password – Email server user password

  • receiver – Email address of the receiver

  • mail_subject – Subject of the email

  • mail_content – Content part of the email

Example

Page model level example QAutoRobot.send_email(email_client, email_secret, "employee@company.com", "Test_Subject", "This is a test message")

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 level
using web element
QAutoRobot.send_keys(self.ID_CONTACT_FIRST_NAME, "this is value")
using representation
QAutoRobot.send_keys((By.ID, u'contact_first_name'), "this is value")
set_speed(timeout)

Set selenium speed

Parameters

timeout – timeout in seconds

set_window_size(width, height)

Set current window size width, height

Parameters
  • width – window width

  • height – window height

Example
Page model level example
QAutoRobot.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 example
zap, zap_session = QAutoRobot.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
Pagemodel level example
zap, zap_session = QAutoRobot.start_zapproxy_daemon('C:\ZedAttackProxy\zap.bat')
QAutoRobot.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 id
id = QAutoRobot.open_browser("ff", "http://qautomate.fi/")
id2 = QAutoRobot.open_browser("ff", "http://qautomate.fi/")
run some steps
QAutoRobot.switch_browser(id)
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 element
QAutoRobot.table_contains_text(self.TABLE, u'in_table')
using representation
QAutoRobot.table_contains_text((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'in_table')
take_full_screenshot(pic_name, height_override=None)

Take full screenshot of the page

Parameters
  • pic_name – Name for the screenshot

  • height_override – Override height

Returns

None

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 example
using web element
QAutoRobot.triple_click_element(self.TRIAL)
using representation
QAutoRobot.triple_click_element((By.LINK_TEXT, u'Trial'))
unselect_checkbox(element)

Unchecks the checkbox

Parameters

element – checkbox element

Example
Page model level example
using web element
QAutoRobot.unselect_checkbox(self.ID_CHECKBOX1)
using representation
QAutoRobot.unselect_checkbox((By.ID, u'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.lat

Parameters
  • 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'
QAutoRobot.verify_rest_api_json_value(url, u'get', u'expected.txt', u'', u'')

QAutoRobot.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'
QAutoRobot.verify_rest_api_xml_value(url, u'get', u'expected.txt', u'', u'')

QAutoRobot.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
QAutoRobot.verify_soap_api(u'http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL', u'soap_xml.xml', response_file.txt)
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 example
QAutoRobot.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 example
using web element
QAutoRobot.wait_until_element_attribute_contains(self.ID_DROPDOWN, "name", "dropdown")
using representation
QAutoRobot.wait_until_element_attribute_contains((By.ID, u'dropdown'), "name", "dropdown")
using timeout
QAutoRobot.wait_until_element_attribute_contains(self.ID_DROPDOWN, "name", "dropdown", 10)
QAutoRobot.wait_until_element_attribute_contains((By.ID, u'dropdown'), "name", "dropdown", 10)
wait_until_element_attribute_should_be(element, attr, expected_value, timeout=None)

Wait until element’s attribute is equal

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 example
using web element
QAutoRobot.wait_until_element_attribute_should_be(self.ID_DROPDOWN, "class", "partialtext")
using representation
QAutoRobot.wait_until_element_attribute_should_be((By.ID, u'dropdown'), "class", "partialtext")
using timeout
QAutoRobot.wait_until_element_attribute_should_be(self.ID_DROPDOWN, "class", "partialtext", 10)
QAutoRobot.wait_until_element_attribute_should_be((By.ID, u'dropdown'), "class", "partialtext", 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 example
using web element
QAutoRobot.common_utils.wait_until_element_contains(self.elements.TEST, u'Cell text is this')
QAutoRobot.wait_until_element_contains((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text is this'1', 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 example
using web element
QAutoRobot.wait_until_element_does_not_contain(self.TEST, u'Cell text changed')
using representation
QAutoRobot.wait_until_element_does_not_contain((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text changed')
using timeout
QAutoRobot.wait_until_element_does_not_contain(self.TEST, u'Cell text changed', 10)
QAutoRobot.wait_until_element_does_not_contain((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), 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 example
using web element
QAutoRobot.wait_until_element_is_disabled(self.TRIAL)
using representation
QAutoRobot.common_utils.wait_until_element_is_disabled((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.wait_until_element_is_disabled(self.TRIAL, 10)
QAutoRobot.wait_until_element_is_disabled((By.LINK_TEXT, u'Trial'), 10)
wait_until_element_is_enabled(element, timeout=None, msg=None, fallback=False)

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 example
using web element
QAutoRobot.wait_until_element_is_enabled(self.TRIAL)
using representation
QAutoRobot.common_utils.wait_until_element_is_enabled((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.wait_until_element_is_enabled(self.TRIAL, 10)
QAutoRobot.wait_until_element_is_enabled((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.wait_until_element_is_not_present(self.ID_TESTINPUT)
using representation
QAutoRobot.wait_until_element_is_not_present((By.ID, u'testInput'))
using timeout
QAutoRobot.wait_until_element_is_not_present(self.ID_TESTINPUT, 10)
QAutoRobot.wait_until_element_is_not_present((By.ID, u'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 example
using web element
QAutoRobot.wait_until_element_is_not_visible(self.TRIAL)
using representation
QAutoRobot.common_utils.wait_until_element_is_not_visible((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.wait_until_element_is_not_visible(self.TRIAL, 10)
QAutoRobot.wait_until_element_is_not_visible((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.wait_until_element_is_present(self.ID_TESTINPUT)
using representation
QAutoRobot.wait_until_element_is_present((By.ID, u'testInput'))
using timeout
QAutoRobot.wait_until_element_is_present(self.ID_TESTINPUT, 10)
QAutoRobot.wait_until_element_is_present((By.ID, u'testInput'), 10)
wait_until_element_is_visible(element, timeout=None, msg=None, fallback=False)

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 example
using web element
QAutoRobot.wait_until_element_is_visible(self.TRIAL)
using representation
QAutoRobot.common_utils.wait_until_element_is_visible((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.wait_until_element_is_visible(self.TRIAL, 10)
QAutoRobot.wait_until_element_is_visible((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.wait_until_element_should_be(self.TEST, u'Cell text is this')
using representation
QAutoRobot.wait_until_element_should_be((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text is this')
using timeout
QAutoRobot.wait_until_element_should_be(self.TEST, u'Cell text is this', 10)
QAutoRobot.wait_until_element_should_be((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), 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 example
using web element
QAutoRobot.wait_until_element_should_not_be(self.TEST, u'Cell text changed')
using representation
QAutoRobot.wait_until_element_should_not_be((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text changed')
using timeout
QAutoRobot.wait_until_element_should_not_be(self.TEST, u'Cell text changed', 10)
QAutoRobot.wait_until_element_should_not_be((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text changed', 10)
wait_until_element_value_contains(element, value, timeout=None)

Wait until element’s value contains as expected

Parameters
  • element – Element representation (By, value) or WebElement.

  • value – Element’s value which expected

  • timeout – Uses default timeout, unless custom value provided.

Example
Page model level example
using web element
QAutoRobot.wait_until_element_value_contains(self.TEST, u'Part of element value')
using representation
QAutoRobot.wait_until_element_value_contains((By.CSS_SELECTOR, u'#valueTest input'), u'Part of element value')
using timeout
QAutoRobot.wait_until_element_value_contains(self.TEST, u'Part of element value', 10)
QAutoRobot.wait_until_element_value_contains((By.CSS_SELECTOR, u'#valueTest input'), u'Part of element value', 10)
wait_until_element_value_should_be(element, value, timeout=None)

Wait until element’s value is equal

Parameters
  • element – Element representation (By, value) or WebElement.

  • value – Element’s value which should be

  • timeout – Uses default timeout, unless custom value provided.

Example
Page model level example
using web element
QAutoRobot.wait_until_element_value_should_be(self.TEST, u'Element value is this')
using representation
QAutoRobot.wait_until_element_value_should_be((By.CSS_SELECTOR, u'#valueTest input'), u'Element value is this')
using timeout
QAutoRobot.wait_until_element_value_should_be(self.TEST, u'Element value is this', 10)
QAutoRobot.wait_until_element_value_should_be((By.CSS_SELECTOR, u'#valueTest input'), u'Element value is this', 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 example
QAutoRobot.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 example
using web element
QAutoRobot.wait_until_page_contains(u'Cell text is this')
using representation
QAutoRobot.wait_until_page_contains((u'Cell text is this')
using timeout
QAutoRobot.wait_until_page_contains(u'Cell text is this', 10)
QAutoRobot.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 example
using web element
QAutoRobot.wait_until_page_contain(u'Cell text is this')
using representation
QAutoRobot.wait_until_page_contain((u'Cell text is this')
using timeout
QAutoRobot.wait_until_page_contain(u'Cell text is this', 10)
QAutoRobot.wait_until_page_contain(u'Cell text is this', 10)
wait_until_spinner_is_not_visible(timeout=None)

Wait until page loading spinner is not visible

This method is already build in some of the common methods. Used locator for spinner element can be added in ‘/config/project_config/spinner_locators.txt’ file

Parameters

timeout – Uses default timeout, unless custom value provided.

Exception

If time exceeds DEFAULT_TIMEOUT, then rise exception.

Example
Page model level example
using web element
QAutoRobot.wait_until_spinner_is_not_visible()
using timeout
QAutoRobot.wait_until_spinner_is_not_visible(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 example
using web element
QAutoRobot.wait_until_table_size_changes(self.ID_TABLETEST)
using representation
QAutoRobot.wait_until_table_size_changes((By.ID, u'tableTest'))
using timeout
QAutoRobot.wait_until_table_size_changes(self.ID_TABLETEST, 10)
QAutoRobot.wait_until_table_size_changes((By.ID, u'tableTest'), 10)
warning(message)

Adds warning to test report

Parameters

message – Message to print as a String

Example
Page model level example
QAutoRobot.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 QAutoLibrary.QAutoSelenium.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 QAutoLibrary.QAutoSelenium.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 QAutoLibrary.QAutoSelenium.WebMethods(driver_cache=None)

Class that contains methods for web

accept_alert()

Accepts current alert window

Example
Page model level example
QAutoRobot.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 example
QAutoRobot.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value")
QAutoRobot.add_dynamic_content_to_parameters(TESTDATA, "param_name", "my_value", "my_section")
Using dynamic value
QAutoRobot.add_dynamic_content_to_parameters(self.ELEMENT_NAME, parameters["param_name"])
alert_is_present()

Check if alert is present

Returns

Alert as webdriver element alert if alert not found returns false

Example
Page model level example
QAutoRobot.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 example
QAutoRobot.alert_is_present()
click_checkbox_with_javascript(element)
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 level
using web element
QAutoRobot.click_element(self.TRIAL)
using representation
QAutoRobot.click_element((By.LINK_TEXT, u'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 level
using web element
QAutoRobot.click_element_at_coordinates(self.TRIAL, 1, 1)
using representation
QAutoRobot.click_element_at_coordinates((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.click_table_cell_by_column_and_row(self.TABLE, 1, "TD/DIV/H4/A")
using representation
QAutoRobot.click_table_cell_by_column_and_row((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), 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 example
using web element
QAutoRobot.click_table_cell_by_column_and_row(self.TABLE, 1, 1)
using representation
QAutoRobot.click_table_cell_by_column_and_row((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), 1, 1)
close_all_browsers()

Closes all opened browsers

Example
Page model level example
QAutoRobot.close_all_browsers()
close_browser()

Closes current active browser

Example
Page model level example
QAutoRobot.close_browser()
close_window()

Close current window

Example
Page model level example
QAutoRobot.close_window()
close_window_and_focus_to_previous()

Close current window and focus to previous one

Example
Page model level example
QAutoRobot.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 QAutoRobot.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 example
QAutoRobot.compare_screenshots("ref_scr_name")
decrypt(encrypted)

Decrypts encrypted string back to plain text.

Parameters

encrypted – Encrypted string that needs to decrypt

Returns

decrypted string

Example
Page model level
QAutoRobot.decrypt("encrypted-key-string")
delete_all_cookies()

Deletes all cookies from current session

Example
Page model level example
QAutoRobot.delete_all_cookies()
dismiss_alert()

Dismisses current alert window

Example
Page model level example
QAutoRobot.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 example
using web element
QAutoRobot.double_click_element(self.TRIAL)
using representation
QAutoRobot.double_click_element((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.drag_and_drop_by_offset(self.ID_DRAG1, 0, 0)
using representation
QAutoRobot.drag_and_drop_by_offset((By.CSS_SELECTOR, u'div>p'), 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 example
value = QAutoRobot.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 example
QAutoRobot.fail("My message")
fallback_element(element, action, value='')
find_element(element)

Return found WebElement

Parameters

element – Element representation (By, value) or WebElement

Returns

WebElement

Example
Page model level
element = QAutoRobot.find_element((By.LINK_TEXT, u'Trial'))
find_element_if_not_webelement(element)

Find element if its not selenium web element

Parameters

element – element to find

Returns

Web element

find_element_with_coordinates(x, y)

Finds web element with coordinates

Parameters
  • x – x position

  • y – y position

Returns

Web element

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 level
all_elements = QAutoRobot.find_elements((By.CSS_SELECTOR, u"img"))
find_last_searched_element_details(element=None)

Find element with last searched elements information

Returns

Element details or none

generate_zap_test_report(installation_dir, session_name, report_name='qautorobot_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
Pagemodel level example

QAutoRobot.generate_zap_test_report('C:\ZedAttackProxy\zap.bat', zap_session)
or QAutoRobot.generate_zap_test_report('C:\ZedAttackProxy\zap.bat', zap_session, "qautorobot_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 example
using web element
QAutoRobot.get_attribute(self.ID_DROPDOWN, "name")
using representation
QAutoRobot.get_attribute((By.ID, u'dropdown'), "name")
get_browser_console_log()

Return browser console log

Returns

console log

Example
Page model level example
value = QAutoRobot.get_browser_console_log()
get_current_window_handle()
get_dom_element_count(log=True)

Counting DOM-elements

Returns

Returns number of DOM-elements on web page.

Example
Page model level example
QAutoRobot.get_dom_element_count()
get_download_time(downloads_folder='', max_download_time=120)

Return file download time in Chrome

Parameters
  • downloads_folder – Chrome download folder

  • max_download_time – Max timeout to download

Returns

time

Example
Page model level example
value = QAutoRobot.get_download_time()
get_elements_count(element)

Return number of found elements

Parameters

element – Element representation

Returns

Number of found elements

Example
Page model level example
QAutoRobot.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 example
QAutoRobot.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 example
using web element
QAutoRobot.get_list_row_by_attribute_value(self.LIST, "name", "value_to_find")
element_rowlist = QAutoRobot.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 representation
QAutoRobot.get_list_row_by_attribute_value((By.CSS_SELECTOR, u'#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 example
using web element
QAutoRobot.get_list_row_by_attribute_value_contains(self.LIST, "name", "value_to_find","span")
element_rowlist = QAutoRobot.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 representation
QAutoRobot.get_list_row_by_attribute_value_contains((By.CSS_SELECTOR, u'#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 example
using web element
QAutoRobot.get_list_row_by_text(self.LIST, "text_to_find")
element_rowlist = QAutoRobot.get_list_row_by_text(self.LIST, parameters[u'member_id'],"LI")
element_rowlist[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representation
QAutoRobot.get_list_row_by_text((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "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 example
using web element
QAutoRobot.get_list_row_by_text_contains(self.LIST, "text_to_find")
element_rowlist = QAutoRobot.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 representation
QAutoRobot.get_list_row_by_text_contains((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "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 example
using web element
QAutoRobot.get_list_row_by_value(self.LIST, "value_to_find")
element_rowlist = QAutoRobot.get_list_row_by_value(self.LIST, parameters[u'member_id'],"LI")
element_rowlist[0].find_element(By.CSS_SELECTOR, '.fa-wrench').click()
using representation
QAutoRobot.get_list_row_by_value((By.CSS_SELECTOR, u'#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 example
using web element
QAutoRobot.get_list_row_by_value_contains(self.LIST, "value_to_find")
element_rowlist = QAutoRobot.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 representation
QAutoRobot.get_list_row_by_value_contains((By.CSS_SELECTOR, u'#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 example
QAutoRobot.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 example
QAutoRobot.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 example
using web element
QAutoRobot.get_selected_list_label(self.ID_DROPDOWN)
using representation
QAutoRobot.get_selected_list_label((By.ID, u'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 example
using web element
text_list = QAutoRobot.get_selected_list_labels(self.ID_DROPDOWN)
using representation
text_list = QAutoRobot.get_selected_list_labels((By.ID, u'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 example
using web element
QAutoRobot.get_selected_list_value(self.ID_DROPDOWN)
using representation
QAutoRobot.get_selected_list_value((By.ID, u'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 example
using web element
text_list = QAutoRobot.get_selected_list_values(self.ID_DROPDOWN)
using representation
text_list = QAutoRobot.get_selected_list_values((By.ID, u'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 example
value = QAutoRobot.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 example
using web element
QAutoRobot.get_table_cell_text_by_column_and_row(self.TABLE, 1, 1)
using representation
QAutoRobot.get_table_cell_text_by_column_and_row((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), 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 example
using web element
QAutoRobot.get_table_column_and_row_by_attribute_value(self.TABLE, "name", "attribute_to_find")
element_rowtable = QAutoRobot.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 representation
QAutoRobot.get_table_column_and_row_by_attribute_value((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "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 example
using web element
QAutoRobot.get_table_column_and_row_by_attribute_value_contains(self.TABLE, "name", "attribute_to_find")
element_rowtable = QAutoRobot.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 representation
QAutoRobot.get_table_column_and_row_by_attribute_value_contains((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "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 example
using web element
QAutoRobot.get_table_column_and_row_by_multiple_text(self.TABLE, "text_to_find1", "text_to_find2")
element_rowtable = QAutoRobot.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 representation
QAutoRobot.get_table_column_and_row_by_multiple_text((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "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 example
using web element
QAutoRobot.get_table_column_and_row_by_text(self.TABLE, "text_to_find")
element_rowtable = QAutoRobot.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 representation
QAutoRobot.get_table_column_and_row_by_text((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "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 example
using web element
QAutoRobot.get_table_column_and_row_by_text_contains(self.TABLE, "text_to_find")
element_rowtable = QAutoRobot.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 representation
QAutoRobot.get_table_column_and_row_by_text_contains((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "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 example
using web element
QAutoRobot.get_table_column_and_row_by_value(self.TABLE, "text_to_find")
element_rowtable = QAutoRobot.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 representation
QAutoRobot.get_table_column_and_row_by_value((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "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 example
using web element
QAutoRobot.get_table_column_and_row_by_value_contains(self.TABLE, "text_to_find")
element_rowtable = QAutoRobot.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 representation
QAutoRobot.get_table_column_and_row_by_value_contains((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), "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 example
using web element
QAutoRobot.get_table_size(self.TABLE)
element_rowtable = QAutoRobot.get_table_size(self.ID_TABLE)
using representation
QAutoRobot.get_table_size((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'))
get_text(element)

Return element’s text

Parameters

element – Element representation (By, value) or WebElement

Returns

Text of element

Example
Page model level example
using web element
value = QAutoRobot.get_text(self.TRIAL)
using representation
value = QAutoRobot.get_text((By.LINK_TEXT, u'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 example
using web element
value = QAutoRobot.get_text_length(self.TRIAL)
using representation
value = QAutoRobot.get_text_length((By.LINK_TEXT, u'Trial'))
classmethod get_timestamp()

Return timestamp

Format

‘yyyyMMddhhmmss’

Returns

String which represents current time

Example
Page model level example
value = QAutoRobot.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 example
using web element
value = QAutoRobot.get_value(self.TRIAL)
using representation
value = QAutoRobot.get_value((By.LINK_TEXT, u'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 example
value = QAutoRobot.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 example
QAutoRobot.get_window_size()
get_xpath(element)
go_back()

Simulates pressing Back button in browser window

Example
Page model level example
QAutoRobot.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 example
QAutoRobot.go_to("http://qautomate.fi/")
input_text(element, value, to_print=True, encrypt=False)

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 level
using web element
QAutoRobot.input_text(self.ID_CONTACT_FIRST_NAME, "this is value")
using representation
QAutoRobot.input_text((By.ID, u'contact_first_name'), "this is value")
input_text_element_at_coordinates(element, x, y, text, 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 level
using web element
self.input_text_element_at_coordinates(self.TRIAL, 1, 1)
using representation
self.input_text_element_at_coordinates((By.LINK_TEXT, u'Trial'), 1, 1)

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 example
using web element
QAutoRobot.is_disabled(self.TRIAL)
using representation
QAutoRobot.is_disabled((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.is_disabled(self.TRIAL, 10)
QAutoRobot.is_disabled((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.is_enabled(self.TRIAL)
using representation
QAutoRobot.is_enabled((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.is_enabled(self.TRIAL, 10)
QAutoRobot.is_enabled((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.is_present(self.ID_TESTINPUT)
using representation
QAutoRobot.is_present((By.ID, u'testInput'))
using timeout
QAutoRobot.is_present(self.ID_TESTINPUT, 10)
QAutoRobot.is_present(By.ID, u'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 example
using web element
QAutoRobot.is_visible(self.TRIAL)
using representation
QAutoRobot.is_visible((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.is_visible(self.TRIAL, 10)
QAutoRobot.is_visible((By.LINK_TEXT, u'Trial'), 10)
last_element_details(fallback=False, action='')
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 level
QAutoRobot.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 example
using web element
QAutoRobot.mouse_down(self.TRIAL)
using representation
QAutoRobot.mouse_down((By.LINK_TEXT, u'Trial'))
mouse_over(element)

Mouse overhover element

Parameters

element – Element representation (By, value) or WebElement object.

Example
Page model level example
using web element
QAutoRobot.mouse_over(self.TRIAL)
using representation
QAutoRobot.mouse_over((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.mouse_over_by_offset(self.TRIAL, 0, 0)
using representation
QAutoRobot.mouse_over_by_offset((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.mouse_right_click_by_offset(self.TRIAL, 0, 0)
using representation
QAutoRobot.mouse_right_click_by_offset((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.mouse_up(self.TRIAL)
using representation
QAutoRobot.mouse_up((By.LINK_TEXT, u'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 example
QAutoRobot.open_browser("ff", http://qautomate.fi/")
open_context_menu(element)

Mouse right click at element opening context menu

Parameters

element – Element representation (By, value) or WebElement object.

Example
Page model level example
using web element
QAutoRobot.open_context_menu(self.TRIAL)
using representation
QAutoRobot.open_context_menu((By.LINK_TEXT, u'Trial'))
open_remote_chrome_driver(port=9321)

Creates a driver to a remote debugging chrome instance

Parameters

port – Port specified when Chrome instance was created.

open_url(url, log=True)

Open specified url

Parameters
  • url – Url to open

  • log – Flag, if True prints action message

Example
Page model level example
QAutoRobot.open_url("http://qautomate.fi/")
reload_page()

Refreshes page

Example
Page model level example
QAutoRobot.refresh_page()
select_checkbox(element)

Checks the checkbox

Parameters

element – checkbox element

Example
Page model level example
using web element
QAutoRobot.select_checkbox(self.ID_CHECKBOX1)
using representation
QAutoRobot.select_checkbox((By.ID, u'checkbox1'))
select_frame(element)

Switch focus to frame

Parameters

element – Element representation (By, value), WebElement or frame name.

Example
Page model level example
using web element
QAutoRobot.select_frame(self.IFRAME)
using representation
QAutoRobot.select_frame((By.CSS_SELECTOR, u'iframe'))
select_frame_default_content()

Switch focus to default content

Example
Page model level example
QAutoRobot.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 example
using web element
QAutoRobot.select_from_list_by_label(self.ID_DROPDOWN, "value")
using representation
QAutoRobot.select_from_list_by_label((By.ID, u'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 example
using web element
QAutoRobot.select_from_list_by_random_option(self.ID_DROPDOWN)
using representation
QAutoRobot.select_from_list_by_random_option((By.ID, u'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 example
using web element
QAutoRobot.select_from_list_by_value(self.ID_DROPDOWN, 10)
using representation
QAutoRobot.select_from_list_by_value((By.ID, u'dropdown'), 10)
send_email(smtp_username, smtp_password, receiver, mail_subject, mail_content)

Send mail from qautomate support to receiver

Parameters
  • smtp_username – Email server user

  • smtp_password – Email server user password

  • receiver – Email address of the receiver

  • mail_subject – Subject of the email

  • mail_content – Content part of the email

Example

Page model level example QAutoRobot.send_email(email_client, email_secret, "employee@company.com", "Test_Subject", "This is a test message")

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 level
using web element
QAutoRobot.send_keys(self.ID_CONTACT_FIRST_NAME, "this is value")
using representation
QAutoRobot.send_keys((By.ID, u'contact_first_name'), "this is value")
set_speed(timeout)

Set selenium speed

Parameters

timeout – timeout in seconds

set_window_size(width, height)

Set current window size width, height

Parameters
  • width – window width

  • height – window height

Example
Page model level example
QAutoRobot.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 example
zap, zap_session = QAutoRobot.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
Pagemodel level example
zap, zap_session = QAutoRobot.start_zapproxy_daemon('C:\ZedAttackProxy\zap.bat')
QAutoRobot.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 id
id = QAutoRobot.open_browser("ff", "http://qautomate.fi/")
id2 = QAutoRobot.open_browser("ff", "http://qautomate.fi/")
run some steps
QAutoRobot.switch_browser(id)
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 element
QAutoRobot.table_contains_text(self.TABLE, u'in_table')
using representation
QAutoRobot.table_contains_text((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), 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 example
using web element
QAutoRobot.triple_click_element(self.TRIAL)
using representation
QAutoRobot.triple_click_element((By.LINK_TEXT, u'Trial'))
unselect_checkbox(element)

Unchecks the checkbox

Parameters

element – checkbox element

Example
Page model level example
using web element
QAutoRobot.unselect_checkbox(self.ID_CHECKBOX1)
using representation
QAutoRobot.unselect_checkbox((By.ID, u'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 example
QAutoRobot.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 example
using web element
QAutoRobot.wait_until_element_attribute_contains(self.ID_DROPDOWN, "name", "dropdown")
using representation
QAutoRobot.wait_until_element_attribute_contains((By.ID, u'dropdown'), "name", "dropdown")
using timeout
QAutoRobot.wait_until_element_attribute_contains(self.ID_DROPDOWN, "name", "dropdown", 10)
QAutoRobot.wait_until_element_attribute_contains((By.ID, u'dropdown'), "name", "dropdown", 10)
wait_until_element_attribute_should_be(element, attr, expected_value, timeout=None)

Wait until element’s attribute is equal

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 example
using web element
QAutoRobot.wait_until_element_attribute_should_be(self.ID_DROPDOWN, "class", "partialtext")
using representation
QAutoRobot.wait_until_element_attribute_should_be((By.ID, u'dropdown'), "class", "partialtext")
using timeout
QAutoRobot.wait_until_element_attribute_should_be(self.ID_DROPDOWN, "class", "partialtext", 10)
QAutoRobot.wait_until_element_attribute_should_be((By.ID, u'dropdown'), "class", "partialtext", 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 example
using web element
QAutoRobot.common_utils.wait_until_element_contains(self.elements.TEST, u'Cell text is this')
QAutoRobot.wait_until_element_contains((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text is this'1', 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 example
using web element
QAutoRobot.wait_until_element_does_not_contain(self.TEST, u'Cell text changed')
using representation
QAutoRobot.wait_until_element_does_not_contain((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text changed')
using timeout
QAutoRobot.wait_until_element_does_not_contain(self.TEST, u'Cell text changed', 10)
QAutoRobot.wait_until_element_does_not_contain((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), 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 example
using web element
QAutoRobot.wait_until_element_is_disabled(self.TRIAL)
using representation
QAutoRobot.common_utils.wait_until_element_is_disabled((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.wait_until_element_is_disabled(self.TRIAL, 10)
QAutoRobot.wait_until_element_is_disabled((By.LINK_TEXT, u'Trial'), 10)
wait_until_element_is_enabled(element, timeout=None, msg=None, fallback=False)

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 example
using web element
QAutoRobot.wait_until_element_is_enabled(self.TRIAL)
using representation
QAutoRobot.common_utils.wait_until_element_is_enabled((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.wait_until_element_is_enabled(self.TRIAL, 10)
QAutoRobot.wait_until_element_is_enabled((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.wait_until_element_is_not_present(self.ID_TESTINPUT)
using representation
QAutoRobot.wait_until_element_is_not_present((By.ID, u'testInput'))
using timeout
QAutoRobot.wait_until_element_is_not_present(self.ID_TESTINPUT, 10)
QAutoRobot.wait_until_element_is_not_present((By.ID, u'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 example
using web element
QAutoRobot.wait_until_element_is_not_visible(self.TRIAL)
using representation
QAutoRobot.common_utils.wait_until_element_is_not_visible((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.wait_until_element_is_not_visible(self.TRIAL, 10)
QAutoRobot.wait_until_element_is_not_visible((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.wait_until_element_is_present(self.ID_TESTINPUT)
using representation
QAutoRobot.wait_until_element_is_present((By.ID, u'testInput'))
using timeout
QAutoRobot.wait_until_element_is_present(self.ID_TESTINPUT, 10)
QAutoRobot.wait_until_element_is_present((By.ID, u'testInput'), 10)
wait_until_element_is_visible(element, timeout=None, msg=None, fallback=False)

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 example
using web element
QAutoRobot.wait_until_element_is_visible(self.TRIAL)
using representation
QAutoRobot.common_utils.wait_until_element_is_visible((By.LINK_TEXT, u'Trial'))
using timeout
QAutoRobot.wait_until_element_is_visible(self.TRIAL, 10)
QAutoRobot.wait_until_element_is_visible((By.LINK_TEXT, u'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 example
using web element
QAutoRobot.wait_until_element_should_be(self.TEST, u'Cell text is this')
using representation
QAutoRobot.wait_until_element_should_be((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text is this')
using timeout
QAutoRobot.wait_until_element_should_be(self.TEST, u'Cell text is this', 10)
QAutoRobot.wait_until_element_should_be((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), 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 example
using web element
QAutoRobot.wait_until_element_should_not_be(self.TEST, u'Cell text changed')
using representation
QAutoRobot.wait_until_element_should_not_be((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text changed')
using timeout
QAutoRobot.wait_until_element_should_not_be(self.TEST, u'Cell text changed', 10)
QAutoRobot.wait_until_element_should_not_be((By.CSS_SELECTOR, u'#tableTest>tbody>tr>td'), u'Cell text changed', 10)
wait_until_element_value_contains(element, value, timeout=None)

Wait until element’s value contains as expected

Parameters
  • element – Element representation (By, value) or WebElement.

  • value – Element’s value which expected

  • timeout – Uses default timeout, unless custom value provided.

Example
Page model level example
using web element
QAutoRobot.wait_until_element_value_contains(self.TEST, u'Part of element value')
using representation
QAutoRobot.wait_until_element_value_contains((By.CSS_SELECTOR, u'#valueTest input'), u'Part of element value')
using timeout
QAutoRobot.wait_until_element_value_contains(self.TEST, u'Part of element value', 10)
QAutoRobot.wait_until_element_value_contains((By.CSS_SELECTOR, u'#valueTest input'), u'Part of element value', 10)
wait_until_element_value_should_be(element, value, timeout=None)

Wait until element’s value is equal

Parameters
  • element – Element representation (By, value) or WebElement.

  • value – Element’s value which should be

  • timeout – Uses default timeout, unless custom value provided.

Example
Page model level example
using web element
QAutoRobot.wait_until_element_value_should_be(self.TEST, u'Element value is this')
using representation
QAutoRobot.wait_until_element_value_should_be((By.CSS_SELECTOR, u'#valueTest input'), u'Element value is this')
using timeout
QAutoRobot.wait_until_element_value_should_be(self.TEST, u'Element value is this', 10)
QAutoRobot.wait_until_element_value_should_be((By.CSS_SELECTOR, u'#valueTest input'), u'Element value is this', 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 example
QAutoRobot.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 example
using web element
QAutoRobot.wait_until_page_contains(u'Cell text is this')
using representation
QAutoRobot.wait_until_page_contains((u'Cell text is this')
using timeout
QAutoRobot.wait_until_page_contains(u'Cell text is this', 10)
QAutoRobot.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 example
using web element
QAutoRobot.wait_until_page_contain(u'Cell text is this')
using representation
QAutoRobot.wait_until_page_contain((u'Cell text is this')
using timeout
QAutoRobot.wait_until_page_contain(u'Cell text is this', 10)
QAutoRobot.wait_until_page_contain(u'Cell text is this', 10)
wait_until_spinner_is_not_visible(timeout=None)

Wait until page loading spinner is not visible

This method is already build in some of the common methods. Used locator for spinner element can be added in ‘/config/project_config/spinner_locators.txt’ file

Parameters

timeout – Uses default timeout, unless custom value provided.

Exception

If time exceeds DEFAULT_TIMEOUT, then rise exception.

Example
Page model level example
using web element
QAutoRobot.wait_until_spinner_is_not_visible()
using timeout
QAutoRobot.wait_until_spinner_is_not_visible(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 example
using web element
QAutoRobot.wait_until_table_size_changes(self.ID_TABLETEST)
using representation
QAutoRobot.wait_until_table_size_changes((By.ID, u'tableTest'))
using timeout
QAutoRobot.wait_until_table_size_changes(self.ID_TABLETEST, 10)
QAutoRobot.wait_until_table_size_changes((By.ID, u'tableTest'), 10)
warning(message)

Adds warning to test report

Parameters

message – Message to print as a String

Example
Page model level example
QAutoRobot.warning("My message")
class QAutoLibrary.QAutoSelenium.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)

# QAutomate Ltd 2020. All rights reserved. # # Copyright and all other rights including without limitation all intellectual property rights and title in or # pertaining to this material, all information contained herein, related documentation and their modifications and # new versions and other amendments (QAutomate Material) vest in QAutomate Ltd or its licensor’s. # Any reproduction, transfer, distribution or storage or any other use or disclosure of QAutomate Material or part # thereof without the express prior written consent of QAutomate Ltd is strictly prohibited. # # Distributed with QAutomate license. # All rights reserved, see LICENSE for details.

class QAutoLibrary.Cryptomodule.AESCipher(key)
decrypt(enc)
encrypt(raw)

# QAutomate Ltd 2020. All rights reserved. # # Copyright and all other rights including without limitation all intellectual property rights and title in or # pertaining to this material, all information contained herein, related documentation and their modifications and # new versions and other amendments (QAutomate Material) vest in QAutomate Ltd or its licensor’s. # Any reproduction, transfer, distribution or storage or any other use or disclosure of QAutomate Material or part # thereof without the express prior written consent of QAutomate Ltd is strictly prohibited. # # Distributed with QAutomate license. # All rights reserved, see LICENSE for details.

class QAutoLibrary.RpaLogger.RpaLogger
append_to_file(filename=None, to_save=None)
Parameters
  • filename – Path to the .json file where the information will be saved. Must be full path.

  • to_save – Information to save to the json file

Constructs a string based on the message and time and saves it to the filename under the robotname key

file_exists(filepath)
get_resource_data(field=None, robotname=None)

Get all robot saved data from robotResources

Parameters
  • robotname – String name of the robot (optional)

  • field – String name of document field (optional)

Returns

Robot resources whole document or only one field

Examples: | Robot level example | Get resource data | Get resource data | field=documentFieldName | Page model level example | QAutoRobot.get_resource_data(field="documentFieldName")"

get_rpa_executed_tasks(runid=None, robotname=None)

Get all tasks (tags) that robot has executed/saved

Parameters
  • runid – Integer id of robot run that was executed

  • robotname – String name of the robot that was executed

Returns

List of states (tags) that robot has executed/saved

Examples: | Get rpa executed tasks | runid=${RUNID} | robotname=${ROBOTNAME} | Get rpa executed tasks | ${RUNID} | ${ROBOTNAME}

log_data(**kwargs)
Parameters

**kwargs

**state (string): Current robot state (optional) **title (string): Current message title (optional) **msg (string): Message to be saved to logs (optional) ————- Examples: | Log data | state=ReadyReading | title=excelRead | msg=All reading completed | Log data | state=ReadyOngoing | | Log data | title=excelRead | msg=All reading failed | type=Warning | Log data | title=excelRead | msg=Generic error | type=Error

log_rpa(**kwargs)

DEPRECATED Use keyword Log data instead.

remove_resource_document(robotname=None)

Removes whole document from robot resources

Parameters

robotname – String name of the robot (optional)

Examples: | Robot level example | Remove resource document | Page model level example | QAutoRobot.remove_resource_document()

remove_resource_field(field_path, robotname=None)

Removes field from robot resources

Parameters
  • field_path – String path to field to remove (dot presentation)

  • robotname – String name of the robot (optional)

Examples: | Robot level example | Remove resource field | field.to.remove | Page model level example | QAutoRobot.remove_resource_field("field.to.remove")

remove_resource_list_value(field_path, list_value, robotname=None)

Removes field from robot resources

Parameters
  • field_path – String path to field to remove (dot presentation)

  • list_value – Any list value to remove

  • robotname – String name of the robot (optional)

Examples: | Robot level example | Remove resource list value | field.list.remove | list value | Page model level example | QAutoRobot.remove_resource_list_value("field.list.remove", "list value")

rpa_logger_init(filename=None, robotname=None, runid=1, mongodbIPPort='localhost:27017/', vmname='', username='', password='', sslbool=True)
Parameters
  • filename – Path to the .json file where the information will be saved. Mandatory

  • robotname – Name of the robot that generated the message to be saved Mandatory

  • mongodbIPPort – ip and port: e.g localhost:27017/ Mandatory

  • username – MongoDb username. Default empty. Optional

  • password – MongoDb password. Default empty. Optional

  • ssl – True or False. DefaultFalse. Optional

save_data(**kwargs)

Saves robot data to database

Parameters

**kwargs – 1..n named arguments

Examples: | Save data | MyDataName=MyDataValue | SecondDataName=SecondDataValue

save_resources(**kwargs)

Saves robot permanent data to database

Parameters

**kwargs – 1..n named arguments, if “robotname” in **kwargs it used to identify robot resource

Examples: | Robot level example | Save resources | MyDataName=MyDataValue | SecondDataName=SecondDataValue | Page model level example | QAutoRobot.save_resources(MyDataName=MyData)

save_rpa_data(**kwargs)

DEPRECATED Use keyword Save data instead.

set_custom_post_trigger(condition=True)

Save custom post trigger to database

If set True, other robot can be triggered, regardless of current robots result.

Param

condition: Boolean to set custom post trigger on/off. Default True.

Examples: | Set custom post trigger | True | Set custom post trigger | ${TRUE} | Set custom post trigger | ${FALSE}

set_savings_multiply(value)

Save savings multiply to database

This value will be used to calculate robot savings. If set 0 (zero), robot has not done any actual savings.

Param

value: Integer.

Examples: | Set savings multiply | 2 | Set savings multiply | 0

setup_data(runid=None, robotname=None)

Setup robot data from database

Parameters
  • runid – Integer id of robot run

  • robotname – String name of the robot that is running

Examples: | Setup data | runid=${RUNID} | robotname=${ROBOTNAME} | Setup data | ${RUNID} | ${ROBOTNAME}

setup_rpa_data(runid=None, robotname=None)

DEPRECATED Use keyword Setup data instead.