diff --git a/tests/session/test_protocol_basics.py b/tests/session/test_protocol_basics.py index c129fbc91c..d6226e8c3c 100644 --- a/tests/session/test_protocol_basics.py +++ b/tests/session/test_protocol_basics.py @@ -14,8 +14,8 @@ # limitations under the License. import pytest -from test_helpers import (execute_command, json, read_JSON_message, - send_JSON_command) +from test_helpers import (AnyExtending, execute_command, json, + read_JSON_message, send_JSON_command) # Tests for "handle an incoming message" error handling, when the message # can't be decoded as known command. @@ -89,24 +89,47 @@ async def test_session_status(websocket): @pytest.mark.asyncio -async def test_channel_non_empty(websocket): - await send_JSON_command( +async def test_channel_non_empty_static_command(websocket): + command_id = await send_JSON_command(websocket, { + "method": "session.status", + "params": {}, + "channel": "SOME_CHANNEL" + }) + resp = await read_JSON_message(websocket) + + if "build" in resp["result"]: + # Heuristic to detect chromedriver. + pytest.xfail(reason="TODO: http://b/343683918") + + assert resp == AnyExtending({ + "id": command_id, + "channel": "SOME_CHANNEL", + "type": "success", + "result": { + "ready": False, + "message": "already connected" + } + }) + + +@pytest.mark.asyncio +async def test_channel_non_empty_not_static_command(websocket): + command_id = await send_JSON_command( websocket, { - "id": 6000, - "method": "session.status", + "id": 2, + "method": "browsingContext.getTree", "params": {}, "channel": "SOME_CHANNEL" }) resp = await read_JSON_message(websocket) - assert resp == { - "id": 6000, + assert resp == AnyExtending({ + "id": command_id, "channel": "SOME_CHANNEL", "type": "success", "result": { - "ready": False, - "message": "already connected" + "contexts": [{}] } - } + }) @pytest.mark.asyncio @@ -118,14 +141,14 @@ async def test_channel_empty(websocket): "channel": "" }) resp = await read_JSON_message(websocket) - assert resp == { + assert resp == AnyExtending({ "id": 7000, "type": "success", "result": { "ready": False, "message": "already connected" } - } + }) @pytest.mark.asyncio