Skip to content

Commit 6c2f15d

Browse files
committed
Improve the SeleniumBase behave-BDD Commander GUI
1 parent 0873079 commit 6c2f15d

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

seleniumbase/console_scripts/sb_behave_gui.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ def do_behave_run(
9191
if selected_tests[test_number].get():
9292
full_run_command += " "
9393
test_to_run = test
94-
if test.startswith("(GROUP) "):
95-
test_to_run = test.split("(GROUP) ")[1]
94+
if test.startswith("(GROUP) "):
95+
test_to_run = test.split("(GROUP) ")[1]
9696
full_run_command += test_to_run.split(" => ")[0]
9797
else:
9898
full_run_command += test.split(" => ")[0]
@@ -108,6 +108,10 @@ def do_behave_run(
108108
full_run_command += " -D rs"
109109
elif "(-D rs -D crumbs)" in rs_string:
110110
full_run_command += " -D rs -D crumbs"
111+
elif "(-D rcs)" in rs_string:
112+
full_run_command += " -D rcs"
113+
elif "(-D rcs -D crumbs)" in rs_string:
114+
full_run_command += " -D rcs -D crumbs"
111115

112116
if quiet_mode:
113117
full_run_command += " --quiet"
@@ -173,7 +177,7 @@ def do_behave_run(
173177
send_window_to_front(root)
174178

175179

176-
def create_tkinter_gui(tests, command_string):
180+
def create_tkinter_gui(tests, command_string, t_count, f_count, s_tests):
177181
root = tk.Tk()
178182
root.title("SeleniumBase Behave Commander | GUI for Behave")
179183
root.minsize(820, 656)
@@ -193,8 +197,10 @@ def create_tkinter_gui(tests, command_string):
193197

194198
options_list = [
195199
"New Session Per Test (Default)",
196-
"Reuse Session for all tests (-D rs)",
197-
"Reuse Session / clear cookies (-D rs -D crumbs)",
200+
"Reuse Session for ALL the tests (-D rs)",
201+
"Reuse Session and clear cookies (-D rs -D crumbs)",
202+
"Reuse Session in the SAME class/feature (-D rcs)",
203+
"Reuse Session in class and clear cookies (-D rcs -D crumbs)",
198204
]
199205
rsx = tk.StringVar(root)
200206
rsx.set(options_list[2])
@@ -239,13 +245,17 @@ def create_tkinter_gui(tests, command_string):
239245
chk.pack()
240246

241247
tk.Label(root, text="").pack()
248+
plural = "s"
249+
if f_count == 1:
250+
plural = ""
242251
run_display = (
243-
"Select from %s tests: "
244-
"(If NO TESTS are selected, then ALL TESTS will run)"
245-
% len(tests)
252+
"Select from %s rows (%s feature%s with %s scenarios): "
253+
"(All tests will run if none are selected)"
254+
% (len(tests), f_count, plural, t_count)
246255
)
247-
if len(tests) == 1:
248-
run_display = "Only ONE TEST was found: (Will run automatically)"
256+
if t_count == 1:
257+
run_display = "Only ONE TEST was found and will be run:"
258+
tests = s_tests
249259
tk.Label(root, text=run_display, fg="blue").pack()
250260
text_area = ScrolledText(
251261
root, width=100, height=12, wrap="word", state=tk.DISABLED
@@ -399,6 +409,7 @@ def main():
399409
file_scenario_count = {}
400410
f_count = 0
401411
s_count = 0
412+
t_count = 0
402413
if is_windows:
403414
output = output.decode("latin1")
404415
else:
@@ -436,13 +447,14 @@ def main():
436447
feature_name = feature_name.split(" # ")[-1]
437448
s_count = file_scenario_count[str(f_count)]
438449
filename = filename.strip()
439-
t_name = "(GROUP) %s => %s" % (filename, feature_name)
440-
t_name += " <> (%s Total)" % s_count
450+
t_name = "(GROUP) %s => %s" % (filename, feature_name)
451+
t_name += " <> (%s Total)" % s_count
441452
f_tests.append(t_name)
442453
elif (
443454
row.startswith(" Scenario: ")
444455
or row.startswith(" Scenario Outline: ")
445456
):
457+
t_count += 1
446458
line_num = row.split(":")[-1]
447459
scenario_name = None
448460
if row.startswith(" Scenario: "):
@@ -470,7 +482,7 @@ def main():
470482
print(error_msg)
471483
return
472484

473-
create_tkinter_gui(tests, command_string)
485+
create_tkinter_gui(tests, command_string, t_count, f_count, s_tests)
474486

475487

476488
if __name__ == "__main__":

0 commit comments

Comments
 (0)