Skip to content

Commit 20fe545

Browse files
authored
Merge pull request #1583 from seleniumbase/wire-integration-and-more
Wire integration, UC updates, new console methods, and more
2 parents 4bb3a0a + 4565428 commit 20fe545

21 files changed

+387
-63
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,8 @@ pytest my_first_test.py --pdb
565565
--maximize # (Start tests with the browser window maximized.)
566566
--screenshot # (Save a screenshot at the end of each test.)
567567
--visual-baseline # (Set the visual baseline for Visual/Layout tests.)
568-
--external-pdf # (Set Chrome "plugins.always_open_pdf_externally": True.)
568+
--wire # (Use selenium-wire's webdriver for replacing selenium webdriver.)
569+
--external-pdf # (Set Chromium "plugins.always_open_pdf_externally":True.)
569570
--timeout-multiplier=MULTIPLIER # (Multiplies the default timeout values.)
570571
--list-fail-page # (After each failing test, list the URL of the failure.)
571572
```

examples/raw_parameter_script.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
sb._reuse_session = False
7575
sb._crumbs = False
7676
sb._final_debug = False
77+
sb.use_wire = False
7778
sb.visual_baseline = False
7879
sb.window_size = None
7980
sb.maximize_option = False

examples/test_console_logging.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from seleniumbase import BaseCase
2+
3+
4+
class TestConsoleLogging(BaseCase):
5+
def test_console_logging(self):
6+
self.open("https://seleniumbase.io/demo_page")
7+
self.wait_for_element_visible("h2")
8+
self.start_recording_console_logs()
9+
self.console_log_string("Hello World!")
10+
self.console_log_script('document.querySelector("h2").textContent')
11+
console_logs = [log[0] for log in self.get_recorded_console_logs()]
12+
self.assert_in("Hello World!", console_logs)
13+
self.assert_in("SeleniumBase", console_logs)

help_docs/customizing_test_runs.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ pytest my_first_test.py --settings-file=custom_settings.py
179179
--maximize # (Start tests with the browser window maximized.)
180180
--screenshot # (Save a screenshot at the end of each test.)
181181
--visual-baseline # (Set the visual baseline for Visual/Layout tests.)
182-
--external-pdf # (Set Chrome "plugins.always_open_pdf_externally": True.)
182+
--wire # (Use selenium-wire's webdriver for replacing selenium webdriver.)
183+
--external-pdf # (Set Chromium "plugins.always_open_pdf_externally":True.)
183184
--timeout-multiplier=MULTIPLIER # (Multiplies the default timeout values.)
184185
--list-fail-page # (After each failing test, list the URL of the failure.)
185186
```

help_docs/features_list.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* Can run tests with a customized browser user agent. (``--agent=USER_AGENT_STRING``)
2525
* Can set a Chromium User Data Directory/Profile to load. (``--user-data-dir=DIR``)
2626
* Can avoid detection by sites that try to block Selenium. (``--undetected``/``--uc``)
27+
* Can integrate with [selenium-wire](https://github.com/wkeeling/selenium-wire) for inspecting browser requests. (``--wire``)
2728
* Can load Chrome Extension ZIP files. (``--extension-zip=ZIP``)
2829
* Can load Chrome Extension folders. (``--extension-dir=DIR``)
2930
* Powerful [console scripts](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/console_scripts/ReadMe.md). (Type **``seleniumbase``** or **``sbase``** to use.)

help_docs/method_summary.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,16 @@ self.skip(reason="")
510510

511511
############
512512

513+
self.start_recording_console_logs()
514+
515+
self.console_log_string(string)
516+
517+
self.console_log_script(script)
518+
519+
self.get_recorded_console_logs()
520+
521+
############
522+
513523
self.set_local_storage_item(key, value)
514524

515525
self.get_local_storage_item(key)
@@ -536,6 +546,10 @@ self.get_session_storage_items()
536546

537547
############
538548

549+
self.set_wire_proxy(string) # Requires "--wire"!
550+
551+
############
552+
539553
self.add_css_link(css_link)
540554

541555
self.add_js_link(js_link)

help_docs/syntax_formats.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class BaseTestCase(BaseCase):
7373
# <<< Run custom setUp() code for tests AFTER the super().setUp() >>>
7474

7575
def tearDown(self):
76-
self.save_teardown_screenshot() # If test fails, or if "--screenshot"
76+
self.save_teardown_screenshot() # On failure or "--screenshot"
7777
if self.has_exception():
7878
# <<< Run custom code if the test failed. >>>
7979
pass
@@ -255,7 +255,7 @@ class OverrideDriverTest(BaseCase):
255255

256256
(From <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_override_driver.py">examples/test_override_driver.py</a>)
257257

258-
The above format can let you use [selenium-wire](https://github.com/wkeeling/selenium-wire) to intercept & inspect requests and responses during SeleniumBase tests. Here's how the ``selenium-wire`` integration may look:
258+
The above format lets you customize [selenium-wire](https://github.com/wkeeling/selenium-wire) for intercepting and inspecting requests and responses during SeleniumBase tests. Here's how a ``selenium-wire`` integration may look:
259259

260260
```python
261261
from seleniumbase import BaseCase
@@ -277,6 +277,8 @@ class WireTestCase(BaseCase):
277277
print(request.url)
278278
```
279279

280+
(NOTE: The ``selenium-wire`` integration is now included with ``seleniumbase``: Add ``--wire`` as a ``pytest`` command-line option to activate. If you need both ``--wire`` with ``--undetected`` together, you'll still need to override ``get_new_driver()``.)
281+
280282
<a id="sb_sf_10"></a>
281283
<h3><img src="https://seleniumbase.github.io/img/logo3b.png" title="SeleniumBase" width="32" /> 10. Overriding the driver via "sb" fixture</h3>
282284

@@ -297,7 +299,7 @@ def sb(request):
297299
super(BaseClass, self).setUp()
298300

299301
def tearDown(self):
300-
self.save_teardown_screenshot()
302+
self.save_teardown_screenshot() # On failure or "--screenshot"
301303
super(BaseClass, self).tearDown()
302304

303305
def base_method(self):
@@ -352,7 +354,7 @@ def sb(request):
352354
super(BaseClass, self).setUp()
353355

354356
def tearDown(self):
355-
self.save_teardown_screenshot()
357+
self.save_teardown_screenshot() # On failure or "--screenshot"
356358
super(BaseClass, self).tearDown()
357359

358360
def base_method(self):
@@ -390,6 +392,8 @@ class TestWire:
390392
print(request.url)
391393
```
392394

395+
(NOTE: The ``selenium-wire`` integration is now included with ``seleniumbase``: Add ``--wire`` as a ``pytest`` command-line option to activate. If you need both ``--wire`` with ``--undetected`` together, you'll still need to override ``get_new_driver()``.)
396+
393397
<a id="sb_sf_11"></a>
394398
<h3><img src="https://seleniumbase.github.io/img/logo3b.png" title="SeleniumBase" width="32" /> 11. BaseCase with Chinese translations</h3>
395399

requirements.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ h11==0.14.0;python_version>="3.7"
5151
outcome==1.2.0;python_version>="3.7"
5252
trio==0.22.0;python_version>="3.7"
5353
trio-websocket==0.9.2;python_version>="3.7"
54-
websockets==10.3;python_version>="3.7"
54+
websockets==10.4;python_version>="3.7"
5555
pyopenssl==22.1.0;python_version>="3.7"
5656
wsproto==1.2.0;python_version>="3.7"
5757
selenium==3.141.0;python_version<"3.7"
@@ -60,7 +60,8 @@ msedge-selenium-tools==3.141.3;python_version<"3.7"
6060
more-itertools==5.0.0;python_version<"3.6"
6161
more-itertools==8.14.0;python_version>="3.6" and python_version<"3.7"
6262
more-itertools==9.0.0;python_version>="3.7"
63-
cssselect==1.1.0
63+
cssselect==1.1.0;python_version<"3.7"
64+
cssselect==1.2.0;python_version>="3.7"
6465
sortedcontainers==2.4.0
6566
fasteners==0.16;python_version<"3.6"
6667
fasteners==0.17.3;python_version>="3.6" and python_version<"3.7"
@@ -72,19 +73,20 @@ py==1.8.1;python_version<"3.6"
7273
py==1.11.0;python_version>="3.6"
7374
pytest==4.6.11;python_version<"3.6"
7475
pytest==7.0.1;python_version>="3.6" and python_version<"3.7"
75-
pytest==7.1.3;python_version>="3.7"
76+
pytest==7.2.0;python_version>="3.7"
7677
pytest-forked==1.3.0;python_version<"3.6"
7778
pytest-forked==1.4.0;python_version>="3.6"
7879
pytest-html==1.22.1;python_version<"3.6"
7980
pytest-html==2.0.1;python_version>="3.6"
8081
pytest-metadata==1.8.0;python_version<"3.6"
8182
pytest-metadata==1.11.0;python_version>="3.6" and python_version<"3.7"
82-
pytest-metadata==2.0.2;python_version>="3.7"
83+
pytest-metadata==2.0.3;python_version>="3.7"
8384
pytest-ordering==0.6
8485
pytest-rerunfailures==8.0;python_version<"3.6"
8586
pytest-rerunfailures==10.2;python_version>="3.6"
8687
pytest-xdist==1.34.0;python_version<"3.6"
87-
pytest-xdist==2.5.0;python_version>="3.6"
88+
pytest-xdist==2.5.0;python_version>="3.6" and python_version<"3.7"
89+
pytest-xdist==3.0.2;python_version>="3.7"
8890
parameterized==0.8.1
8991
sbvirtualdisplay==1.1.0
9092
behave==1.2.6
@@ -110,6 +112,7 @@ matplotlib-inline==0.1.6;python_version>="3.7"
110112
colorama==0.4.6;python_version<"3.6"
111113
colorama==0.4.5;python_version>="3.6" and python_version<"3.7"
112114
colorama==0.4.6;python_version>="3.7"
115+
exceptiongroup==1.0.0;python_version>="3.7" and python_version<"3.11"
113116
importlib-metadata==2.1.3;python_version<"3.6"
114117
importlib-metadata==4.2.0;python_version>="3.6" and python_version<"3.8"
115118
pycparser==2.21

sbase/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from seleniumbase import BaseCase # noqa
2+
from seleniumbase import decorators # noqa
3+
from seleniumbase import Driver # noqa
4+
from seleniumbase import encryption # noqa
5+
from seleniumbase import get_driver # noqa
6+
from seleniumbase import js_utils # noqa
7+
from seleniumbase import MasterQA # noqa
8+
from seleniumbase import page_actions # noqa
9+
from seleniumbase import page_utils # noqa
10+
from seleniumbase import SB # noqa

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.6.6"
2+
__version__ = "4.7.0"

0 commit comments

Comments
 (0)