Skip to content

Commit c0af5b4

Browse files
authored
Merge pull request #2441 from seleniumbase/options-for-disabling-chromium-features
Add options for disabling chromium features, and more
2 parents 31020e4 + 713dc6d commit c0af5b4

File tree

18 files changed

+200
-42
lines changed

18 files changed

+200
-42
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ pytest test_coffee_cart.py --trace
662662
--firefox-pref=SET # (Set a Firefox preference:value set, comma-separated.)
663663
--extension-zip=ZIP # (Load a Chrome Extension .zip|.crx, comma-separated.)
664664
--extension-dir=DIR # (Load a Chrome Extension directory, comma-separated.)
665+
--disable-features="F1,F2" # (Disable features, comma-separated, no spaces.)
665666
--binary-location=PATH # (Set path of the Chromium browser binary to use.)
666667
--driver-version=VER # (Set the chromedriver or uc_driver version to use.)
667668
--sjw # (Skip JS Waits for readyState to be "complete" or Angular to load.)

examples/boilerplates/boilerplate_test.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
from .base_test_case import BaseTestCase
2-
from .page_objects import Page
1+
try: # Run with "pytest" (relative imports are valid)
2+
from .base_test_case import BaseTestCase
3+
from .page_objects import Page
4+
except (ImportError, ValueError): # Run with "python"
5+
from base_test_case import BaseTestCase
6+
from page_objects import Page
7+
BaseTestCase.main(__name__, __file__)
38

49

510
class MyTestClass(BaseTestCase):

examples/raw_parameter_script.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
sb.window_size = None
8282
sb.maximize_option = False
8383
sb.visual_baseline = False
84+
sb.disable_features = None
8485
sb._disable_beforeunload = False
8586
sb.save_screenshot_after_test = False
8687
sb.no_screenshot_after_test = False

examples/test_todomvc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class TodoMVC(BaseCase):
88
def test_todomvc(self, framework):
99
self.open("https://todomvc.com/")
1010
self.clear_local_storage()
11-
self.click('a[href="examples/%s"]' % framework)
11+
self.click('a[href*="examples/%s/dist"]' % framework)
1212
self.assert_element("section.todoapp")
1313
self.assert_text("todos", "header h1")
1414
self.wait_for_ready_state_complete()
@@ -25,5 +25,5 @@ def test_todomvc(self, framework):
2525
self.check_if_unchecked("ul.todo-list li:nth-of-type(2) input")
2626
self.check_if_unchecked("ul.todo-list li:nth-of-type(3) input")
2727
self.assert_text("0 items left", todo_count_span)
28-
self.click('label[for="toggle-all"]')
29-
self.assert_text("3 items left", todo_count_span)
28+
self.click("button.clear-completed")
29+
self.assert_element_not_visible(todo_count_span)

examples/translations/russian_test_1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class МойТестовыйКласс(ТестНаСелен):
77
def test_пример_1(self):
88
self.открыть("https://ru.wikipedia.org/wiki/")
99
self.подтвердить_элемент('[title="Русский язык"]')
10-
self.подтвердить_текст("Википедия", "h2.main-wikimedia-header")
10+
self.подтвердить_текст("Википедия", "div.main-wikimedia-header")
1111
self.введите("#searchInput", "МГУ")
1212
self.нажмите("#searchButton")
1313
self.подтвердить_текст("университет", "#firstHeading")

help_docs/customizing_test_runs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ pytest my_first_test.py --settings-file=custom_settings.py
138138
--firefox-pref=SET # (Set a Firefox preference:value set, comma-separated.)
139139
--extension-zip=ZIP # (Load a Chrome Extension .zip|.crx, comma-separated.)
140140
--extension-dir=DIR # (Load a Chrome Extension directory, comma-separated.)
141+
--disable-features="F1,F2" # (Disable features, comma-separated, no spaces.)
141142
--binary-location=PATH # (Set path of the Chromium browser binary to use.)
142143
--driver-version=VER # (Set the chromedriver or uc_driver version to use.)
143144
--sjw # (Skip JS Waits for readyState to be "complete" or Angular to load.)

mkdocs_build/requirements.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33

44
regex>=2023.12.25
55
pymdown-extensions>=10.7
6-
pipdeptree>=2.13.1
6+
pipdeptree>=2.13.2
77
python-dateutil>=2.8.2
8-
Markdown==3.5.1
8+
Markdown==3.5.2
99
markdown2==2.4.12
1010
MarkupSafe==2.1.3
11-
Jinja2==3.1.2
11+
Jinja2==3.1.3
1212
click==8.1.7
1313
ghp-import==2.1.0
1414
watchdog==3.0.0
1515
cairocffi==1.6.1
1616
pathspec==0.12.1
1717
Babel==2.14.0
1818
paginate==0.5.6
19-
lxml==5.0.0
19+
lxml==5.1.0
2020
pyquery==2.0.0
2121
readtime==3.0.0
2222
mkdocs==1.5.3
23-
mkdocs-material==9.5.3
23+
mkdocs-material==9.5.4
2424
mkdocs-exclude-search==0.6.6
2525
mkdocs-simple-hooks==0.1.5
2626
mkdocs-material-extensions==1.3.1

requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ sniffio==1.3.0
2424
h11==0.14.0
2525
outcome==1.3.0.post0
2626
trio==0.22.2;python_version<"3.8"
27-
trio==0.23.2;python_version>="3.8"
27+
trio==0.24.0;python_version>="3.8"
2828
trio-websocket==0.11.1
2929
wsproto==1.2.0
3030
selenium==4.11.2;python_version<"3.8"
@@ -48,7 +48,7 @@ sbvirtualdisplay==1.3.0
4848
behave==1.2.6
4949
soupsieve==2.4.1;python_version<"3.8"
5050
soupsieve==2.5;python_version>="3.8"
51-
beautifulsoup4==4.12.2
51+
beautifulsoup4==4.12.3
5252
pygments==2.17.2
5353
pyreadline3==3.4.1;platform_system=="Windows"
5454
tabcompleter==1.3.0
@@ -70,9 +70,9 @@ coverage==7.4.0;python_version>="3.8"
7070
pytest-cov==4.0.0;python_version<"3.7"
7171
pytest-cov==4.1.0;python_version>="3.7"
7272
flake8==5.0.4;python_version<"3.9"
73-
flake8==6.1.0;python_version>="3.9"
73+
flake8==7.0.0;python_version>="3.9"
7474
mccabe==0.7.0
7575
pyflakes==2.5.0;python_version<"3.9"
76-
pyflakes==3.1.0;python_version>="3.9"
76+
pyflakes==3.2.0;python_version>="3.9"
7777
pycodestyle==2.9.1;python_version<"3.9"
7878
pycodestyle==2.11.1;python_version>="3.9"

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.22.5"
2+
__version__ = "4.22.6"

seleniumbase/behave/behave_sb.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ def get_configured_sb(context):
226226
sb.chromium_arg = None
227227
sb.firefox_arg = None
228228
sb.firefox_pref = None
229+
sb.disable_features = None
229230
sb.proxy_string = None
230231
sb.proxy_bypass_list = None
231232
sb.proxy_pac_url = None
@@ -748,6 +749,13 @@ def get_configured_sb(context):
748749
firefox_pref = sb.firefox_pref # revert to default
749750
sb.firefox_pref = firefox_pref
750751
continue
752+
# Handle: -D disable-features="F1,F2" / disable_features="F1,F2"
753+
if low_key in ["disable-features", "disable_features"]:
754+
disable_features = userdata[key]
755+
if disable_features == "true":
756+
disable_features = sb.disable_features # revert to default
757+
sb.disable_features = disable_features
758+
continue
751759
# Handle: -D proxy=SERVER:PORT / proxy=USERNAME:PASSWORD@SERVER:PORT
752760
if low_key in ["proxy", "proxy-server", "proxy-string"]:
753761
proxy_string = userdata[key]

0 commit comments

Comments
 (0)