Skip to content

Commit 9dab7b6

Browse files
committed
fix tests
1 parent 5df6e13 commit 9dab7b6

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

py/test/selenium/webdriver/common/bidi_emulation_tests.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ def get_browser_geolocation(driver, user_context=None):
4949

5050

5151
def get_browser_locale(driver):
52-
return driver.execute_script("return navigator.languages || [navigator.language];")
52+
result = driver.script._evaluate(
53+
"Intl.DateTimeFormat().resolvedOptions().locale",
54+
{"context": driver.current_window_handle},
55+
await_promise=False,
56+
)
57+
return result.result["value"]
5358

5459

5560
def test_emulation_initialized(driver):
@@ -223,37 +228,32 @@ def test_set_geolocation_override_with_error(driver, pages):
223228
def test_set_locale_override_with_contexts(driver, pages):
224229
"""Test setting locale override with browsing contexts."""
225230
context_id = driver.current_window_handle
226-
driver.browsing_context.navigate(context_id, pages.url("formPage.html"))
227-
228-
original_locale = get_browser_locale(driver)
229-
print("Original locale:", original_locale)
230231

231232
# Set locale override to French
232233
test_locale = "fr-FR"
233234
driver.emulation.set_locale_override(locale=test_locale, contexts=[context_id])
234-
driver.browsing_context.reload(context_id, wait="complete")
235+
236+
driver.browsing_context.navigate(context_id, pages.url("formPage.html"), wait="complete")
235237

236238
current_locale = get_browser_locale(driver)
237239
assert current_locale == test_locale, f"Expected locale {test_locale}, got {current_locale}"
238240

239241

240242
def test_set_locale_override_with_user_contexts(driver, pages):
241243
"""Test setting locale override with user contexts."""
242-
# Create a user context
243244
user_context = driver.browser.create_user_context()
244245

245246
context_id = driver.browsing_context.create(type=WindowTypes.TAB, user_context=user_context)
246247

247248
driver.switch_to.window(context_id)
248-
driver.browsing_context.navigate(context_id, pages.url("formPage.html"))
249-
250-
original_locale = get_browser_locale(driver)
251-
print("Original locale:", original_locale)
252249

253250
# Set locale override to Spanish
254251
test_locale = "es-ES"
255252
driver.emulation.set_locale_override(locale=test_locale, user_contexts=[user_context])
256253

254+
url = pages.url("formPage.html")
255+
driver.browsing_context.navigate(context_id, url, wait="complete")
256+
257257
current_locale = get_browser_locale(driver)
258258
assert current_locale == test_locale, f"Expected locale {test_locale}, got {current_locale}"
259259

0 commit comments

Comments
 (0)