Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,8 @@ pytest my_first_test.py --pdb
--maximize # (Start tests with the browser window maximized.)
--screenshot # (Save a screenshot at the end of each test.)
--visual-baseline # (Set the visual baseline for Visual/Layout tests.)
--external-pdf # (Set Chrome "plugins.always_open_pdf_externally": True.)
--wire # (Use selenium-wire's webdriver for replacing selenium webdriver.)
--external-pdf # (Set Chromium "plugins.always_open_pdf_externally":True.)
--timeout-multiplier=MULTIPLIER # (Multiplies the default timeout values.)
--list-fail-page # (After each failing test, list the URL of the failure.)
```
Expand Down
1 change: 1 addition & 0 deletions examples/raw_parameter_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
sb._reuse_session = False
sb._crumbs = False
sb._final_debug = False
sb.use_wire = False
sb.visual_baseline = False
sb.window_size = None
sb.maximize_option = False
Expand Down
13 changes: 13 additions & 0 deletions examples/test_console_logging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from seleniumbase import BaseCase


class TestConsoleLogging(BaseCase):
def test_console_logging(self):
self.open("https://seleniumbase.io/demo_page")
self.wait_for_element_visible("h2")
self.start_recording_console_logs()
self.console_log_string("Hello World!")
self.console_log_script('document.querySelector("h2").textContent')
console_logs = [log[0] for log in self.get_recorded_console_logs()]
self.assert_in("Hello World!", console_logs)
self.assert_in("SeleniumBase", console_logs)
3 changes: 2 additions & 1 deletion help_docs/customizing_test_runs.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ pytest my_first_test.py --settings-file=custom_settings.py
--maximize # (Start tests with the browser window maximized.)
--screenshot # (Save a screenshot at the end of each test.)
--visual-baseline # (Set the visual baseline for Visual/Layout tests.)
--external-pdf # (Set Chrome "plugins.always_open_pdf_externally": True.)
--wire # (Use selenium-wire's webdriver for replacing selenium webdriver.)
--external-pdf # (Set Chromium "plugins.always_open_pdf_externally":True.)
--timeout-multiplier=MULTIPLIER # (Multiplies the default timeout values.)
--list-fail-page # (After each failing test, list the URL of the failure.)
```
Expand Down
1 change: 1 addition & 0 deletions help_docs/features_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* Can run tests with a customized browser user agent. (``--agent=USER_AGENT_STRING``)
* Can set a Chromium User Data Directory/Profile to load. (``--user-data-dir=DIR``)
* Can avoid detection by sites that try to block Selenium. (``--undetected``/``--uc``)
* Can integrate with [selenium-wire](https://github.com/wkeeling/selenium-wire) for inspecting browser requests. (``--wire``)
* Can load Chrome Extension ZIP files. (``--extension-zip=ZIP``)
* Can load Chrome Extension folders. (``--extension-dir=DIR``)
* Powerful [console scripts](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/console_scripts/ReadMe.md). (Type **``seleniumbase``** or **``sbase``** to use.)
Expand Down
14 changes: 14 additions & 0 deletions help_docs/method_summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,16 @@ self.skip(reason="")

############

self.start_recording_console_logs()

self.console_log_string(string)

self.console_log_script(script)

self.get_recorded_console_logs()

############

self.set_local_storage_item(key, value)

self.get_local_storage_item(key)
Expand All @@ -536,6 +546,10 @@ self.get_session_storage_items()

############

self.set_wire_proxy(string) # Requires "--wire"!

############

self.add_css_link(css_link)

self.add_js_link(js_link)
Expand Down
12 changes: 8 additions & 4 deletions help_docs/syntax_formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class BaseTestCase(BaseCase):
# <<< Run custom setUp() code for tests AFTER the super().setUp() >>>

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

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

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:
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:

```python
from seleniumbase import BaseCase
Expand All @@ -277,6 +277,8 @@ class WireTestCase(BaseCase):
print(request.url)
```

(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()``.)

<a id="sb_sf_10"></a>
<h3><img src="https://seleniumbase.github.io/img/logo3b.png" title="SeleniumBase" width="32" /> 10. Overriding the driver via "sb" fixture</h3>

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

def tearDown(self):
self.save_teardown_screenshot()
self.save_teardown_screenshot() # On failure or "--screenshot"
super(BaseClass, self).tearDown()

def base_method(self):
Expand Down Expand Up @@ -352,7 +354,7 @@ def sb(request):
super(BaseClass, self).setUp()

def tearDown(self):
self.save_teardown_screenshot()
self.save_teardown_screenshot() # On failure or "--screenshot"
super(BaseClass, self).tearDown()

def base_method(self):
Expand Down Expand Up @@ -390,6 +392,8 @@ class TestWire:
print(request.url)
```

(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()``.)

<a id="sb_sf_11"></a>
<h3><img src="https://seleniumbase.github.io/img/logo3b.png" title="SeleniumBase" width="32" /> 11. BaseCase with Chinese translations</h3>

Expand Down
13 changes: 8 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ h11==0.14.0;python_version>="3.7"
outcome==1.2.0;python_version>="3.7"
trio==0.22.0;python_version>="3.7"
trio-websocket==0.9.2;python_version>="3.7"
websockets==10.3;python_version>="3.7"
websockets==10.4;python_version>="3.7"
pyopenssl==22.1.0;python_version>="3.7"
wsproto==1.2.0;python_version>="3.7"
selenium==3.141.0;python_version<"3.7"
Expand All @@ -60,7 +60,8 @@ msedge-selenium-tools==3.141.3;python_version<"3.7"
more-itertools==5.0.0;python_version<"3.6"
more-itertools==8.14.0;python_version>="3.6" and python_version<"3.7"
more-itertools==9.0.0;python_version>="3.7"
cssselect==1.1.0
cssselect==1.1.0;python_version<"3.7"
cssselect==1.2.0;python_version>="3.7"
sortedcontainers==2.4.0
fasteners==0.16;python_version<"3.6"
fasteners==0.17.3;python_version>="3.6" and python_version<"3.7"
Expand All @@ -72,19 +73,20 @@ py==1.8.1;python_version<"3.6"
py==1.11.0;python_version>="3.6"
pytest==4.6.11;python_version<"3.6"
pytest==7.0.1;python_version>="3.6" and python_version<"3.7"
pytest==7.1.3;python_version>="3.7"
pytest==7.2.0;python_version>="3.7"
pytest-forked==1.3.0;python_version<"3.6"
pytest-forked==1.4.0;python_version>="3.6"
pytest-html==1.22.1;python_version<"3.6"
pytest-html==2.0.1;python_version>="3.6"
pytest-metadata==1.8.0;python_version<"3.6"
pytest-metadata==1.11.0;python_version>="3.6" and python_version<"3.7"
pytest-metadata==2.0.2;python_version>="3.7"
pytest-metadata==2.0.3;python_version>="3.7"
pytest-ordering==0.6
pytest-rerunfailures==8.0;python_version<"3.6"
pytest-rerunfailures==10.2;python_version>="3.6"
pytest-xdist==1.34.0;python_version<"3.6"
pytest-xdist==2.5.0;python_version>="3.6"
pytest-xdist==2.5.0;python_version>="3.6" and python_version<"3.7"
pytest-xdist==3.0.2;python_version>="3.7"
parameterized==0.8.1
sbvirtualdisplay==1.1.0
behave==1.2.6
Expand All @@ -110,6 +112,7 @@ matplotlib-inline==0.1.6;python_version>="3.7"
colorama==0.4.6;python_version<"3.6"
colorama==0.4.5;python_version>="3.6" and python_version<"3.7"
colorama==0.4.6;python_version>="3.7"
exceptiongroup==1.0.0;python_version>="3.7" and python_version<"3.11"
importlib-metadata==2.1.3;python_version<"3.6"
importlib-metadata==4.2.0;python_version>="3.6" and python_version<"3.8"
pycparser==2.21
Expand Down
10 changes: 10 additions & 0 deletions sbase/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from seleniumbase import BaseCase # noqa
from seleniumbase import decorators # noqa
from seleniumbase import Driver # noqa
from seleniumbase import encryption # noqa
from seleniumbase import get_driver # noqa
from seleniumbase import js_utils # noqa
from seleniumbase import MasterQA # noqa
from seleniumbase import page_actions # noqa
from seleniumbase import page_utils # noqa
from seleniumbase import SB # noqa
2 changes: 1 addition & 1 deletion seleniumbase/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "4.6.6"
__version__ = "4.7.0"
6 changes: 6 additions & 0 deletions seleniumbase/behave/behave_sb.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
-D maximize (Start tests with the browser window maximized.)
-D screenshot (Save a screenshot at the end of each test.)
-D visual-baseline (Set the visual baseline for Visual/Layout tests.)
-D wire (Use selenium-wire's webdriver for replacing selenium webdriver.)
-D external-pdf (Set Chromium "plugins.always_open_pdf_externally": True.)
-D timeout-multiplier=MULTIPLIER (Multiplies the default timeout values.)
"""
Expand Down Expand Up @@ -179,6 +180,7 @@ def get_configured_sb(context):
sb._crumbs = False
sb._disable_beforeunload = False
sb.visual_baseline = False
sb.use_wire = False
sb.window_size = None
sb.maximize_option = False
sb.is_context_manager = False
Expand Down Expand Up @@ -540,6 +542,10 @@ def get_configured_sb(context):
if low_key in ["visual-baseline", "visual_baseline"]:
sb.visual_baseline = True
continue
# Handle: -D wire
if low_key == "wire":
sb.use_wire = True
continue
# Handle: -D window-size=Width,Height / window_size=Width,Height
if low_key in ["window-size", "window_size"]:
window_size = userdata[key]
Expand Down
10 changes: 7 additions & 3 deletions seleniumbase/common/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,29 @@
OutOfScopeException => Used by BaseCase methods when setUp() is skipped.
TextNotVisibleException => Called when expected text fails to appear.
TimeLimitExceededException => Called when exceeding "--time-limit=SECONDS".
VisualException => Called when there's a Visual Diff Assertion Failure.
"""
from selenium.common.exceptions import WebDriverException


class NoSuchFileException(Exception):
pass


class NotUsingChromeException(WebDriverException):
class NotUsingChromeException(Exception):
pass


class OutOfScopeException(Exception):
pass


class TextNotVisibleException(WebDriverException):
class TextNotVisibleException(Exception):
pass


class TimeLimitExceededException(Exception):
pass


class VisualException(Exception):
pass
2 changes: 1 addition & 1 deletion seleniumbase/config/proxy_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"""

PROXY_LIST = {
"example1": "170.39.193.236:3128", # (Example) - set your own proxy here
"example1": "151.181.91.10:80", # (Example) - set your own proxy here
"example2": "socks4://50.197.210.138:32100", # (Example)
"proxy1": None,
"proxy2": None,
Expand Down
Loading