Skip to content

Commit

Permalink
Merge pull request #71 from botcity-dev/TST/tests-to-keyboard-mouse-v…
Browse files Browse the repository at this point in the history
…ision

TST: Expand tests to keyboard, mouse and vision
  • Loading branch information
hhslepicka committed Nov 23, 2022
2 parents a2d9f11 + a2658c8 commit 4af5239
Show file tree
Hide file tree
Showing 5 changed files with 472 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ jobs:

- name: Run Tests in ${{ matrix.browser }}
run: |
pytest -v -vrxs --headless=${{ matrix.headless }} --browser=${{ matrix.browser }}
pytest -n 2 -v -vrxs --headless=${{ matrix.headless }} --browser=${{ matrix.browser }}
1 change: 0 additions & 1 deletion tests/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

def test_create_tab(web: WebBot):
web.browse(conftest.INDEX_PAGE)

title = web.page_title()
assert title == 'Botcity - web test'

Expand Down
161 changes: 161 additions & 0 deletions tests/test_keyboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
import conftest

from botcity.web import WebBot


def test_control_a(web: WebBot):
web.browse(conftest.INDEX_PAGE)
web.control_a()

result = conftest.get_event_result('element-result', web)
if conftest.OS_NAME == 'Darwin':
assert result['data'] == ['Meta', 'a']
else:
assert result['data'] == ['Control', 'a']


def test_control_c(web: WebBot):
web.browse(conftest.INDEX_PAGE)
web.control_c()

assert web.get_clipboard() == 'Botcity'


def test_enter(web: WebBot):
web.browse(conftest.INDEX_PAGE)
web.enter()

result = conftest.get_event_result('element-result', web)
assert result['data'] == ['Enter']


def test_control_v(web: WebBot):
web.browse(conftest.INDEX_PAGE)
web.copy_to_clipboard(text='botcity-paste')
web.control_v()

result = conftest.get_event_result('element-result', web)
assert ''.join(result['data']) == 'botcity-paste'


def test_delete(web: WebBot):
web.browse(conftest.INDEX_PAGE)
web.delete()

result = conftest.get_event_result('element-result', web)
assert result['data'] == ['Delete']


def test_key_end(web: WebBot):
web.browse(conftest.INDEX_PAGE)
web.key_end()

result = conftest.get_event_result('element-result', web)
assert result['data'] == ['End']


def test_key_esc(web: WebBot):
web.browse(conftest.INDEX_PAGE)
web.key_esc()

result = conftest.get_event_result('element-result', web)
assert result['data'] == ['Escape']


def test_key_home(web: WebBot):
web.browse(conftest.INDEX_PAGE)
web.key_home()

result = conftest.get_event_result('element-result', web)
assert result['data'] == ['Home']


def test_type_keys(web: WebBot):
web.browse(conftest.INDEX_PAGE)
web.type_keys(['a', 'b', 'c'])

result = conftest.get_event_result('element-result', web)
assert result['data'] == ['a', 'b', 'c']


def test_type_down(web: WebBot):
web.browse(conftest.INDEX_PAGE)
web.type_down()

result = conftest.get_event_result('element-result', web)
assert result['data'] == ['ArrowDown']


def test_type_left(web: WebBot):
web.browse(conftest.INDEX_PAGE)
web.type_left()

result = conftest.get_event_result('element-result', web)
assert result['data'] == ['ArrowLeft']


def test_type_right(web: WebBot):
web.browse(conftest.INDEX_PAGE)
web.type_right()

result = conftest.get_event_result('element-result', web)
assert result['data'] == ['ArrowRight']


def test_type_up(web: WebBot):
web.browse(conftest.INDEX_PAGE)
web.type_up()

result = conftest.get_event_result('element-result', web)
assert result['data'] == ['ArrowUp']


def test_backspace(web: WebBot):
web.browse(conftest.INDEX_PAGE)
web.backspace()

result = conftest.get_event_result('element-result', web)
assert result['data'] == ['Backspace']


def test_hold_shift(web: WebBot):
web.browse(conftest.INDEX_PAGE)
web.hold_shift()
web.kb_type('a')
web.release_shift()
web.kb_type('a')

result = conftest.get_event_result('element-result', web)
assert result['data'] == ['Shift', 'A', 'a']


def test_space(web: WebBot):
web.browse(conftest.INDEX_PAGE)
web.space()

result = conftest.get_event_result('element-result', web)
assert result['data'] == ['Space']


def test_page_down(web: WebBot):
web.browse(conftest.INDEX_PAGE)
web.page_down()

result = conftest.get_event_result('element-result', web)
assert result['data'] == ['PageDown']


def test_page_up(web: WebBot):
web.browse(conftest.INDEX_PAGE)
web.page_up()

result = conftest.get_event_result('element-result', web)
assert result['data'] == ['PageUp']


def test_key_tab(web: WebBot):
web.browse(conftest.INDEX_PAGE)
web.tab()

result = conftest.get_event_result('element-result', web)
assert result['data'] == ['Tab']

0 comments on commit 4af5239

Please sign in to comment.