Skip to content

Commit 89678be

Browse files
authored
Merge pull request #1920 from seleniumbase/refactoring-and-more
Refactoring and more
2 parents 717b6d0 + e082c78 commit 89678be

File tree

14 files changed

+128
-55
lines changed

14 files changed

+128
-55
lines changed

examples/behave_bdd/ReadMe.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ Feature: SeleniumBase scenarios for the RealWorld App # features/realworld.featu
1616

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

3232
- Dashboard: /Users/michael/github/SeleniumBase/examples/behave_bdd/dashboard.html

examples/hack_the_planet.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def test_all_your_base_are_belong_to_us(self):
4343
self.set_text_content('#shelf-1 a[href*="airtag"]', "TO")
4444
self.set_text_content('#shelf-1 a[href*="tv"]', "US")
4545
self.set_text_content('#shelf-1 a[href*="homepod"]', ".")
46-
self.set_text_content("#shelf-3 h2", aybabtu + ". ")
46+
self.set_text_content("#shelf-2_section h2", ayb + ". ")
47+
self.set_text_content("#shelf-2_section span", abtu + ". ")
4748
self.highlight("div.rs-shop-subheader", loops=6, scroll=False)
4849
self.highlight("#shelf-1", loops=2, scroll=False)
4950
self.highlight('#shelf-1 a[href*="mac"]', loops=1, scroll=False)
@@ -53,7 +54,8 @@ def test_all_your_base_are_belong_to_us(self):
5354
self.highlight('#shelf-1 a[href*="airpod"]', loops=1, scroll=False)
5455
self.highlight('#shelf-1 a[href*="airtag"]', loops=1, scroll=False)
5556
self.highlight('#shelf-1 a[href*="tv"]', loops=3, scroll=False)
56-
self.highlight("#shelf-3 h2", loops=9, scroll=False)
57+
self.highlight("#shelf-2_section h2", loops=5, scroll=False)
58+
self.highlight("#shelf-2_section span", loops=6, scroll=False)
5759

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

285287
self.open("https://wordpress.com/")
286-
self.set_text_content('a[title="Plans & Pricing"]', aybabtu)
287-
self.set_text_content('a[title="Get Started"]', ayb)
288288
self.set_text_content("p.no-widows", aybabtu)
289289
zoom_out = "h1{zoom: 0.8;-moz-transform: scale(0.8);}"
290290
self.add_css_style(zoom_out)
291291
self.set_text_content("h1.no-widows", aybabtu)
292292
self.set_text_content("a#lpc-button", "Automate with SeleniumBase")
293-
self.highlight('a[title="Plans & Pricing"]', loops=6, scroll=False)
294-
self.highlight('a[title="Get Started"]', loops=4, scroll=False)
295293
self.highlight("h1.no-widows", loops=6, scroll=False)
296294
self.highlight("p.no-widows", loops=4, scroll=False)
297295
self.highlight("a#lpc-button", loops=4, scroll=False)

help_docs/customizing_test_runs.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,34 @@ The code above will leave your browser window open in case there's a failure. (p
277277
🎛️ There are times when you'll want to combine various command-line options for added effect.
278278
For instance, the multi-process option, ``-n8``, can be customized by adding:
279279
``--dist=loadscope`` or ``--dist=loadfile`` to it.
280-
Here's more info on that, as taken from [pytest-xdist](https://pypi.org/project/pytest-xdist/):
280+
There's more info on that here: [pytest-xdist](https://pypi.org/project/pytest-xdist/2.5.0/):
281281

282282
* ``-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.
283283

284284
* ``-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.
285285

286+
<details>
287+
<summary> ▶️ <code>-n8 --dist=loadgroup</code> (<b>click to expand</b>)</summary>
288+
<div>
289+
290+
<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>
291+
292+
```python
293+
@pytest.mark.xdist_group(name="group1")
294+
def test_1():
295+
pass
296+
297+
class Test:
298+
@pytest.mark.xdist_group("group1")
299+
def test_2():
300+
pass
301+
```
302+
303+
<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>
304+
305+
</div>
306+
</details>
307+
286308
🎛️ You might also want to combine multiple options at once. For example:
287309

288310
```bash

help_docs/how_it_works.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class TestMFALogin(BaseCase):
4646
👁️🔎 Here are some examples of running tests with ``pytest``:
4747

4848
```bash
49-
pytest --headless --rs --dashboard --html=report.html -v -n=4
49+
pytest --headless -n8 --dashboard --html=report.html -v --rs --crumbs
5050
pytest test_mfa_login.py
5151
pytest -m marker2
5252
pytest offline_examples/

integrations/behave/ReadMe.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@ Dashboard: /Users/michael/github/SeleniumBase/examples/behave_bdd/dashboard.html
1313
Feature: SeleniumBase scenarios for the RealWorld App # features/realworld.feature:1
1414

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

2730
- Dashboard: /Users/michael/github/SeleniumBase/examples/behave_bdd/dashboard.html

mkdocs_build/requirements.txt

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

44
regex>=2023.6.3
55
pkginfo>=1.9.6
6+
readme-renderer>=40.0
7+
pymdown-extensions>=10.0.1
8+
importlib-metadata>=6.7.0
9+
pipdeptree>=2.9.3
610
docutils==0.20.1
711
python-dateutil==2.8.2
812
livereload==2.6.3
@@ -12,10 +16,6 @@ MarkupSafe==2.1.3
1216
Jinja2==3.1.2
1317
click==8.1.3
1418
ghp-import==2.1.0
15-
readme-renderer==37.3
16-
pymdown-extensions==10.0.1
17-
importlib-metadata==6.6.0
18-
pipdeptree==2.9.0
1919
bleach==6.0.0
2020
lunr==0.6.2
2121
nltk==3.8.1
@@ -27,7 +27,7 @@ cssselect2==0.7.0
2727
tinycss2==1.2.1
2828
defusedxml==0.7.1
2929
mkdocs==1.4.3
30-
mkdocs-material==9.1.15
30+
mkdocs-material==9.1.16
3131
mkdocs-exclude-search==0.6.5
3232
mkdocs-simple-hooks==0.1.5
3333
mkdocs-material-extensions==1.1.1

requirements.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ pip>=23.1.2;python_version>="3.7"
33
packaging>=21.3;python_version<"3.7"
44
packaging>=23.1;python_version>="3.7"
55
setuptools>=59.6.0;python_version<"3.7"
6-
setuptools>=67.8.0;python_version>="3.7"
6+
setuptools>=68.0.0;python_version>="3.7"
77
keyring>=23.4.1;python_version<"3.8"
8-
keyring>=23.13.1;python_version>="3.8"
8+
keyring>=24.0.1;python_version>="3.8"
99
tomli>=1.2.3;python_version<"3.7"
1010
tomli>=2.0.1;python_version>="3.7"
1111
tqdm>=4.64.1;python_version<"3.7"
@@ -19,9 +19,10 @@ certifi>=2023.5.7
1919
filelock>=3.4.1;python_version<"3.7"
2020
filelock>=3.12.2;python_version>="3.7"
2121
platformdirs>=2.4.0;python_version<"3.7"
22-
platformdirs>=3.5.3;python_version>="3.7"
22+
platformdirs>=3.7.0;python_version>="3.7"
23+
parse>=1.19.1
2324
pyparsing>=3.0.7;python_version<"3.7"
24-
pyparsing>=3.0.9;python_version>="3.7"
25+
pyparsing>=3.1.0;python_version>="3.7"
2526
zipp==3.6.0;python_version<"3.7"
2627
zipp>=3.15.0;python_version>="3.7"
2728
more-itertools==8.14.0;python_version<"3.7"
@@ -56,7 +57,8 @@ fasteners==0.18;python_version>="3.7"
5657
execnet==1.9.0
5758
iniconfig==1.1.1;python_version<"3.7"
5859
iniconfig==2.0.0;python_version>="3.7"
59-
pluggy==1.0.0
60+
pluggy==1.0.0;python_version<"3.7"
61+
pluggy==1.2.0;python_version>="3.7"
6062
py==1.11.0
6163
pytest==7.0.1;python_version<"3.7"
6264
pytest==7.3.2;python_version>="3.7"
@@ -82,8 +84,8 @@ cryptography==41.0.1;python_version>="3.7"
8284
pygments==2.14.0;python_version<"3.7"
8385
pygments==2.15.1;python_version>="3.7"
8486
pyreadline3==3.4.1;platform_system=="Windows"
85-
tabcompleter==1.2.0
86-
pdbp==1.4.0
87+
tabcompleter==1.2.1
88+
pdbp==1.4.1
8789
colorama==0.4.5;python_version<"3.7"
8890
colorama==0.4.6;python_version>="3.7"
8991
exceptiongroup==1.1.1;python_version>="3.7"

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.15.3"
2+
__version__ = "4.15.4"

seleniumbase/core/browser_launcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ def _set_chrome_options(
606606
pass
607607
if user_data_dir and not is_using_uc(undetectable, browser_name):
608608
abs_path = os.path.abspath(user_data_dir)
609-
chrome_options.add_argument("user-data-dir=%s" % abs_path)
609+
chrome_options.add_argument("--user-data-dir=%s" % abs_path)
610610
if extension_zip:
611611
# Can be a comma-separated list of .ZIP or .CRX files
612612
extension_zip_list = extension_zip.split(",")
@@ -2320,7 +2320,7 @@ def get_local_driver(
23202320
)
23212321
if user_data_dir and not is_using_uc(undetectable, browser_name):
23222322
abs_path = os.path.abspath(user_data_dir)
2323-
edge_options.add_argument("user-data-dir=%s" % abs_path)
2323+
edge_options.add_argument("--user-data-dir=%s" % abs_path)
23242324
if extension_zip:
23252325
# Can be a comma-separated list of .ZIP or .CRX files
23262326
extension_zip_list = extension_zip.split(",")

seleniumbase/fixtures/constants.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,21 @@ class Environment:
99
STAGING = "staging"
1010
DEVELOP = "develop"
1111
PRODUCTION = "production"
12+
PERFORMANCE = "performance"
1213
OFFLINE = "offline"
1314
ONLINE = "online"
1415
MASTER = "master"
1516
REMOTE = "remote"
17+
LEGACY = "legacy"
1618
LOCAL = "local"
1719
ALPHA = "alpha"
1820
BETA = "beta"
21+
DEMO = "demo"
1922
MAIN = "main"
2023
TEST = "test"
24+
GOV = "gov"
25+
NEW = "new"
26+
OLD = "old"
2127
UAT = "uat"
2228

2329

@@ -28,15 +34,21 @@ class ValidEnvs:
2834
"staging",
2935
"develop",
3036
"production",
37+
"performance",
3138
"offline",
3239
"online",
3340
"master",
3441
"remote",
42+
"legacy",
3543
"local",
3644
"alpha",
3745
"beta",
46+
"demo",
3847
"main",
3948
"test",
49+
"gov",
50+
"new",
51+
"old",
4052
"uat",
4153
]
4254

0 commit comments

Comments
 (0)