Skip to content

Commit 52c0486

Browse files
committed
New feature: SeleniumBase Commander / GUI for pytest
1 parent 7191a8c commit 52c0486

File tree

3 files changed

+453
-1
lines changed

3 files changed

+453
-1
lines changed

seleniumbase/console_scripts/ReadMe.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ COMMANDS:
1717
install [DRIVER] [OPTIONS]
1818
methods (List common Python methods)
1919
options (List common pytest options)
20+
commander / gui [OPTIONAL PATH or TEST FILE]
2021
mkdir [DIRECTORY] [OPTIONS]
2122
mkfile [FILE.py] [OPTIONS]
2223
mkrec / codegen [FILE.py] [OPTIONS]
@@ -143,6 +144,21 @@ that are available when using SeleniumBase.
143144
For the full list of command-line options, type: "pytest --help".
144145
```
145146

147+
<h3>commander / gui</h3>
148+
149+
* Usage:
150+
``sbase commander [OPTIONAL PATH or TEST FILE]``
151+
``sbase gui [OPTIONAL PATH or TEST FILE]``
152+
153+
* Examples:
154+
``sbase gui``
155+
``sbase gui -k agent``
156+
``sbase gui examples/``
157+
``sbase gui test_suite.py``
158+
159+
* Output:
160+
Launches SeleniumBase Commander | GUI for pytest.
161+
146162
<h3>mkdir</h3>
147163

148164
* Usage:

seleniumbase/console_scripts/run.py

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
sbase install chromedriver
1010
sbase methods
1111
sbase options
12+
sbase commander
1213
sbase mkdir ui_tests
1314
sbase mkfile new_test.py
1415
sbase mkrec new_test.py
@@ -78,6 +79,7 @@ def show_basic_usage():
7879
sc += " install [DRIVER] [OPTIONS]\n"
7980
sc += " methods (List common Python methods)\n"
8081
sc += " options (List common pytest options)\n"
82+
sc += " commander / gui [OPTIONAL PATH or TEST FILE]\n"
8183
sc += " mkdir [DIRECTORY] [OPTIONS]\n"
8284
sc += " mkfile [FILE.py] [OPTIONS]\n"
8385
sc += " mkrec / codegen [FILE.py] [OPTIONS]\n"
@@ -146,6 +148,28 @@ def show_install_usage():
146148
print("")
147149

148150

151+
def show_commander_usage():
152+
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
153+
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
154+
cr = colorama.Style.RESET_ALL
155+
sc = " " + c2 + "** " + c3 + "commander" + c2 + " **" + cr
156+
print(sc)
157+
print("")
158+
print(" Usage:")
159+
print(" seleniumbase commander [OPTIONAL PATH or TEST FILE]")
160+
print(" OR: sbase commander [OPTIONAL PATH or TEST FILE]")
161+
print(" OR: seleniumbase gui [OPTIONAL PATH or TEST FILE]")
162+
print(" OR: sbase gui [OPTIONAL PATH or TEST FILE]")
163+
print(" Examples:")
164+
print(" sbase gui")
165+
print(" sbase gui -k agent")
166+
print(" sbase gui examples/")
167+
print(" sbase gui test_suite.py")
168+
print(" Output:")
169+
print(" Launches SeleniumBase Commander | GUI for pytest.")
170+
print("")
171+
172+
149173
def show_mkdir_usage():
150174
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
151175
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
@@ -250,6 +274,21 @@ def show_codegen_usage():
250274
print("")
251275

252276

277+
def show_recorder_usage():
278+
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
279+
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
280+
cr = colorama.Style.RESET_ALL
281+
sc = " " + c2 + "** " + c3 + "recorder" + c2 + " **" + cr
282+
print(sc)
283+
print("")
284+
print(" Usage:")
285+
print(" seleniumbase recorder")
286+
print(" OR: sbase recorder")
287+
print(" Output:")
288+
print(" Launches the SeleniumBase Recorder Desktop App.")
289+
print("")
290+
291+
253292
def show_mkpres_usage():
254293
c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
255294
c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX
@@ -629,7 +668,8 @@ def show_methods():
629668
sbm += "*.get_attribute(selector, attribute) => Get element attribute.\n"
630669
sbm += "*.get_title() => Get the title of the current page.\n"
631670
sbm += "*.switch_to_frame(frame) => Switch into the iframe container.\n"
632-
sbm += "*.switch_to_default_content() => Leave the iframe container.\n"
671+
sbm += "*.switch_to_default_content() => Exit all iframe containers.\n"
672+
sbm += "*.switch_to_parent_frame() => Exit from the current iframe.\n"
633673
sbm += "*.open_new_window() => Open a new window in the same browser.\n"
634674
sbm += "*.switch_to_window(window) => Switch to the browser window.\n"
635675
sbm += "*.switch_to_default_window() => Switch to the original window.\n"
@@ -735,10 +775,12 @@ def show_detailed_help():
735775
print(c6 + " " + c2 + " Commands: " + c6 + " ")
736776
print(cr)
737777
show_install_usage()
778+
show_commander_usage()
738779
show_mkdir_usage()
739780
show_mkfile_usage()
740781
show_mkrec_usage()
741782
show_codegen_usage()
783+
show_recorder_usage()
742784
show_mkpres_usage()
743785
show_mkchart_usage()
744786
show_convert_usage()
@@ -779,6 +821,10 @@ def main():
779821
else:
780822
show_basic_usage()
781823
show_install_usage()
824+
elif command == "commander" or command == "gui":
825+
from seleniumbase.console_scripts import sb_commander
826+
827+
sb_commander.main()
782828
elif (
783829
command == "recorder"
784830
or (command == "record" and len(command_args) == 0)
@@ -960,6 +1006,14 @@ def main():
9601006
print("")
9611007
show_install_usage()
9621008
return
1009+
elif command_args[0] == "commander":
1010+
print("")
1011+
show_commander_usage()
1012+
return
1013+
elif command_args[0] == "gui":
1014+
print("")
1015+
show_commander_usage()
1016+
return
9631017
elif command_args[0] == "mkdir":
9641018
print("")
9651019
show_mkdir_usage()
@@ -976,6 +1030,10 @@ def main():
9761030
print("")
9771031
show_codegen_usage()
9781032
return
1033+
elif command_args[0] == "recorder":
1034+
print("")
1035+
show_recorder_usage()
1036+
return
9791037
elif command_args[0] == "mkpres":
9801038
print("")
9811039
show_mkpres_usage()

0 commit comments

Comments
 (0)