From d5e4e8f33aaec08b10d2aaf8f0b3263da5d38893 Mon Sep 17 00:00:00 2001 From: Vinyzu <50874994+Vinyzu@users.noreply.github.com> Date: Sat, 20 Apr 2024 20:14:33 +0200 Subject: [PATCH] Small Test Fixes & ReadMe Update --- README.md | 4 ++-- tests/test_async_driverless.py | 2 ++ tests/test_async_playwright.py | 4 ++++ tests/test_selenium.py | 5 +++++ tests/test_sync_driverless.py | 4 ++++ tests/test_sync_playwright.py | 6 +++--- 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4651424..3705536 100644 --- a/README.md +++ b/README.md @@ -17,14 +17,14 @@ PyPI
- + - + diff --git a/tests/test_async_driverless.py b/tests/test_async_driverless.py index 3403714..4dcf423 100644 --- a/tests/test_async_driverless.py +++ b/tests/test_async_driverless.py @@ -157,6 +157,8 @@ async def test_keyboard_type_into_a_textarea(async_driver: Chrome) -> None: @pytest.mark.asyncio async def test_quit_exception(async_driver: Chrome) -> None: await async_driver.quit() + await asyncio.sleep(5) + with pytest.raises(WindowClosedException): await async_driver.async_input.down("left", 100, 100, emulate_behaviour=False) with pytest.raises(WindowClosedException): diff --git a/tests/test_async_playwright.py b/tests/test_async_playwright.py index 3b29494..b5d5a76 100644 --- a/tests/test_async_playwright.py +++ b/tests/test_async_playwright.py @@ -1,3 +1,5 @@ +import asyncio + import pytest from playwright.async_api import Locator, Page @@ -210,6 +212,8 @@ async def test_keyboard_type_into_a_textarea(async_page: Page) -> None: @pytest.mark.asyncio async def test_quit_exception(async_page: Page) -> None: await async_page.close() + await asyncio.sleep(5) + with pytest.raises(WindowClosedException): await async_page.async_input.down("left", 100, 100, emulate_behaviour=False) # type: ignore[attr-defined] with pytest.raises(WindowClosedException): diff --git a/tests/test_selenium.py b/tests/test_selenium.py index 91697e7..44f650a 100644 --- a/tests/test_selenium.py +++ b/tests/test_selenium.py @@ -1,3 +1,5 @@ +import time + import pytest from selenium.webdriver import Chrome from selenium.webdriver.common.by import By @@ -40,6 +42,7 @@ def test_input_leak(selenium_driver: Chrome, server: Server) -> None: x, y = get_locator_pos(sync_locator) selenium_driver.sync_input.click("left", x, y) # type: ignore[attr-defined] + time.sleep(2) is_leaking = selenium_driver.execute_async_script("window.is_leaking.then(arguments[arguments.length - 1])") assert not is_leaking @@ -145,6 +148,8 @@ def test_keyboard_type_into_a_textarea(selenium_driver: Chrome) -> None: def test_quit_exception(selenium_driver: Chrome) -> None: selenium_driver.quit() + time.sleep(5) + with pytest.raises(WindowClosedException): selenium_driver.sync_input.down("left", 100, 100, emulate_behaviour=False) # type: ignore[attr-defined] with pytest.raises(WindowClosedException): diff --git a/tests/test_sync_driverless.py b/tests/test_sync_driverless.py index 867b81b..07872f4 100644 --- a/tests/test_sync_driverless.py +++ b/tests/test_sync_driverless.py @@ -1,3 +1,5 @@ +import time + import pytest from selenium_driverless.sync.webdriver import Chrome from selenium_driverless.types.by import By @@ -147,6 +149,8 @@ def test_keyboard_type_into_a_textarea(sync_driver: Chrome) -> None: def test_quit_exception(sync_driver: Chrome) -> None: sync_driver.quit() + time.sleep(5) + with pytest.raises(WindowClosedException): sync_driver.sync_input.down("left", 100, 100, emulate_behaviour=False) with pytest.raises(WindowClosedException): diff --git a/tests/test_sync_playwright.py b/tests/test_sync_playwright.py index e71ea9f..1339830 100644 --- a/tests/test_sync_playwright.py +++ b/tests/test_sync_playwright.py @@ -1,3 +1,5 @@ +import time + import pytest from playwright.sync_api import Locator, Page @@ -201,9 +203,7 @@ def test_keyboard_type_into_a_textarea(sync_page: Page) -> None: def test_quit_exception(sync_page: Page) -> None: sync_page.close() - import time - - time.sleep(2) + time.sleep(5) with pytest.raises(WindowClosedException): sync_page.sync_input.down("left", 100, 100, emulate_behaviour=False) # type: ignore[attr-defined]