toolkit.helpers.bdd – BDD helpers

toolkit.helpers.bdd.bdd.assert_text_in_table(browser, values, date_format='%m/%d/%Y')

Asserts that a list of values exists in table rows on the page

Parameters:
  • browser – browser object
  • values (list) – list of values
  • date_format (string) – optional field to specify a specific string format for date values sent in the values list
toolkit.helpers.bdd.bdd.assert_text_not_in_table(browser, values, date_format='%m/%d/%Y')

Asserts that a list of values does not exist in table rows on the page

Parameters:
  • browser – browser object
  • values (list) – list of values
  • date_format (string) – optional field to specify a specific string format for date values sent in the values list
toolkit.helpers.bdd.bdd.assert_text_on_page(browser, values, date_format='%m/%d/%Y')

Asserts that a list of values does exist on the page

Parameters:
  • browser – browser object
  • values (list) – list of values
  • date_format (string) – optional field to specify a specific string format for date values sent in the values list
toolkit.helpers.bdd.bdd.click_element_by_name(browser, name, index=0)

Clicks an element in the DOM by the element name

Parameters:
  • browser – browser object
  • name (string) – name of element
  • index (integer) – index of the element in the DOM
toolkit.helpers.bdd.bdd.compare_content_types(browser, context, file_type)

Attempts to find the download link, request the file and asserts that the file extension matches the expected file type

toolkit.helpers.bdd.bdd.fill_and_submit_form(browser, fields, submit_button_name='submit')

Fills a dictionary of form fields on a page and clicks the submit button

Parameters:
  • browser – browser object
  • fields – iterable of fields
  • submit_button_name (string) – optional button name field in case there’s multiple buttons on the page
toolkit.helpers.bdd.bdd.fill_form(browser, fields)

Fills a dictionary of form fields on a page

Parameters:
  • browser – browser object
  • fields – iterable of fields
toolkit.helpers.bdd.bdd.get_file_content_type(extension)
Parameters:extension (string) – file extension
Returns string:mime type based on file extension
toolkit.helpers.bdd.bdd.log(context, text)

logs text in the js console

toolkit.helpers.bdd.bdd.scroll_to_top(browser)

executes the following js code on the page: window.scrollTo(0, 0)

toolkit.helpers.bdd.bdd.set_test_obj(context, model)

Sets the test object

toolkit.helpers.bdd.bdd.set_test_obj_pk(context)

Sets the test object pk

toolkit.helpers.bdd.utils.setup_test_environment(context, scenario, visible=0, use_xvfb=True)
Method used to setup the BDD test environment
  • Sets up virtual display
  • Sets up webdriver instance
  • Sets window size
  • Flushes cookies
  • Enables debug (Allows for more verbose error screens)
  • Sets scenario
  • Truncates database tables
Options:
  • visible (0 or 1) - Toggle Xephyr to view the Xvfb instance for limited debugging. 0: Off, 1: On.
  • use_xvfb (True/False) - Toggle Xvfb to run the tests on your desktop for in-depth debugging.
toolkit.helpers.bdd.shared_steps.log_in_as(context, user)

Allows you to log in as a user in the system. I am logged in as (.*)

Parameters:
  • context (object) – behave’s global object
  • user (string) – user in the system
Usage:
1
2
Scenario Outline: Manage applications
    Given I am logged in as manager
toolkit.helpers.bdd.shared_steps.visit_page(context, url_name)

Allows you to visit a page in the system. I visit (.*)

Parameters:
  • context (object) – behave’s global object
  • url_name (string) – url name to visit
Usage:
1
2
3
Scenario Outline: Manage applications
    Given I am logged in as manager
    When I visit manage_application
toolkit.helpers.bdd.shared_steps.verify_navigation(context, url_names)

Allows you to find a link on the current page

Parameters:
  • context (object) – behave’s global object
  • url_names (string) – url name(s) to visit, add comma between url name if there’s more than one
Usage:
1
2
3
4
Scenario Outline: Manage applications
    Given I am logged in as manager
    When I visit manage_application
    Then I should find a link to add_application
toolkit.helpers.bdd.shared_steps.verify_post_form(context, should_not, url_name)

Allows you know if there’s a form that can be posted to a certain place on the page. I should( not)? find a form that posts to (.*)

Parameters:
  • context (object) – behave’s global object
  • should_not (string) – include “not” if the form should not be found
  • url_name (string) – url name to visit
Usage 1:
1
2
3
4
5
Scenario Outline: Manage applications
    Given I am logged in as manager
    And I have a valid submitted application
    When I visit view_application
    Then I should find a form that posts to approve_application
Usage 2:
1
2
3
4
5
Scenario Outline: Manage applications
    Given I am logged in as manager
    And I have a valid application
    When I visit view_application
    Then I should not find a form that posts to approve_application
toolkit.helpers.bdd.shared_steps.verify_file_download(context, should_or_shouldnt, file_type)

Allows you to compare the file download type. I (should|shouldn’t) receive a (.*) file download

Parameters:
  • context (object) – behave’s global object
  • should_or_shouldnt (string) – should or shouldn’t
  • file_type (string) – file type
Usage:
1
2
3
4
5
Scenario: Download as .docx
    Given I am logged in as manager
    And I have valid applications
    When I go to application_report
    Then I should receive a docx file download