Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update logging options, WebRTC preferences, and link-checking methods #2221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
mdmintz merged 10 commits into master from update-logging-webrtc-and-link-checking
Oct 29, 2023
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
8 changes: 6 additions & 2 deletions examples/boilerplates/samples/google_test.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
class GoogleTests(BaseCase):
def test_google_dot_com(self):
self.open("https://google.com/ncr")
self.sleep(0.4)
self.assert_title_contains("Google")
self.sleep(0.25)
self.save_screenshot_to_logs() # ("./latest_logs" folder)
self.sleep(0.2)
self.sleep(0.15)
self.hide_elements('iframe') # Hide "Sign in" pop-up
self.sleep(0.15)
self.save_screenshot_to_logs()
self.type(HomePage.search_box, "github.com")
self.assert_element(HomePage.search_button)
self.assert_element(HomePage.feeling_lucky_button)
Expand Down
14 changes: 11 additions & 3 deletions examples/boilerplates/samples/test_page_objects.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@
class GooglePage:
def go_to_google(self, sb):
sb.open("https://google.com/ncr")
sb.sleep(0.1)
sb.hide_elements('iframe') # Hide "Sign in" pop-up
sb.sleep(0.2)

def assert_google_title(self, sb):
sb.assert_title_contains("Google")

def hide_sign_in_pop_up(self, sb):
sb.sleep(0.25)
sb.hide_elements('iframe')
sb.sleep(0.15)

def do_search(self, sb, search_term):
sb.sleep(0.05)
sb.click('[title="Search"]')
sb.type('[title="Search"]', search_term + "\n")

Expand All @@ -30,6 +36,8 @@ def test_page_objects(self):
search_term = "SeleniumBase.io Docs"
expected_text = "SeleniumBase"
GooglePage().go_to_google(self)
GooglePage().assert_google_title(self)
GooglePage().hide_sign_in_pop_up(self)
GooglePage().do_search(self, search_term)
self.assert_text(expected_text, "#search")
GooglePage().click_search_result(self, expected_text)
Expand Down
4 changes: 2 additions & 2 deletions examples/capabilities/ReadMe.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<h3><img src="https://seleniumbase.github.io/img/green_logo.png" title="SeleniumBase" width="32" /> Using Desired Capabilities</h3>

You can specify browser capabilities when running SeleniumBase tests on a remote Selenium Grid server such as <a href="https://www.browserstack.com/automate/capabilities" target="_blank">BrowserStack</a>, <a href="https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/" target="_blank">Sauce Labs</a>, or another.
You can specify browser capabilities when running SeleniumBase tests on a remote Selenium Grid server such as <a href="https://www.browserstack.com/automate/capabilities" target="_blank">BrowserStack</a>, <a href="https://saucelabs.com/products/platform-configurator" target="_blank">Sauce Labs</a>, or another.

Sample run commands may look like this when run from the [SeleniumBase/examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples) folder: (The browser is now specified in the capabilities file.)

Expand Down Expand Up @@ -47,7 +47,7 @@ capabilities = {

<ul>
<li><a href="https://www.browserstack.com/automate/capabilities" target="_blank">BrowserStack desired capabilities</a></li>
<li><a href="https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/" target="_blank">Sauce Labs desired capabilities</a></li>
<li><a href="https://saucelabs.com/products/platform-configurator" target="_blank">Sauce Labs desired capabilities</a></li>
</ul>

<div><b>Parsing desired capabilities:</b></div>
Expand Down
2 changes: 1 addition & 1 deletion examples/capabilities/sample_cap_file_SL.py
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Desired capabilities example file for Sauce Labs
# Generate from https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/
# Generate from https://saucelabs.com/products/platform-configurator
capabilities = {
"browserName": "chrome",
"browserVersion": "latest",
Expand Down
1 change: 1 addition & 0 deletions examples/raw_parameter_script.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
sb.no_sandbox = False
sb.disable_js = False
sb.disable_gpu = False
sb.log_cdp_events = False
sb._multithreaded = False
sb._reuse_session = False
sb._crumbs = False
Expand Down
4 changes: 4 additions & 0 deletions examples/test_todomvc.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def test_todomvc(self, framework):
self.clear_local_storage()
self.click('a[href="examples/%s"]' % framework)
self.assert_element("section.todoapp")
self.assert_text("todos", "header h1")
self.wait_for_ready_state_complete()
title = self.get_title()
self.assert_in(framework, title.lower())
new_todo_input = "input.new-todo"
todo_count_span = "span.todo-count"
self.type(new_todo_input, "Learn Python\n")
Expand Down
2 changes: 1 addition & 1 deletion help_docs/customizing_test_runs.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ pytest --settings-file=custom_settings.py

<h3><img src="https://seleniumbase.github.io/img/green_logo.png" title="SeleniumBase" width="32" /> Running tests on a remote Selenium Grid:</h3>

🌐 SeleniumBase lets you run tests on remote Selenium Grids such as [BrowserStack](https://www.browserstack.com/automate#)'s Selenium Grid, [Sauce Labs](https://saucelabs.com/products/open-source-frameworks/selenium)'s Selenium Grid, other Grids, and even your own Grid:
🌐 SeleniumBase lets you run tests on remote Selenium Grids such as [BrowserStack](https://www.browserstack.com/automate#)'s Selenium Grid, [Sauce Labs](https://saucelabs.com/products/platform-configurator)'s Selenium Grid, other Grids, and even your own Grid:

🌐 For setting browser desired capabilities while running Selenium remotely, see the ReadMe located here: https://github.com/seleniumbase/SeleniumBase/tree/master/examples/capabilities

Expand Down
4 changes: 2 additions & 2 deletions help_docs/desired_capabilities.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## [<img src="https://seleniumbase.github.io/img/logo6.png" title="SeleniumBase" width="32">](https://github.com/seleniumbase/SeleniumBase/) Using Desired Capabilities

You can specify browser capabilities when running SeleniumBase tests on a remote Selenium Grid server such as <a href="https://www.browserstack.com/automate/capabilities" target="_blank">BrowserStack</a> or <a href="https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/" target="_blank">Sauce Labs</a>.
You can specify browser capabilities when running SeleniumBase tests on a remote Selenium Grid server such as <a href="https://www.browserstack.com/automate/capabilities" target="_blank">BrowserStack</a> or <a href="https://saucelabs.com/products/platform-configurator" target="_blank">Sauce Labs</a>.

Sample run commands may look like this when run from the [SeleniumBase/examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples) folder: (The browser is now specified in the capabilities file.)

Expand Down Expand Up @@ -47,7 +47,7 @@ capabilities = {

<ul>
<li><a href="https://www.browserstack.com/automate/capabilities" target="_blank">BrowserStack desired capabilities</a></li>
<li><a href="https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/" target="_blank">Sauce Labs desired capabilities</a></li>
<li><a href="https://saucelabs.com/products/platform-configurator" target="_blank">Sauce Labs desired capabilities</a></li>
</ul>

<div><b>Parsing desired capabilities:</b></div>
Expand Down
58 changes: 41 additions & 17 deletions help_docs/how_it_works.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

<a id="how_seleniumbase_works"></a>

👁️🔎 At the core, SeleniumBase works by extending [pytest](https://docs.pytest.org/en/latest/) as a direct plugin. SeleniumBase automatically spins up web browsers for tests (using [Selenium WebDriver](https://www.selenium.dev/documentation/webdriver/)), and then gives those tests access to the SeleniumBase libraries through the [BaseCase class](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures/base_case.py). Tests are also given access to [SeleniumBase command-line options](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md) and [SeleniumBase methods](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/method_summary.md), which provide additional functionality.
👁️🔎 The primary [SeleniumBase syntax format](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md) works by extending [pytest](https://docs.pytest.org/en/latest/) as a direct plugin. SeleniumBase automatically spins up web browsers for tests (using [Selenium WebDriver](https://www.selenium.dev/documentation/webdriver/)), and then gives those tests access to the SeleniumBase libraries through the [BaseCase class](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures/base_case.py). Tests are also given access to [SeleniumBase command-line options](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md) and [SeleniumBase methods](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/method_summary.md), which provide additional functionality.

👁️🔎 ``pytest`` uses a feature called test discovery to automatically find and run Python methods that start with ``test_`` when those methods are located in Python files that start with ``test_`` or end with ``_test.py``.

👁️🔎 The most common way of using **SeleniumBase** is by importing ``BaseCase``:
👁️🔎 The primary [SeleniumBase syntax format](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md) starts by importing ``BaseCase``:

```python
from seleniumbase import BaseCase
```

👁️🔎 This line activates ``pytest`` when a file is called directly with ``python``:
👁️🔎 This next line activates ``pytest`` when a file is called directly with ``python`` by accident:

```python
BaseCase.main(__name__, __file__)
Expand All @@ -29,12 +29,16 @@ class MyTestClass(BaseCase):
👁️🔎 Test methods inside ``BaseCase`` classes become SeleniumBase tests: (These tests automatically launch a web browser before starting, and quit the web browser after ending. Default settings can be changed via command-line options.)

```python
class MyTestClass(BaseCase):
def test_abc(self):
# ...
```

👁️🔎 SeleniumBase APIs can be called from tests via ``self``:
👁️🔎 [SeleniumBase APIs](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/method_summary.md) can be called from tests via ``self``:

```python
class MyTestClass(BaseCase):
def test_abc(self):
self.open("https://example.com")
```

Expand All @@ -44,22 +48,20 @@ class MyTestClass(BaseCase):
from seleniumbase import BaseCase
BaseCase.main(__name__, __file__)

class TestMFALogin(BaseCase):
def test_mfa_login(self):
self.open("https://seleniumbase.io/realworld/login")
class TestSimpleLogin(BaseCase):
def test_simple_login(self):
self.open("https://seleniumbase.io/simple/login")
self.type("#username", "demo_user")
self.type("#password", "secret_pass")
self.enter_mfa_code("#totpcode", "GAXG2MTEOR3DMMDG") # 6-digit
self.assert_text("Welcome!", "h1")
self.highlight("img#image1") # A fancier assert_element() call
self.click('a:contains("This Page")') # Use :contains() on any tag
self.save_screenshot_to_logs() # ("./latest_logs" folder for test)
self.click_link("Sign out") # Link must be "a" tag. Not "button".
self.assert_element('a:contains("Sign in")')
self.assert_exact_text("You have been signed out!", "#top_message")
self.click('a:contains("Sign in")')
self.assert_exact_text("Welcome!", "h1")
self.assert_element("img#image1")
self.highlight("#image1")
self.click_link("Sign out")
self.assert_text("signed out", "#top_message")
```

(See the example, [test_mfa_login.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_mfa_login.py), for reference.)
(See the example, [test_simple_login.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_simple_login.py), for reference.)

👁️🔎 Here are some examples of running tests with ``pytest``:

Expand All @@ -71,7 +73,29 @@ pytest -k agent
pytest offline_examples/
```

(See <a href="https://seleniumbase.io/help_docs/syntax_formats/">Syntax_Formats</a> for more ways of structuring <b>SeleniumBase</b> tests.)
👁️🔎 Here's a [SeleniumBase syntax format](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md) that uses the raw `driver`. Unlike the format mentioned earlier, it can be run with `python` instead of `pytest`. The `driver` includes original `driver` methods and new ones added by SeleniumBase:

```python
from seleniumbase import Driver

driver = Driver()
try:
driver.get("https://seleniumbase.io/simple/login")
driver.type("#username", "demo_user")
driver.type("#password", "secret_pass")
driver.click('a:contains("Sign in")')
driver.assert_exact_text("Welcome!", "h1")
driver.assert_element("img#image1")
driver.highlight("#image1")
driver.click_link("Sign out")
driver.assert_text("signed out", "#top_message")
finally:
driver.quit()
```

(See the example, [raw_login_driver.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_login_driver.py), for reference.)

👁️🔎 Note that regular SeleniumBase formats (ones that use `BaseCase`, the `SB` context manager, or the `sb` `pytest` fixture) have more methods than the improved `driver` format. The regular formats also have more features. Some features, (such as the [SeleniumBase dashboard](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md)), require a `pytest` format.

--------

Expand Down
1 change: 1 addition & 0 deletions help_docs/method_summary.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ self.get_new_driver(
undetectable=None,
uc_cdp_events=None,
uc_subprocess=None,
log_cdp_events=None,
no_sandbox=None,
disable_gpu=None,
headless2=None,
Expand Down
2 changes: 1 addition & 1 deletion mkdocs_build/requirements.txt
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ paginate==0.5.6
pyquery==2.0.0
readtime==3.0.0
mkdocs==1.5.3
mkdocs-material==9.4.6
mkdocs-material==9.4.7
mkdocs-exclude-search==0.6.5
mkdocs-simple-hooks==0.1.5
mkdocs-material-extensions==1.3
2 changes: 1 addition & 1 deletion requirements.txt
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ wheel>=0.41.2
attrs>=23.1.0
certifi>=2023年7月22日
filelock>=3.12.2;python_version<"3.8"
filelock>=3.12.4;python_version>="3.8"
filelock>=3.13.0;python_version>="3.8"
platformdirs>=3.11.0
parse>=1.19.1
parse-type>=0.6.2
Expand Down
2 changes: 1 addition & 1 deletion seleniumbase/__version__.py
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "4.20.7"
__version__ = "4.20.8"
6 changes: 6 additions & 0 deletions seleniumbase/behave/behave_sb.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
-D enable-sync (Enable "Chrome Sync".)
-D uc | -D undetected (Use undetected-chromedriver to evade bot-detection)
-D uc-cdp-events (Capture CDP events when running in "-D undetected" mode)
-D log-cdp ("goog:loggingPrefs", {"performance": "ALL", "browser": "ALL"})
-D remote-debug (Sync to Chrome Remote Debugger chrome://inspect/#devices)
-D dashboard (Enable the SeleniumBase Dashboard. Saved at: dashboard.html)
-D dash-title=STRING (Set the title shown for the generated dashboard.)
Expand Down Expand Up @@ -181,6 +182,7 @@ def get_configured_sb(context):
sb.undetectable = False
sb.uc_cdp_events = False
sb.uc_subprocess = False
sb.log_cdp_events = False
sb.no_sandbox = False
sb.disable_gpu = False
sb._multithreaded = False
Expand Down Expand Up @@ -549,6 +551,10 @@ def get_configured_sb(context):
sb.uc_subprocess = True
sb.undetectable = True
continue
# Handle: -D log-cdp-events / log_cdp_events / log-cdp
if low_key in ["log-cdp-events", "log_cdp_events", "log-cdp"]:
sb.log_cdp_events = True
continue
# Handle: -D no-sandbox / no_sandbox
if low_key in ["no-sandbox", "no_sandbox"]:
sb.no_sandbox = True
Expand Down
2 changes: 1 addition & 1 deletion seleniumbase/config/proxy_list.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
PROXY_LIST = {
"example1": "37.19.220.129:8443", # (Example) - set your own proxy here
"example2": "socks4://104.236.32.53:8915", # (Example)
"example3": "socks5://142.44.212.57:30439", # (Example)
"example3": "socks5://142.44.212.57:49006", # (Example)
"proxy1": None,
"proxy2": None,
"proxy3": None,
Expand Down
Loading

AltStyle によって変換されたページ (->オリジナル) /