| 1 |
import pytest |
| 2 |
from webdriver.bidi.error import InvalidSessionIDError |
| 3 |
|
| 4 |
pytestmark = pytest.mark.asyncio |
| 5 |
|
| 6 |
|
| 7 |
@pytest.mark.parametrize("marionette_enabled", [False, True]) |
| 8 |
async def test_with_marionette_enabled( |
| 9 |
new_session, add_browser_capabilities, bidi_client, marionette_enabled |
| 10 |
): |
| 11 |
bidi_session = await new_session( |
| 12 |
capabilities={"alwaysMatch": add_browser_capabilities({})}, |
| 13 |
browser_args={"use_marionette": marionette_enabled}, |
| 14 |
) |
| 15 |
|
| 16 |
await bidi_session.session.end() |
| 17 |
|
| 18 |
# Connect the client again. |
| 19 |
not_active_bidi_session = await bidi_client( |
| 20 |
current_browser=bidi_session.current_browser |
| 21 |
) |
| 22 |
|
| 23 |
# Make sure that command will fail, since the session was closed. |
| 24 |
with pytest.raises(InvalidSessionIDError): |
| 25 |
await not_active_bidi_session.session.end() |
| 26 |
|
| 27 |
# Make sure that session can be created. |
| 28 |
response = await not_active_bidi_session.session.status() |
| 29 |
assert response["ready"] is True |
| 30 |
|
| 31 |
|
| 32 |
async def test_start_session_again(new_session, add_browser_capabilities): |
| 33 |
bidi_session = await new_session( |
| 34 |
capabilities={"alwaysMatch": add_browser_capabilities({})} |
| 35 |
) |
| 36 |
first_session_id = bidi_session.session_id |
| 37 |
|
| 38 |
await bidi_session.session.end() |
| 39 |
|
| 40 |
# Try to create a session again |
| 41 |
bidi_session = await new_session( |
| 42 |
capabilities={"alwaysMatch": add_browser_capabilities({})} |
| 43 |
) |
| 44 |
|
| 45 |
assert isinstance(bidi_session.session_id, str) |
| 46 |
assert first_session_id != bidi_session.session_id |
| 47 |
|
| 48 |
|
| 49 |
async def test_send_the_command_after_session_end( |
| 50 |
new_session, add_browser_capabilities, bidi_client |
| 51 |
): |
| 52 |
bidi_session = await new_session( |
| 53 |
capabilities={"alwaysMatch": add_browser_capabilities({})}, |
| 54 |
) |
| 55 |
|
| 56 |
await bidi_session.session.end() |
| 57 |
|
| 58 |
# Connect the client again. |
| 59 |
not_active_bidi_session = await bidi_client( |
| 60 |
current_browser=bidi_session.current_browser |
| 61 |
) |
| 62 |
|
| 63 |
# Make sure that command will fail, since the session was closed. |
| 64 |
with pytest.raises(InvalidSessionIDError): |
| 65 |
await not_active_bidi_session.session.end() |