# Interactive Testing¶

In some circumstances tests can not be completely automated.

This feature can be used to script and revision manual tests for example.

## Solve Arithmetic Problems¶

This demo lets you solve arithmetic problems.

The demo is located in `interaction/test_solve_arithmetic_problems.py`.

```# -*- coding: utf-8 -*-
#
# Copyright (c) 2020, HILSTER Testing Solutions GmbH, Germany - https://hilster.io
#

import htf
from operator import add, sub, mul
from random import randint, choice

def test_solve_arithmetic_problems(interaction, assertions):
"""
This test shows how to interactively solve simple arithmetic problems.

Args:
interaction (htf.fixtures.interaction): the interaction fixture
assertions (htf.fixtures.assertions): the assertions fixture
"""
try:
for number_solved in range(1, 6):  # max 5 equations can be solved
a, b = randint(1, 10), randint(1, 10)  # pick two random numbers
operator, func = choice([('+', add), ('-', sub), ('*', mul)])  # pick a random operator
text="{} {} {} = ?".format(a, operator, b),
validator=htf.int_validator)  # only accept valid integers as inputs

if number_solved < 5:
again = interaction.yes_no_dialog(title='Again',
text="Would you like to solve another one?")
if again == 'no':  # stop if the user has had enough
break
except AssertionError:
number_solved -= 1
raise
finally:
interaction.message_dialog(title='Congratulations', text="You solved {} equations!".format(number_solved))

if __name__ == '__main__':
htf.main(interactive=True)
```

To use interactive mode, add `-i` to the htf call.

```cd interaction
htf -i -o test_solve_arithmetic_problems.py
```

The dialogs will appear in the test report afterwards.

This demo lets you solve captchas.

It is located in `interaction/test_captcha_solver.py`.

```# -*- coding: utf-8 -*-
#
# Copyright (c) 2020, HILSTER Testing Solutions GmbH, Germany - https://hilster.io
#

import htf
from random import randint

"""
This test shows how to interactively solve captchas.

Args:
interaction (htf.fixtures.interaction): the interaction fixture
assertions (htf.fixtures.assertions): the assertions fixture
"""
try:
for number_solved in range(1, 6):  # max 5 captchas can be solved

"""

if number_solved < 5:
again = interaction.yes_no_dialog(title='Again',
text="Would you like to solve another one?")
if again == 'no':  # stop if the user has had enough
break
except AssertionError:
number_solved -= 1
raise
finally:
To use interactive mode add `-i` to the htf call.
```cd interaction