Path: blob/trunk/py/test/selenium/webdriver/remote/remote_session_event_tests.py
3992 views
# Licensed to the Software Freedom Conservancy (SFC) under one1# or more contributor license agreements. See the NOTICE file2# distributed with this work for additional information3# regarding copyright ownership. The SFC licenses this file4# to you under the Apache License, Version 2.0 (the5# "License"); you may not use this file except in compliance6# with the License. You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing,11# software distributed under the License is distributed on an12# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13# KIND, either express or implied. See the License for the14# specific language governing permissions and limitations15# under the License.1617"""18Integration tests for session events fired through Selenium Grid.1920These tests require a running Selenium Grid instance. They verify that21custom session events can be fired from client code and received by22services listening on the remote server event bus.23"""242526def test_fire_session_event_with_payload(driver, pages):27"""Test firing a session event with payload data through Grid."""28pages.load("simpleTest.html")2930payload = {"testName": "LoginTest", "error": "Element not found", "screenshot": True}31result = driver.fire_session_event("test:failed", payload)3233assert result["success"] is True34assert result["eventType"] == "test:failed"35assert "timestamp" in result363738def test_fire_session_event_without_payload(driver, pages):39"""Test firing a session event without payload through Grid."""40pages.load("simpleTest.html")4142result = driver.fire_session_event("log:collect")4344assert result["success"] is True45assert result["eventType"] == "log:collect"46assert "timestamp" in result474849def test_fire_session_event_with_empty_payload(driver, pages):50"""Test firing a session event with empty payload through Grid."""51pages.load("simpleTest.html")5253result = driver.fire_session_event("marker:add", {})5455assert result["success"] is True56assert result["eventType"] == "marker:add"575859def test_fire_multiple_session_events(driver, pages):60"""Test firing multiple session events in sequence."""61pages.load("simpleTest.html")6263# Simulate test lifecycle events64result1 = driver.fire_session_event("test:started", {"testName": "NavigationTest"})65assert result1["success"] is True66assert result1["eventType"] == "test:started"6768result2 = driver.fire_session_event("test:step", {"stepName": "Navigate to page", "status": "passed"})69assert result2["success"] is True70assert result2["eventType"] == "test:step"7172result3 = driver.fire_session_event("test:passed", {"testName": "NavigationTest", "duration": 1500})73assert result3["success"] is True74assert result3["eventType"] == "test:passed"757677def test_fire_session_event_with_complex_payload(driver, pages):78"""Test firing a session event with nested payload data."""79pages.load("simpleTest.html")8081payload = {82"testName": "ComplexTest",83"metadata": {"suite": "regression", "priority": "high", "tags": ["smoke", "critical"]},84"timing": {"started": "2024-01-15T10:00:00Z", "ended": "2024-01-15T10:05:00Z"},85"retryCount": 0,86}87result = driver.fire_session_event("test:completed", payload)8889assert result["success"] is True90assert result["eventType"] == "test:completed"919293