99    sbase mkfile new_test.py 
1010
1111Options: 
12+     --uc  (UC Mode boilerplate using SB context manager) 
1213    -b / --basic  (Basic boilerplate / single-line test) 
13-     -r / --rec  (adds  Pdb+ breakpoint for Recorder Mode) 
14-     --url=URL  (makes  the test start on a specific page) 
14+     -r / --rec  (Adds  Pdb+ breakpoint for Recorder Mode) 
15+     --url=URL  (Makes  the test start on a specific page) 
1516
1617Language Options: 
1718    --en / --English    |    --zh / --Chinese 
3738    and "assert_text". If using the basic boilerplate 
3839    option, only the "open" method is included. Only the 
3940    BaseCase format supports Languages or Recorder Mode. 
41+     UC Mode automatically uses English with SB() format. 
4042""" 
4143import  codecs 
4244import  colorama 
@@ -52,9 +54,10 @@ def invalid_run_command(msg=None):
5254    exp  +=  "  Example:\n " 
5355    exp  +=  "           sbase mkfile new_test.py\n " 
5456    exp  +=  "  Options:\n " 
57+     exp  +=  "           --uc  (UC Mode boilerplate using SB context manager)\n " 
5558    exp  +=  "           -b / --basic  (Basic boilerplate / single-line test)\n " 
56-     exp  +=  "           -r / --rec  (adds  Pdb+ breakpoint for Recorder Mode)\n " 
57-     exp  +=  "           --url=URL  (makes  the test start on a specific page)\n " 
59+     exp  +=  "           -r / --rec  (Adds  Pdb+ breakpoint for Recorder Mode)\n " 
60+     exp  +=  "           --url=URL  (Makes  the test start on a specific page)\n " 
5861    exp  +=  "  Language Options:\n " 
5962    exp  +=  "           --en / --English    |    --zh / --Chinese\n " 
6063    exp  +=  "           --nl / --Dutch      |    --fr / --French\n " 
@@ -77,6 +80,7 @@ def invalid_run_command(msg=None):
7780    exp  +=  '           and "assert_text". If using the basic boilerplate\n ' 
7881    exp  +=  '           option, only the "open" method is included. Only the\n ' 
7982    exp  +=  "           BaseCase format supports Languages or Recorder Mode.\n " 
83+     exp  +=  "           UC Mode automatically uses English with SB() format.\n " 
8084    if  not  msg :
8185        raise  Exception ("INVALID RUN COMMAND!\n \n %s"  %  exp )
8286    elif  msg  ==  "help" :
@@ -105,6 +109,7 @@ def main():
105109        cr  =  colorama .Style .RESET_ALL 
106110
107111    basic  =  False 
112+     use_uc  =  False 
108113    help_me  =  False 
109114    recorder  =  False 
110115    error_msg  =  None 
@@ -152,6 +157,9 @@ def main():
152157                recorder  =  True 
153158            elif  option  ==  "--record"  or  option  ==  "--recorder" :
154159                recorder  =  True 
160+             elif  use_uc :
161+                 # UC must use English & ContextManager formats 
162+                 continue 
155163            elif  option  ==  "--en"  or  option  ==  "--english" :
156164                language  =  "English" 
157165            elif  option  ==  "--zh"  or  option  ==  "--chinese" :
@@ -184,6 +192,11 @@ def main():
184192                syntax  =  "DriverContext" 
185193            elif  option  ==  "--dm"  or  option  ==  "--driver-manager" :
186194                syntax  =  "DriverManager" 
195+             elif  option  ==  "--uc" :
196+                 basic  =  True 
197+                 language  =  "English" 
198+                 syntax  =  "ContextManager" 
199+                 use_uc  =  True 
187200            else :
188201                invalid_cmd  =  "\n ===> INVALID OPTION: >> %s <<\n "  %  option 
189202                invalid_cmd  =  invalid_cmd .replace (">> " , ">>"  +  c5  +  " " )
@@ -319,16 +332,22 @@ def main():
319332        data  =  []
320333        data .append ("from seleniumbase import SB" )
321334        data .append ("" )
322-         data .append ('with SB(browser="chrome") as sb:' )
323-         data .append (
324-             '    sb.open("data:text/html,<div>Hello<br><input></div>")' 
325-         )
335+         if  use_uc :
336+             data .append ('with SB(uc=True) as sb:' )
337+         else :
338+             data .append ('with SB(browser="chrome") as sb:' )
339+         if  use_uc :
340+             data .append ('    url = "%s"'  %  url )
341+             data .append ("    sb.uc_open_with_reconnect(url, 4)" )
342+             data .append ("    sb.uc_gui_click_captcha()" )
343+         else :
344+             data .append ('    sb.open("%s")'  %  url )
326345        if  not  basic :
327346            data .append ('    sb.type("input", "Goodbye")  # selector, text' )
328-             data .append ('    sb.click("html body > div ")  # selector' )
347+             data .append ('    sb.click("html body > p ")  # selector' )
329348            data .append ('    sb.assert_element("input")  # selector' )
330-             data .append ('    sb.assert_text("Hello", "div ")  # text, selector' )
331-             data .append ('    sb.highlight("div ")  # selector' )
349+             data .append ('    sb.assert_text("Hello", "p ")  # text, selector' )
350+             data .append ('    sb.highlight("p ")  # selector' )
332351            data .append ("    sb.sleep(0.5)  # seconds" )
333352        data .append ("" )
334353        new_data  =  data 
@@ -337,7 +356,14 @@ def main():
337356        data .append ("from seleniumbase import DriverContext" )
338357        data .append ("" )
339358        data .append ('with DriverContext(browser="chrome") as driver:' )
340-         data .append ('    driver.get("data:text/html,<p>Hello<br><input>")' )
359+         data .append ('    driver.get("%s")'  %  url )
360+         if  not  basic :
361+             data .append ('    driver.type("input", "Goodbye")  # sel, text' )
362+             data .append ('    driver.click("html body > p")  # selector' )
363+             data .append ('    driver.assert_element("input")  # selector' )
364+             data .append ('    driver.assert_text("Hello", "p")  # text, sel' )
365+             data .append ('    driver.highlight("p")  # selector' )
366+             data .append ("    driver.sleep(0.5)  # seconds" )
341367        data .append ("" )
342368        new_data  =  data 
343369    elif  language  ==  "English"  and  syntax  ==  "DriverManager" :
@@ -346,7 +372,14 @@ def main():
346372        data .append ("" )
347373        data .append ('driver = Driver(browser="chrome")' )
348374        data .append ("try:" )
349-         data .append ('    driver.get("data:text/html,<p>Hello<br><input>")' )
375+         data .append ('    driver.get("%s")'  %  url )
376+         if  not  basic :
377+             data .append ('    driver.type("input", "Goodbye")  # sel, text' )
378+             data .append ('    driver.click("html body > p")  # selector' )
379+             data .append ('    driver.assert_element("input")  # selector' )
380+             data .append ('    driver.assert_text("Hello", "p")  # text, sel' )
381+             data .append ('    driver.highlight("p")  # selector' )
382+             data .append ("    driver.sleep(0.5)  # seconds" )
350383        data .append ("finally:" )
351384        data .append ("    driver.quit()" )
352385        data .append ("" )
0 commit comments