diff --git a/playwright/_impl/_js_handle.py b/playwright/_impl/_js_handle.py index 01625ec3f..5a930f1e6 100644 --- a/playwright/_impl/_js_handle.py +++ b/playwright/_impl/_js_handle.py @@ -129,7 +129,7 @@ def serialize_value( if math.isnan(value): return dict(v="NaN") if isinstance(value, datetime): - return dict(d=value.isoformat()) + return dict(d=value.isoformat() + "Z") if isinstance(value, bool): return {"b": value} if isinstance(value, (int, float)): diff --git a/tests/sync/test_assertions.py b/tests/sync/test_assertions.py index d7180fc94..f2df44ab5 100644 --- a/tests/sync/test_assertions.py +++ b/tests/sync/test_assertions.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import datetime import re +from datetime import datetime import pytest @@ -163,11 +163,7 @@ def test_assertions_locator_to_have_js_property(page: Page, server: Server) -> N ) expect(page.locator("div")).to_have_js_property( "foo", - { - "a": 1, - "b": "string", - "c": datetime.datetime.fromtimestamp(1627503992000 / 1000), - }, + {"a": 1, "b": "string", "c": datetime.utcfromtimestamp(1627503992000 / 1000)}, )