Skip to content

Refactoring and more #1920

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
merged 9 commits into from
Jun 22, 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
22 changes: 11 additions & 11 deletions examples/behave_bdd/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ Feature: SeleniumBase scenarios for the RealWorld App # features/realworld.featu

Scenario: Verify RealWorld App (log in / sign out) # features/realworld.feature:3
Given Open "seleniumbase.io/realworld/login" # ../../sbase/steps.py:10
And Clear Session Storage # ../../sbase/steps.py:391
When Type "demo_user" into "#username" # ../../sbase/steps.py:28
And Type "secret_pass" into "#password" # ../../sbase/steps.py:28
And Do MFA "GAXG2MTEOR3DMMDG" into "#totpcode" # ../../sbase/steps.py:194
Then Assert exact text "Welcome!" in "h1" # ../../sbase/steps.py:85
And Highlight "img#image1" # ../../sbase/steps.py:95
And Click 'a:contains("This Page")' # ../../sbase/steps.py:19
And Save screenshot to logs # ../../sbase/steps.py:120
When Click link "Sign out" # ../../sbase/steps.py:104
Then Assert element 'a:contains("Sign in")' # ../../sbase/steps.py:60
And Assert text "You have been signed out!" # ../../sbase/steps.py:77
And Clear Session Storage # ../../sbase/steps.py:613
When Type "demo_user" into "#username" # ../../sbase/steps.py:40
And Type "secret_pass" into "#password" # ../../sbase/steps.py:40
And Do MFA "GAXG2MTEOR3DMMDG" into "#totpcode" # ../../sbase/steps.py:309
Then Assert exact text "Welcome!" in "h1" # ../../sbase/steps.py:157
And Highlight "img#image1" # ../../sbase/steps.py:171
And Click 'a:contains("This Page")' # ../../sbase/steps.py:27
And Save screenshot to logs # ../../sbase/steps.py:226
When Click link "Sign out" # ../../sbase/steps.py:182
Then Assert element 'a:contains("Sign in")' # ../../sbase/steps.py:120
And Assert text "You have been signed out!" # ../../sbase/steps.py:145
✅ Scenario Passed!

- Dashboard: /Users/michael/github/SeleniumBase/examples/behave_bdd/dashboard.html
Expand Down
10 changes: 4 additions & 6 deletions examples/hack_the_planet.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def test_all_your_base_are_belong_to_us(self):
self.set_text_content('#shelf-1 a[href*="airtag"]', "TO")
self.set_text_content('#shelf-1 a[href*="tv"]', "US")
self.set_text_content('#shelf-1 a[href*="homepod"]', ".")
self.set_text_content("#shelf-3 h2", aybabtu + ". ")
self.set_text_content("#shelf-2_section h2", ayb + ". ")
self.set_text_content("#shelf-2_section span", abtu + ". ")
self.highlight("div.rs-shop-subheader", loops=6, scroll=False)
self.highlight("#shelf-1", loops=2, scroll=False)
self.highlight('#shelf-1 a[href*="mac"]', loops=1, scroll=False)
Expand All @@ -53,7 +54,8 @@ def test_all_your_base_are_belong_to_us(self):
self.highlight('#shelf-1 a[href*="airpod"]', loops=1, scroll=False)
self.highlight('#shelf-1 a[href*="airtag"]', loops=1, scroll=False)
self.highlight('#shelf-1 a[href*="tv"]', loops=3, scroll=False)
self.highlight("#shelf-3 h2", loops=9, scroll=False)
self.highlight("#shelf-2_section h2", loops=5, scroll=False)
self.highlight("#shelf-2_section span", loops=6, scroll=False)

self.open("https://google.com/ncr")
self.hide_elements("iframe")
Expand Down Expand Up @@ -283,15 +285,11 @@ def test_all_your_base_are_belong_to_us(self):
self.highlight("h1", loops=10, scroll=False)

self.open("https://wordpress.com/")
self.set_text_content('a[title="Plans & Pricing"]', aybabtu)
self.set_text_content('a[title="Get Started"]', ayb)
self.set_text_content("p.no-widows", aybabtu)
zoom_out = "h1{zoom: 0.8;-moz-transform: scale(0.8);}"
self.add_css_style(zoom_out)
self.set_text_content("h1.no-widows", aybabtu)
self.set_text_content("a#lpc-button", "Automate with SeleniumBase")
self.highlight('a[title="Plans & Pricing"]', loops=6, scroll=False)
self.highlight('a[title="Get Started"]', loops=4, scroll=False)
self.highlight("h1.no-widows", loops=6, scroll=False)
self.highlight("p.no-widows", loops=4, scroll=False)
self.highlight("a#lpc-button", loops=4, scroll=False)
Expand Down
24 changes: 23 additions & 1 deletion help_docs/customizing_test_runs.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,34 @@ The code above will leave your browser window open in case there's a failure. (p
🎛️ There are times when you'll want to combine various command-line options for added effect.
For instance, the multi-process option, ``-n8``, can be customized by adding:
``--dist=loadscope`` or ``--dist=loadfile`` to it.
Here's more info on that, as taken from [pytest-xdist](https://pypi.org/project/pytest-xdist/):
There's more info on that here: [pytest-xdist](https://pypi.org/project/pytest-xdist/2.5.0/):

* ``-n8 --dist=loadscope``: Tests are grouped by module for test functions and by class for test methods. Groups are distributed to available workers as whole units. This guarantees that all tests in a group run in the same process. This can be useful if you have expensive module-level or class-level fixtures. Grouping by class takes priority over grouping by module.

* ``-n8 --dist=loadfile``: Tests are grouped by their containing file. Groups are distributed to available workers as whole units. This guarantees that all tests in a file run in the same worker.

<details>
<summary> ▶️ <code>-n8 --dist=loadgroup</code> (<b>click to expand</b>)</summary>
<div>

<ul><li>Tests are grouped by the <code>xdist_group</code> mark. Groups are distributed to available workers as whole units. This guarantees that all tests with the same <code>xdist_group</code> name run in the same worker.</li></ul>

```python
@pytest.mark.xdist_group(name="group1")
def test_1():
pass

class Test:
@pytest.mark.xdist_group("group1")
def test_2():
pass
```

<blockquote><p>This makes <code>test_1</code> and <code>Test::test_2</code> run in the same worker. Tests without the <code>xdist_group</code> mark are distributed normally.</p></blockquote>

</div>
</details>

🎛️ You might also want to combine multiple options at once. For example:

```bash
Expand Down
2 changes: 1 addition & 1 deletion help_docs/how_it_works.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class TestMFALogin(BaseCase):
👁️🔎 Here are some examples of running tests with ``pytest``:

```bash
pytest --headless --rs --dashboard --html=report.html -v -n=4
pytest --headless -n8 --dashboard --html=report.html -v --rs --crumbs
pytest test_mfa_login.py
pytest -m marker2
pytest offline_examples/
Expand Down
21 changes: 12 additions & 9 deletions integrations/behave/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ Dashboard: /Users/michael/github/SeleniumBase/examples/behave_bdd/dashboard.html
Feature: SeleniumBase scenarios for the RealWorld App # features/realworld.feature:1

Scenario: Verify RealWorld App (log in / sign out) # features/realworld.feature:3
Given Open the RealWorld Login Page # steps/real_world.py:4
When Login to the RealWorld App # steps/real_world.py:11
Then Assert exact text "Welcome!" in "h1" # steps/real_world.py:89
When Highlight element "img#image1" # steps/real_world.py:19
And Click element 'a:contains("This Page")' # steps/real_world.py:29
Then Save a screenshot to the logs # steps/real_world.py:49
When Click link "Sign out" # steps/real_world.py:39
Then Assert element 'a:contains("Sign in")' # steps/real_world.py:55
And Assert text "You have been signed out!" # steps/real_world.py:79
Given Open "seleniumbase.io/realworld/login" # ../../sbase/steps.py:10
And Clear Session Storage # ../../sbase/steps.py:613
When Type "demo_user" into "#username" # ../../sbase/steps.py:40
And Type "secret_pass" into "#password" # ../../sbase/steps.py:40
And Do MFA "GAXG2MTEOR3DMMDG" into "#totpcode" # ../../sbase/steps.py:309
Then Assert exact text "Welcome!" in "h1" # ../../sbase/steps.py:157
And Highlight "img#image1" # ../../sbase/steps.py:171
And Click 'a:contains("This Page")' # ../../sbase/steps.py:27
And Save screenshot to logs # ../../sbase/steps.py:226
When Click link "Sign out" # ../../sbase/steps.py:182
Then Assert element 'a:contains("Sign in")' # ../../sbase/steps.py:120
And Assert text "You have been signed out!" # ../../sbase/steps.py:145
✅ Scenario Passed!

- Dashboard: /Users/michael/github/SeleniumBase/examples/behave_bdd/dashboard.html
Expand Down
10 changes: 5 additions & 5 deletions mkdocs_build/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

regex>=2023.6.3
pkginfo>=1.9.6
readme-renderer>=40.0
pymdown-extensions>=10.0.1
importlib-metadata>=6.7.0
pipdeptree>=2.9.3
docutils==0.20.1
python-dateutil==2.8.2
livereload==2.6.3
Expand All @@ -12,10 +16,6 @@ MarkupSafe==2.1.3
Jinja2==3.1.2
click==8.1.3
ghp-import==2.1.0
readme-renderer==37.3
pymdown-extensions==10.0.1
importlib-metadata==6.6.0
pipdeptree==2.9.0
bleach==6.0.0
lunr==0.6.2
nltk==3.8.1
Expand All @@ -27,7 +27,7 @@ cssselect2==0.7.0
tinycss2==1.2.1
defusedxml==0.7.1
mkdocs==1.4.3
mkdocs-material==9.1.15
mkdocs-material==9.1.16
mkdocs-exclude-search==0.6.5
mkdocs-simple-hooks==0.1.5
mkdocs-material-extensions==1.1.1
16 changes: 9 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ pip>=23.1.2;python_version>="3.7"
packaging>=21.3;python_version<"3.7"
packaging>=23.1;python_version>="3.7"
setuptools>=59.6.0;python_version<"3.7"
setuptools>=67.8.0;python_version>="3.7"
setuptools>=68.0.0;python_version>="3.7"
keyring>=23.4.1;python_version<"3.8"
keyring>=23.13.1;python_version>="3.8"
keyring>=24.0.1;python_version>="3.8"
tomli>=1.2.3;python_version<"3.7"
tomli>=2.0.1;python_version>="3.7"
tqdm>=4.64.1;python_version<"3.7"
Expand All @@ -19,9 +19,10 @@ certifi>=2023.5.7
filelock>=3.4.1;python_version<"3.7"
filelock>=3.12.2;python_version>="3.7"
platformdirs>=2.4.0;python_version<"3.7"
platformdirs>=3.5.3;python_version>="3.7"
platformdirs>=3.7.0;python_version>="3.7"
parse>=1.19.1
pyparsing>=3.0.7;python_version<"3.7"
pyparsing>=3.0.9;python_version>="3.7"
pyparsing>=3.1.0;python_version>="3.7"
zipp==3.6.0;python_version<"3.7"
zipp>=3.15.0;python_version>="3.7"
more-itertools==8.14.0;python_version<"3.7"
Expand Down Expand Up @@ -56,7 +57,8 @@ fasteners==0.18;python_version>="3.7"
execnet==1.9.0
iniconfig==1.1.1;python_version<"3.7"
iniconfig==2.0.0;python_version>="3.7"
pluggy==1.0.0
pluggy==1.0.0;python_version<"3.7"
pluggy==1.2.0;python_version>="3.7"
py==1.11.0
pytest==7.0.1;python_version<"3.7"
pytest==7.3.2;python_version>="3.7"
Expand All @@ -82,8 +84,8 @@ cryptography==41.0.1;python_version>="3.7"
pygments==2.14.0;python_version<"3.7"
pygments==2.15.1;python_version>="3.7"
pyreadline3==3.4.1;platform_system=="Windows"
tabcompleter==1.2.0
pdbp==1.4.0
tabcompleter==1.2.1
pdbp==1.4.1
colorama==0.4.5;python_version<"3.7"
colorama==0.4.6;python_version>="3.7"
exceptiongroup==1.1.1;python_version>="3.7"
Expand Down
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.15.3"
__version__ = "4.15.4"
4 changes: 2 additions & 2 deletions seleniumbase/core/browser_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def _set_chrome_options(
pass
if user_data_dir and not is_using_uc(undetectable, browser_name):
abs_path = os.path.abspath(user_data_dir)
chrome_options.add_argument("user-data-dir=%s" % abs_path)
chrome_options.add_argument("--user-data-dir=%s" % abs_path)
if extension_zip:
# Can be a comma-separated list of .ZIP or .CRX files
extension_zip_list = extension_zip.split(",")
Expand Down Expand Up @@ -2320,7 +2320,7 @@ def get_local_driver(
)
if user_data_dir and not is_using_uc(undetectable, browser_name):
abs_path = os.path.abspath(user_data_dir)
edge_options.add_argument("user-data-dir=%s" % abs_path)
edge_options.add_argument("--user-data-dir=%s" % abs_path)
if extension_zip:
# Can be a comma-separated list of .ZIP or .CRX files
extension_zip_list = extension_zip.split(",")
Expand Down
12 changes: 12 additions & 0 deletions seleniumbase/fixtures/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ class Environment:
STAGING = "staging"
DEVELOP = "develop"
PRODUCTION = "production"
PERFORMANCE = "performance"
OFFLINE = "offline"
ONLINE = "online"
MASTER = "master"
REMOTE = "remote"
LEGACY = "legacy"
LOCAL = "local"
ALPHA = "alpha"
BETA = "beta"
DEMO = "demo"
MAIN = "main"
TEST = "test"
GOV = "gov"
NEW = "new"
OLD = "old"
UAT = "uat"


Expand All @@ -28,15 +34,21 @@ class ValidEnvs:
"staging",
"develop",
"production",
"performance",
"offline",
"online",
"master",
"remote",
"legacy",
"local",
"alpha",
"beta",
"demo",
"main",
"test",
"gov",
"new",
"old",
"uat",
]

Expand Down
6 changes: 6 additions & 0 deletions seleniumbase/plugins/base_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,21 @@ def options(self, parser, env):
constants.Environment.STAGING,
constants.Environment.DEVELOP,
constants.Environment.PRODUCTION,
constants.Environment.PERFORMANCE,
constants.Environment.OFFLINE,
constants.Environment.ONLINE,
constants.Environment.MASTER,
constants.Environment.REMOTE,
constants.Environment.LEGACY,
constants.Environment.LOCAL,
constants.Environment.ALPHA,
constants.Environment.BETA,
constants.Environment.DEMO,
constants.Environment.MAIN,
constants.Environment.TEST,
constants.Environment.GOV,
constants.Environment.NEW,
constants.Environment.OLD,
constants.Environment.UAT,
),
default=constants.Environment.TEST,
Expand Down
10 changes: 10 additions & 0 deletions seleniumbase/plugins/db_reporting_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,26 @@ def options(self, parser, env):
dest="database_env",
choices=(
constants.Environment.QA,
constants.Environment.RC,
constants.Environment.STAGING,
constants.Environment.DEVELOP,
constants.Environment.PRODUCTION,
constants.Environment.PERFORMANCE,
constants.Environment.OFFLINE,
constants.Environment.ONLINE,
constants.Environment.MASTER,
constants.Environment.REMOTE,
constants.Environment.LEGACY,
constants.Environment.LOCAL,
constants.Environment.ALPHA,
constants.Environment.BETA,
constants.Environment.DEMO,
constants.Environment.MAIN,
constants.Environment.TEST,
constants.Environment.GOV,
constants.Environment.NEW,
constants.Environment.OLD,
constants.Environment.UAT,
),
default=constants.Environment.TEST,
help="The database environment to run the tests in.",
Expand Down
16 changes: 16 additions & 0 deletions seleniumbase/plugins/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,21 @@ def pytest_addoption(parser):
constants.Environment.STAGING,
constants.Environment.DEVELOP,
constants.Environment.PRODUCTION,
constants.Environment.PERFORMANCE,
constants.Environment.OFFLINE,
constants.Environment.ONLINE,
constants.Environment.MASTER,
constants.Environment.REMOTE,
constants.Environment.LEGACY,
constants.Environment.LOCAL,
constants.Environment.ALPHA,
constants.Environment.BETA,
constants.Environment.DEMO,
constants.Environment.MAIN,
constants.Environment.TEST,
constants.Environment.GOV,
constants.Environment.NEW,
constants.Environment.OLD,
constants.Environment.UAT,
),
default=constants.Environment.TEST,
Expand Down Expand Up @@ -365,16 +371,26 @@ def pytest_addoption(parser):
dest="database_env",
choices=(
constants.Environment.QA,
constants.Environment.RC,
constants.Environment.STAGING,
constants.Environment.DEVELOP,
constants.Environment.PRODUCTION,
constants.Environment.PERFORMANCE,
constants.Environment.OFFLINE,
constants.Environment.ONLINE,
constants.Environment.MASTER,
constants.Environment.REMOTE,
constants.Environment.LEGACY,
constants.Environment.LOCAL,
constants.Environment.ALPHA,
constants.Environment.BETA,
constants.Environment.DEMO,
constants.Environment.MAIN,
constants.Environment.TEST,
constants.Environment.GOV,
constants.Environment.NEW,
constants.Environment.OLD,
constants.Environment.UAT,
),
default=constants.Environment.TEST,
help="The database environment to run the tests in.",
Expand Down
Loading