def perform_as(self, actor: Actor):
        assert save_screenshot.path is not None, "capture_screenshot.path not set before trying to capture a screenshot"
        filename = path.join(save_screenshot.path, str(self._index) + '.png')

        actor.attempts_to(
            save_screenshot_to_file(filename)
        )
Exemple #2
0
 def perform_as(self, actor: Actor):
     if self._id is not None:
         value = actor.state[self._id].value
         matched = False
         for required_value in self._values:
             if value == required_value:
                 matched = True
         if matched is False:
             actor.attempts_to(*self._actions)
Exemple #3
0
def test_The_log_indent_is_restored_if_a_test_fails():
    user = Actor('user')

    Log.to_actions()
    original_indent = _LogIndent.current_indent

    try:
        user.attempts_to(failing_task())
    except AssertionError:
        pass

    assert original_indent == _LogIndent.current_indent, 'The indent was not reset if an action fails'
def test_an_attempted_out_of_bounds_access_causes_an_assertion():
    user = Actor('user')
    user.state['list'].set(['a'])

    with pytest.raises(AssertionError) as exception:
        user.attempts_to(
            select_element_at_index(1).from_stored_list('list').and_store_in(
                'found'))

    expected = "'list' does not have enough elements to access element 1"
    actual = exception.value.args[0]

    assert actual == expected, "Incorrect message\nExpected: {expected}\nActual:{actual}".format(
        expected=expected, actual=actual)
Exemple #5
0
def test_The_log_indent_is_not_increased_by_actions_if_only_logging_to_tasks():
    user = Actor('user')

    Log.to_tasks()

    start_indent = _LogIndent.current_indent

    action = record_log_indent_action()
    task = record_log_indent_task(action)

    user.attempts_to(task)

    assert task.indent == start_indent + 2, 'Task not indented correctly'
    assert action.indent == start_indent + 2, 'Action not indented correctly'
def capture_log_messages(user: Actor, *actions):
    original_log_function = Log.write_line
    log_text = []

    def write_line(*values, sep=''):
        line = sep.join(map(str, chain.from_iterable(values)))
        log_text.append(line)

    Log.write_line = write_line

    try:
        user.attempts_to(*actions)
    finally:
        Log.write_line = original_log_function

    return log_text
def test_selecting_an_element_from_a_stored_list_returns_the_value_and_stores_it_in_the_actors_state():
    user = Actor('user')
    user.state['list'].set(['a', 'b', 'c', 'd'])

    returned_value = user.attempts_to(
        select_element_at_index(1).from_stored_list('list').and_store_in('found')
    )

    assert returned_value == 'b', "Returned value was incorrect"
    assert user.state['found'].value == 'b', "Stored value was incorrect"
 def perform_as(self, actor: Actor):
     actor.attempts_to(
         enter_text(self._text).into_element(
             google_homepage.search_textbox),
         send_enter_key_to().element(google_homepage.search_textbox))
Exemple #9
0
 def perform_as(self, actor: Actor):
     self.indent = _LogIndent.current_indent
     actor.attempts_to(*self.actions)
 def perform_as(self, actor: Actor):
     actor.attempts_to(
         navigate_to('https://www.google.co.uk')
     )
Exemple #11
0
 def perform_as(self, actor: Actor):
     actor.attempts_to(
         # A parameter list of Action objects
     )
 def perform_as(self, actor: Actor):
     assert self.id is not None, "No id specified for Using"
     actor.state[self.id].set(actor.attempts_to(
         self.task_or_action
     ))