Skip to content

Commit c1907a0

Browse files
committed
Add a console script for displaying common pytest options
1 parent 6ed8617 commit c1907a0

File tree

2 files changed

+63
-2
lines changed

2 files changed

+63
-2
lines changed

seleniumbase/console_scripts/ReadMe.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_q.png" title="SeleniumBase" width="290">
1+
[<img src="https://cdn2.hubspot.net/hubfs/100006/images/super_logo_q.png" title="SeleniumBase" width="290">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
22

33
<h2><img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="30" /> Console Scripts</h2>
44

@@ -78,6 +78,15 @@ methods, which are "open", "click", "update_text",
7878
basic boilerplate option, only the "open" method
7979
is included.
8080

81+
### options
82+
83+
* Usage:
84+
``sbase options``
85+
86+
* Output:
87+
Displays common pytest command-line options
88+
that are available when using SeleniumBase.
89+
8190
### convert
8291

8392
* Usage:

seleniumbase/console_scripts/run.py

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
sbase install chromedriver
1010
sbase mkdir browser_tests
1111
sbase mkfile new_test.py
12-
sbase convert my_old_webdriver_unittest.py
12+
sbase options
13+
sbase convert old_webdriver_unittest.py
1314
sbase print my_first_test.py -n
1415
sbase translate my_first_test.py --zh -p
1516
sbase extract-objects my_first_test.py
@@ -60,6 +61,7 @@ def show_basic_usage():
6061
sc += (" install [DRIVER_NAME] [OPTIONS]\n")
6162
sc += (" mkdir [DIRECTORY_NAME]\n")
6263
sc += (" mkfile [FILE_NAME.py]\n")
64+
sc += (" options (display common pytest options)\n")
6365
sc += (" convert [PYTHON_WEBDRIVER_UNITTEST_FILE]\n")
6466
sc += (" print [FILE] [OPTIONS]\n")
6567
sc += (" translate [SB_PYTHON_FILE] [LANGUAGE] [ACTION]\n")
@@ -436,6 +438,54 @@ def show_version_info():
436438
print('\n%s\n' % version)
437439

438440

441+
def show_options():
442+
c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
443+
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
444+
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
445+
cr = colorama.Style.RESET_ALL
446+
sc = ("\n " + c2 + "** " + c3 + "pytest cmd options" + c2 + " **" + cr)
447+
print(sc)
448+
print("")
449+
line = "Here are some common pytest options to use with SeleniumBase:"
450+
line = c1 + line + cr
451+
print(line)
452+
print("")
453+
print('--browser=BROWSER (The web browser to use. Default: "chrome")')
454+
print('--headless (Run tests headlessly. Default mode on Linux OS.)')
455+
print('--demo (Slow down and visually see test actions as they occur.)')
456+
print('--slow (Slow down the automation. Faster than using Demo Mode.)')
457+
print('--reuse-session / --rs (Reuse the browser session between tests.)')
458+
print('--crumbs (Delete all cookies between tests reusing a session.)')
459+
print("--guest (Enable Chrome's Guest mode.)")
460+
print("--incognito (Enable Chrome's Incognito mode.)")
461+
print('-m MARKER (Only run tests with the specified pytest marker.)')
462+
print('-n NUM (Multithread the tests using that many threads.)')
463+
print('-v (Verbose mode. Print the full name of each test run.)')
464+
print("--agent=STRING (Modify the web browser's User-Agent string.)")
465+
print('--mobile (Use the mobile device emulator while running tests.)')
466+
print('--metrics=STRING (Set mobile "CSSWidth,CSSHeight,PixelRatio".)')
467+
print('--maximize (Start tests with the web browser window maximized.)')
468+
print('--ad-block (Block some types of display ads after page loads.)')
469+
print('--check-js (Check for JavaScript errors after page loads.)')
470+
print('--pdb (Enter Debug Mode if a test fails. h: Help. c: Continue.')
471+
print(' interact: Interactive Mode. CTRL-D: Exit Interactive Mode.)')
472+
print('--html=report.html (Create a detailed pytest-html report.)')
473+
print('--archive-logs (Archive old log files instead of deleting them.)')
474+
print('--disable-csp (Disable the Content Security Policy of websites.)')
475+
print('--proxy=SERVER:PORT (Set a proxy server:port combo for tests.)')
476+
print("--settings-file=FILE (Override default SeleniumBase settings.)")
477+
print('--env=ENV (Set the test env. Access with "self.env" in tests.)')
478+
print('--data=DATA (Extra test data. Access with "self.data" in tests.)')
479+
print('--collect-only -q (Show discovered tests without running them.)')
480+
print('--save-screenshot (Save a screenshot at the end of each test.)')
481+
print('-x (Stop running tests after the first failure is reached.)')
482+
print("")
483+
line = 'For the full list of ' + c1 + 'command-line options' + cr
484+
line += ', type: "' + c2 + 'pytest' + cr + ' ' + c3 + '--help' + cr + '".'
485+
print(line)
486+
print("")
487+
488+
439489
def show_detailed_help():
440490
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
441491
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
@@ -605,6 +655,8 @@ def main():
605655
show_version_info()
606656
else:
607657
show_basic_usage()
658+
elif command == "options" or command == "--options":
659+
show_options()
608660
elif command == "help" or command == "--help":
609661
if len(command_args) >= 1:
610662
if command_args[0] == "install":

0 commit comments

Comments
 (0)