Skip to content

Commit 6674048

Browse files
authored
Merge pull request #3792 from seleniumbase/support-intellisense-and-fix-locale-settings
Support IntelliSense and fix locale settings
2 parents 2b60087 + 1c2bb1a commit 6674048

File tree

10 files changed

+21
-10
lines changed

10 files changed

+21
-10
lines changed

examples/migration/protractor/input_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ class AngularMaterialInputTests(BaseCase):
66
def test_invalid_input(self):
77
# Test that there's an error for an invalid input
88
self.open("https://material.angular.io/components/input/examples")
9-
self.type("#mat-input-1", "invalid")
9+
self.type('input[type="email"]', "invalid")
1010
self.assert_element("mat-error")

examples/migration/protractor/mat_paginator_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
class AngularMaterialPaginatorTests(BaseCase):
66
def test_pagination(self):
77
self.open("https://material.angular.io/components/paginator/examples")
8+
self.click_if_visible("button.mat-mdc-button")
9+
self.scroll_to("div.mat-mdc-paginator-page-size")
810
# Set pagination to 5 items per page
911
self.click("mat-select > div")
10-
self.click("#mat-option-0")
12+
self.click("mat-option:nth-of-type(1)")
1113
# Verify navigation to the next page
1214
self.click('button[aria-label="Next page"]')
1315
self.assert_exact_text(
@@ -20,7 +22,7 @@ def test_pagination(self):
2022
)
2123
# Set pagination to 10 items per page
2224
self.click("mat-select > div")
23-
self.click("#mat-option-1")
25+
self.click("mat-option:nth-of-type(2)")
2426
# Verify page with correct number of pages
2527
self.assert_exact_text(
2628
"1 – 10 of 50", ".mat-mdc-paginator-range-label"

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.39.1"
2+
__version__ = "4.39.2"

seleniumbase/core/browser_launcher.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,6 +2169,9 @@ def _set_chrome_options(
21692169
prefs["profile.default_content_setting_values.automatic_downloads"] = 1
21702170
if locale_code:
21712171
prefs["intl.accept_languages"] = locale_code
2172+
sb_config._cdp_locale = locale_code
2173+
else:
2174+
sb_config._cdp_locale = None
21722175
if block_images:
21732176
prefs["profile.managed_default_content_settings.images"] = 2
21742177
if disable_cookies:

seleniumbase/core/sb_driver.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Add new methods to extend the driver"""
22
from contextlib import suppress
3+
from selenium.webdriver.remote.webdriver import WebDriver
34
from selenium.webdriver.remote.webelement import WebElement
45
from seleniumbase.config import settings
56
from seleniumbase.fixtures import js_utils
@@ -8,7 +9,7 @@
89
from seleniumbase.fixtures import shared_utils
910

1011

11-
class DriverMethods():
12+
class DriverMethods(WebDriver):
1213
def __init__(self, driver):
1314
self.driver = driver
1415

seleniumbase/plugins/driver_manager.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"""
3939
import os
4040
import sys
41+
from seleniumbase.core import sb_driver
4142

4243

4344
class DriverContext():
@@ -139,7 +140,7 @@ def Driver(
139140
pls=None, # Shortcut / Duplicate of "page_load_strategy".
140141
cft=None, # Use "Chrome for Testing"
141142
chs=None, # Use "Chrome-Headless-Shell"
142-
):
143+
) -> sb_driver.DriverMethods:
143144
"""
144145
* SeleniumBase Driver as a Python Context Manager or a returnable object. *
145146

seleniumbase/plugins/sb_manager.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#########################################
2525
"""
2626
from contextlib import contextmanager, suppress
27+
from typing import Any, Generator
28+
from seleniumbase import BaseCase
2729

2830

2931
@contextmanager # Usage: -> ``with SB() as sb:``
@@ -133,7 +135,7 @@ def SB(
133135
highlights=None, # Number of highlight animations for Demo Mode actions.
134136
interval=None, # SECONDS (Autoplay interval for SB Slides & Tour steps.)
135137
time_limit=None, # SECONDS (Safely fail tests that exceed the time limit.)
136-
):
138+
) -> Generator[BaseCase, Any, None]:
137139
"""
138140
* SeleniumBase as a Python Context Manager *
139141
@@ -263,7 +265,6 @@ def SB(
263265
import sys
264266
import time
265267
import traceback
266-
from seleniumbase import BaseCase
267268
from seleniumbase import config as sb_config
268269
from seleniumbase.config import settings
269270
from seleniumbase.fixtures import constants

seleniumbase/undetected/cdp_driver/browser.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,8 @@ async def get(
323323
_cdp_locale = kwargs["locale"]
324324
elif "lang" in kwargs:
325325
_cdp_locale = kwargs["lang"]
326+
elif "locale_code" in kwargs:
327+
_cdp_locale = kwargs["locale_code"]
326328
if "platform" in kwargs:
327329
_cdp_platform = kwargs["platform"]
328330
elif "plat" in kwargs:
@@ -336,6 +338,8 @@ async def get(
336338
if _cdp_timezone:
337339
await connection.send(cdp.page.navigate("about:blank"))
338340
await connection.set_timezone(_cdp_timezone)
341+
if _cdp_locale:
342+
await connection.set_locale(_cdp_locale)
339343
if _cdp_user_agent or _cdp_locale or _cdp_platform:
340344
await connection.send(cdp.page.navigate("about:blank"))
341345
await connection.set_user_agent(

seleniumbase/undetected/cdp_driver/cdp_util.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,6 @@ async def start(
370370
sb_config._cdp_locale = kwargs["locale"]
371371
elif "locale_code" in kwargs:
372372
sb_config._cdp_locale = kwargs["locale_code"]
373-
else:
374-
sb_config._cdp_locale = None
375373
if tzone:
376374
sb_config._cdp_timezone = tzone
377375
elif "timezone" in kwargs:

seleniumbase/undetected/cdp_driver/connection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ async def wait(self, t: Union[int, float] = None):
347347
async def set_locale(self, locale: Optional[str] = None):
348348
"""Sets the Language Locale code via set_user_agent_override."""
349349
await self.set_user_agent(user_agent="", accept_language=locale)
350+
await self.send(cdp.emulation.set_locale_override(locale))
350351

351352
async def set_timezone(self, timezone: Optional[str] = None):
352353
"""Sets the Timezone via set_timezone_override."""

0 commit comments

Comments
 (0)