cyan API

Sub Modules

cyan.data

cyan.dom


This module contains the functionality that related to DOM tree like:
  • Finding DOM’s elements.
  • Checking the elements state (Present, visible,..etc.)

all_windows_closed() → bool
click_Calendar(dateToChangeTo)

change the day/month/year on the calendar pop up as expected format for dateToChangeTo is Mon 21 May, 2014

:rtype : object

element_text_available_callback(element_text: str, element: str, by: By = 'css selector')
Parameters:
  • element_text
  • element
  • by
Returns:

execute_script(script, ele)
get_browser() → WebDriver

Get the shared web driver.

Returns:The web driver
Return type:WebDriver
get_drop_down_selected_value(drop_down_id)
get_element(search_filter: str, by: By = 'css selector') → WebElement

Get an element by its identifier.

Parameters:
  • search_filter – The element identifier to search by
  • by – Element’s filter type
Returns:

Return type:

WebElement

get_element_by_angular_model(model_name: str, element_tag: str = '*', angular_prefix: str = 'ng') → WebElement

Get DOM element by its AngularJs model’s binding.

Parameters:
  • model_name – Angular model binding name
  • element_tag – The element’s html tag
  • angular_prefix – angular html data prefix
  • element_tag – DOM element’s tag
Returns:

The element

get_element_by_attribute(attribute_name: str, attribute_value: str, element_tag: str = '*', search_type: cyan.common.TextSearchType = <TextSearchType.Exact: 1>) → WebElement

Get DOM element by its attribute.

Parameters:
  • attribute_name – Attribute name
  • attribute_value – Attribute value
  • element_tag – DOM element’s tag
Returns:

The element

get_element_by_text(value: str, tag: str = '*', search_type: cyan.common.TextSearchType = <TextSearchType.Contain: 4>) → WebElement

Get DOM element by its text.

Parameters:
  • value
  • search_type
Returns:

get_element_by_value(value: str, search_type: cyan.common.TextSearchType = <TextSearchType.Contain: 4>) → WebElement

Get DOM element by its value.

Parameters:value – Element’s value
Returns:The element
get_elements(search_filter: str, by: By = 'css selector')

Get all element by its identifier.

Parameters:
  • search_filter – The elements identifier to search by
  • by – element filter type
Returns:

get_facet_element(facet: <string>, value: <string>)

Select a value from a faceted search facet

get_growl_message()
get_label_by_partial_text(label_text: str) → WebElement

Get a label by its partial text.

Parameters:label_text – label’s partial text
Returns:The found label as WebElement
get_label_by_text(label_text: str, search_type: cyan.common.TextSearchType = <TextSearchType.Exact: 1>) → WebElement

Get a label by its text.

Parameters:label_text – label’s text
Returns:The found label as WebElement

Get a link by its text.

Parameters:label_text – label’s text
Returns:The found label as WebElement
is_element_disabled(css: str) → bool

Checks if the element has the ‘disabled’ class attached to the element.

Parameters:css
Returns:
is_element_enabled(search_filter: str, element_by: By = 'css selector') → bool
is_element_present(search_filter: str, element_by: By = 'css selector') → bool

Check the present of an element on the current page.

Parameters:
  • search_filter – the element filter value:
  • element_by – the element filter type
is_element_selected(search_filter: str, element_by: By = 'css selector') → bool

To check if a tick box is selected.

Parameters:
  • search_filter
  • element_by
Returns:

is_element_visible(search_filter: str, element_by: By = 'css selector') → bool
is_element_visible_attr(attr_name: str, attr_value: str, tag: str = 'input') → bool
is_element_visible_text(element_text: str) → bool
is_print_dialog_present(timeout: int = 5) → bool
is_web_element_selected(element: WebElement) → bool

To check if a tick box is selected.

Parameters:element
Returns:
is_web_element_visible(element) → bool
screen_shot(file_name: str, file_directory: str = './Screenshots')

takes a screen-shot of the current web page and saves. If the specified folder don’t exists, it will be created

Parameters:
  • file_name – name of the file to be saved. The current time in the format YYYYMMDD_HHMMSS will be added as suffix to the file name
  • file_directory – destination folder
scroll_down()

scroll to the bottom of the page

scroll_down_by(distance: int)
scroll_element_into_view(elementWe)
scroll_to_bottom()

takes a screenshot of the current web page and saves it in a folder called Screenshots.

scroll_to_top()

Scrolls the page to the top.

scroll_up(distance)
select_from_add(css: str, name: str)

Enter the ‘name’ in the search text box then click on ‘Enter’ to select

Parameters:
  • css
  • name
select_from_dropdown(xpath: str, selection: str)
select_from_dropdown_CSS(css: str, selection: str)
send_browser_key(key: selenium.webdriver.common.keys.Keys)
validate_element(element: WebElement)
wait(timer: int)
wait_for_element_enabled(search_filter, element_by: By = 'css selector', timer: int = 10, msg: str = 'Waiting for element timed out')

Wait for an element to be enabled on the page.

Parameters:
  • search_filter – The element identifier to search by
  • timer – time to wait before it through a timeout error
  • element_by – element filter type
wait_for_text_present(text_to_present: str, text_element: str, by: By = 'css selector', timer: int = 10)

Wait for a string literal to be present on the page.

Parameters:
  • text_to_present – The string to wait for its present
  • text_element – The dom element whose has the string as its value.
  • timer – Time to wait before it’s timeout
  • by – The string’s attribute
wait_non_visibility_of_element(search_filter, element_by: By = 'css selector', timer: int = 10, msg: str = 'Waiting for element timed out')

Wait for an element to be loaded and become visible on the page.

Parameters:
  • search_filter – The element identifier to search by
  • timer – time to wait before it through a timeout error
  • element_by – element filter type
wait_presence_of_element(search_filter, by: By = 'css selector', timer: int = 10)

Wait for an element to be loaded on the page

Parameters:
  • search_filter – The element identifier to search by
  • timer – time to wait before it through a timeout error
  • by – element filter type
wait_presence_of_element_by_text(element_text: str, timer: int = 10, search_type: cyan.common.TextSearchType = <TextSearchType.Contain: 4>)

Wait for an element to be loaded on the page

Parameters:
  • search_type
  • element_text – The element text to search by
  • timer – time to wait before it through a timeout error
wait_visibility_of_element(search_filter, element_by: By = 'css selector', timer: int = 10, msg: str = 'Waiting for element timed out')

Wait for an element to be loaded and become visible on the page.

Parameters:
  • msg
  • search_filter – The element identifier to search by
  • timer – time to wait before it through a timeout error
  • element_by – element filter type
wait_visibility_of_element_by_text(element_text: str, timer: int = 10, msg: str = 'Waiting for element timed out', search_type: cyan.common.TextSearchType = <TextSearchType.Contain: 4>)

Wait for an element to be loaded and become visible on the page.

Parameters:
  • search_type
  • element_text – The element’s text to search by
  • timer – time to wait before it through a timeout error
  • msg – Message to fire when timeout error thrown
wait_visibility_of_ng_element(model_name: str, timer: int = 10, element_tag: str = '*', angular_prefix: str = 'ng', msg: str = 'Waiting for element timed out')

Wait for an element to be loaded and become visible on the page.

Parameters:
  • model_name – Angular model binding name
  • element_tag – The element’s html tag
  • angular_prefix – angular html data prefix
  • element_tag – DOM element’s tag
  • timer – time to wait before it through a timeout error
  • msg – Message to fire when timeout error thrown

cyan.input

add_days(days: int)
check_notification(message: <string>)
Parameters:message
clear_select2_by_css(search_filter: <string>, by: By = 'css selector')

Clicks the little ‘x’ in a Cosacs select2 based on a css selector for the select2

Parameters:
  • search_filter – The element identifier to search by
  • by – Element filter type
clear_select2_by_label(label_text)

Clicks the little ‘x’ in a Cosacs drop down based on id

clear_textbox(textbox_filter: <string>, by: By = 'css selector', submit: bool = True)
click_button(button_text: <string>, tag: str = 'button')

Click on a button by its display text.

Parameters:button_text – The button’s display text
click_button_by_id(button_id: <string>)

Click on a button by its id.

Parameters:button_id – The button’s id
click_element(search_filter: <string>, by: By = 'css selector')

Click on element.

:rtype : object :param search_filter: The element identifier to search by :param by: element filter type

click_on_element(element_to_click: WebElement)

Perform a click on an element

Parameters:element_to_click – element to click
click_on_span_element(element_to_click: WebElement)

Perform a click on an element

Parameters:element_to_click – element to click
close_notification()
fill_text_boxes_by_attribute_value(values: dict, attr_name: <string> = '@placeholder')

Write to a series of textbox by trier attribute values.

Parameters:
  • values – Dictionary of ‘attribute values’ with corresponded text to write
  • attr_name – The attribute name to filter with
fill_text_boxes_by_labels_text(labels)

Write to a series of textbox by tier label texts.

Parameters:labels – The textbox’ label texts
fill_textbox_by_attribute_value(value_to_fill: <string>, attr_value: <string>, attr_name: <string> = '@placeholder')

Write to a textbox by its attribute value.

Parameters:
  • value_to_fill – Text to write into the text box
  • attr_value – Which attribute value to filter with
  • attr_name – the attribute name
fill_textbox_by_label_text(label_text, value_for_textbox, search_type: cyan.common.TextSearchType = <TextSearchType.Exact: 1>)

Write to a textbox by its label text.

Parameters:
  • label_text – The textbox’ label text
  • value_for_textbox – The text to write
focus_on_element(element_to_focus: WebElement)
get_element_attribute(search_filter: <string>, attribute: <string>, by: By = 'css selector') → <string>

Get an element’s attribute value by its identifier.

:rtype : object :param search_filter: The element identifier to search by :param attribute: the target attribute name :param by: element filter type :return:

get_element_value(search_filter: <string>, by: By = 'css selector') → <string>

Get an element’s value by its identifier.

:rtype : object :param search_filter: The element identifier to search by :param by: element filter type :return:

hover_on_element(element_to_hover: WebElement)
radio_button_select_value(radio_button_tag: <string>)
select2_set_value(grayed_text: <string>, value: <string>)
Parameters:
  • grayed_text – the grayed text inside the select2.
  • value – value to set to the select2
select2_set_value_ex(grayed_text: <string>, value: <string>)
Parameters:
  • grayed_text – the grayed text inside the BlueBridge select2
  • value – value to set to the select2
select2_set_value_filter(value: <string>, search_filter: <string>, by: By = 'css selector')
Parameters:
  • value – value to set to the select2
  • search_filter – The element identifier to search by (div expected)
  • by – element filter type
select_set_value(value: str, search_type: cyan.common.TextSearchType = <TextSearchType.Contain: 4>)

Select a value from a drop down list by passing the string text of that value :param value:

set_drop_down_text_by_model(ng_model: str, value: str, search_type: cyan.common.TextSearchType = <TextSearchType.Contain: 4>)
set_drop_down_value_by_model(ng_model: str, value: str, search_type: cyan.common.TextSearchType = <TextSearchType.Contain: 4>)
set_list_value(value: str, list_filter: str, filter_type: cyan.common.ListFilterType = <ListFilterType.NgModel: 2>, search_type: cyan.common.TextSearchType = <TextSearchType.Contain: 4>)

Select a list item of the ‘list’ drop-down directive by the passed value :param value: The list item value to select :param list_filter: The ‘list’ directive filter value :param filter_type: Type of the list filter

set_select_value_by_text(place_holder_text: <string>, sel_text: <string>)
write_on_element(text: <string>, element: WebElement)

:rtype : object

write_on_ng_textbox(text: str, model_name: str, element_tag: str = '*', angular_prefix: str = 'ng')

Write on a textbox element using Angular model name.

Parameters:
  • text – The text to write
  • model_name – Angular model binding name
  • element_tag – The element’s html tag
  • angular_prefix – angular html data prefix
  • element_tag – DOM element’s tag
write_on_textbox(text: <string>, search_filter: <string>, by: By = 'css selector')

Write on a textbox element.

Parameters:
  • text – The text to write
  • search_filter – The element identifier to search by
  • by – element filter type

cyan.nav

class MenuItem(title, url)

Bases: object

__init__(title, url)
cascade_menu(parent_item, nameHover_item, child_item)
Parameters:
  • parent_item – The Parent Menu Item (Link Text)
  • CSSHover_item – The Hover Menu Item (Text that is displayed)
  • child_item – The child menu item that is wanted (Link Text)
Returns:

get_all_menu_options(parent_item: <string>)

Uses the parent menu name to return a list of all the sub menu’s that are available including sub menu’s.

Parameters:parent_item
Returns:
get_current_url()
get_main_menu() → list
get_menu_item(ele: WebElement) → cyan.nav.MenuItem
Parameters:ele
Returns:
get_menu_options(parent_item: <string>)

Uses the parent menu name to return a list of all the sub menu’s that are available.

Parameters:parent_item
Returns:
go(url: <string>, is_route: bool = True)

Navigate to a specific Url.

Parameters:url – The url to go to. It can a relative or absolute url.
go_home()

Navigate to the Home page

go_to_profile()

Navigate to the user profile page

logout_quit_browser()

Closes the current session by logging out and close the browser

menu(parent_item: <string>, child_item: <string>)

Click on a navigation menu item (only work on a 2 level menu).

Parameters:
  • parent_item – The parent menu item
  • child_item – The sub menu item
menu_CSS(parent_item: <string>, child_item: <string>)
Parameters:
  • parent_item – The Parent Menu Item (Link Text)
  • child_item – The child menu item that is wanted (Link Text)
Returns:

multi_menu(menu_hierarchy: <string>, delimiter: <string> = ', ')

Click on a navigation menu item (work on multi levels menu) :param menu_hierarchy: The menu item hierarchy as string separated by delimiter :param delimiter: The delimiter that separate the menu items

quit_browser()

Close the browser window

refresh()

Refresh current page

cyan.security

check_self(check_logging: bool = True)
get_config_path()
get_driver_path(driver_name: str)
get_project_path()
init_class(config_path: str = '')
is_logged()
login(user: str = None, password: str = None, config_path: str = '')

Log in into Cosacs application.

Parameters:
  • user – User name
  • password – Password

Todo: Check if already logged | store u and pw

logout()

Log off

Module contents