2121from seleniumbase .utilities .selenium_grid import grid_hub
2222from seleniumbase .utilities .selenium_grid import grid_node
2323from seleniumbase .utilities .selenium_ide import convert_ide
24+ from seleniumbase .utilities .selenium_ide import objectify
2425
2526
2627def show_usage ():
@@ -39,6 +40,10 @@ def show_basic_usage():
3940 print (" install [DRIVER_NAME]" )
4041 print (" mkdir [NEW_TEST_DIRECTORY_NAME]" )
4142 print (" convert [PYTHON_WEBDRIVER_UNITTEST_FILE]" )
43+ print (" extract-objects [SELENIUMBASE_PYTHON_FILE]" )
44+ print (" inject-objects [SELENIUMBASE_PYTHON_FILE] [OPTIONS]" )
45+ print (" objectify [SELENIUMBASE_PYTHON_FILE] [OPTIONS]" )
46+ print (" revert-objects [SELENIUMBASE_PYTHON_FILE]" )
4247 print (" download [ITEM]" )
4348 print (" grid-hub [start|stop|restart] [OPTIONS]" )
4449 print (" grid-node [start|stop|restart] --hub=[HUB_IP] [OPTIONS]" )
@@ -50,96 +55,157 @@ def show_install_usage():
5055 print (" ** install **" )
5156 print ("" )
5257 print (" Usage:" )
53- print (" seleniumbase install [DRIVER_NAME]" )
54- print (" (Drivers: chromedriver, geckodriver, edgedriver" )
55- print (" iedriver, operadriver)" )
58+ print (" seleniumbase install [DRIVER_NAME]" )
59+ print (" (Drivers: chromedriver, geckodriver, edgedriver" )
60+ print (" iedriver, operadriver)" )
5661 print (" Example:" )
57- print (" seleniumbase install chromedriver" )
62+ print (" seleniumbase install chromedriver" )
5863 print (" Output:" )
59- print (" Installs the specified webdriver." )
60- print (" (chromedriver is required for Chrome automation)" )
61- print (" (geckodriver is required for Firefox automation)" )
62- print (" (edgedriver is required for Microsoft Edge automation)" )
63- print (" (iedriver is required for InternetExplorer automation)" )
64- print (" (operadriver is required for Opera Browser automation)" )
64+ print (" Installs the specified webdriver." )
65+ print (" (chromedriver is required for Chrome automation)" )
66+ print (" (geckodriver is required for Firefox automation)" )
67+ print (" (edgedriver is required for Microsoft Edge automation)" )
68+ print (" (iedriver is required for InternetExplorer automation)" )
69+ print (" (operadriver is required for Opera Browser automation)" )
6570 print ("" )
6671
6772
6873def show_mkdir_usage ():
6974 print (" ** mkdir **" )
7075 print ("" )
7176 print (" Usage:" )
72- print (" seleniumbase mkdir [DIRECTORY_NAME]" )
77+ print (" seleniumbase mkdir [DIRECTORY_NAME]" )
7378 print (" Example:" )
74- print (" seleniumbase mkdir browser_tests" )
79+ print (" seleniumbase mkdir browser_tests" )
7580 print (" Output:" )
76- print (" Creates a new folder for running SeleniumBase scripts." )
77- print (" The new folder contains default config files," )
78- print (" sample tests for helping new users get started, and" )
79- print (" Python boilerplates for setting up customized" )
80- print (" test frameworks." )
81+ print (" Creates a new folder for running SeleniumBase scripts." )
82+ print (" The new folder contains default config files," )
83+ print (" sample tests for helping new users get started, and" )
84+ print (" Python boilerplates for setting up customized" )
85+ print (" test frameworks." )
8186 print ("" )
8287
8388
8489def show_convert_usage ():
8590 print (" ** convert **" )
8691 print ("" )
8792 print (" Usage:" )
88- print (" seleniumbase convert [PYTHON_WEBDRIVER_UNITTEST_FILE]" )
93+ print (" seleniumbase convert [PYTHON_WEBDRIVER_UNITTEST_FILE]" )
8994 print (" Output:" )
90- print (" Converts a Selenium IDE exported WebDriver unittest" )
91- print (" file into a SeleniumBase file. Adds _SB to the new" )
92- print (" file name while keeping the original file intact." )
93- print (" Works with Katalon Recorder scripts." )
94- print (" See: http://www.katalon.com/automation-recorder" )
95+ print (" Converts a Selenium IDE exported WebDriver unittest" )
96+ print (" file into a SeleniumBase file. Adds _SB to the new" )
97+ print (" file name while keeping the original file intact." )
98+ print (" Works with Katalon Recorder scripts." )
99+ print (" See: http://www.katalon.com/automation-recorder" )
100+ print ("" )
101+
102+
103+ def show_extract_objects_usage ():
104+ print (" ** extract-objects **" )
105+ print ("" )
106+ print (" Usage:" )
107+ print (" seleniumbase extract-objects [SELENIUMBASE_PYTHON_FILE]" )
108+ print (" Output:" )
109+ print (" Creates page objects based on selectors found in a" )
110+ print (" seleniumbase Python file and saves those objects to the" )
111+ print (' "page_objects.py" file in the same folder as the tests.' )
112+ print ("" )
113+
114+
115+ def show_inject_objects_usage ():
116+ print (" ** inject-objects **" )
117+ print ("" )
118+ print (" Usage:" )
119+ print (" seleniumbase inject-objects [SELENIUMBASE_PYTHON_FILE]" )
120+ print (" Options:" )
121+ print (" -c, --comments (Add object selectors to the comments.)" )
122+ print (" (Default: No added comments.)" )
123+ print (" Output:" )
124+ print (' Takes the page objects found in the "page_objects.py"' )
125+ print (' file and uses those to replace matching selectors in' )
126+ print (' the selected seleniumbase Python file.' )
127+ print ("" )
128+
129+
130+ def show_objectify_usage ():
131+ print (" ** objectify **" )
132+ print ("" )
133+ print (" Usage:" )
134+ print (" seleniumbase objectify [SELENIUMBASE_PYTHON_FILE]" )
135+ print (" Options:" )
136+ print (" -c, --comments (Add object selectors to the comments.)" )
137+ print (" (Default: No added comments.)" )
138+ print (" Output:" )
139+ print (' A modified version of the file where the selectors' )
140+ print (' have been replaced with variable names defined in' )
141+ print (' "page_objects.py", supporting the Page Object Pattern.' )
142+ print ("" )
143+ print (' (seleniumbase "objectify" has the same outcome as' )
144+ print (' combining "extract-objects" with "inject-objects")' )
145+ print ("" )
146+
147+
148+ def show_revert_objects_usage ():
149+ print (" ** revert-objects **" )
150+ print ("" )
151+ print (" Usage:" )
152+ print (" seleniumbase revert-objects [SELENIUMBASE_PYTHON_FILE]" )
153+ print (" Options:" )
154+ print (" -c, --comments (Keep existing comments for the lines.)" )
155+ print (" (Default: No comments are kept.)" )
156+ print (" Output:" )
157+ print (' Reverts the changes made by "seleniumbase objectify" or' )
158+ print (' "seleniumbase inject-objects" when run against a' )
159+ print (' seleniumbase Python file. Objects will get replaced by' )
160+ print (' selectors stored in the "page_objects.py" file.' )
95161 print ("" )
96162
97163
98164def show_download_usage ():
99165 print (" ** download **" )
100166 print ("" )
101167 print (" Usage:" )
102- print (" seleniumbase download [ITEM]" )
168+ print (" seleniumbase download [ITEM]" )
103169 print (" (Choices: server)" )
104170 print (" Example:" )
105- print (" seleniumbase download server" )
171+ print (" seleniumbase download server" )
106172 print (" Output:" )
107- print (" Downloads the specified item." )
108- print (" (server is required for using your own Selenium Grid)" )
173+ print (" Downloads the specified item." )
174+ print (" (server is required for using your own Selenium Grid)" )
109175 print ("" )
110176
111177
112178def show_grid_hub_usage ():
113179 print (" ** grid-hub **" )
114180 print ("" )
115181 print (" Usage:" )
116- print (" seleniumbase grid-hub {start|stop|restart}" )
182+ print (" seleniumbase grid-hub {start|stop|restart}" )
117183 print (" Options:" )
118- print (" -v, --verbose (Increase verbosity of logging output.)" )
119- print (" (Default: Quiet logging / not verbose.)" )
184+ print (" -v, --verbose (Increase verbosity of logging output.)" )
185+ print (" (Default: Quiet logging / not verbose.)" )
120186 print (" Output:" )
121- print (" Controls the Selenium Grid Hub Server, which allows" )
122- print (" for running tests on multiple machines in parallel" )
123- print (" to speed up test runs and reduce the total time" )
124- print (" of test suite execution." )
125- print (" You can start, restart, or stop the Grid Hub server." )
187+ print (" Controls the Selenium Grid Hub Server, which allows" )
188+ print (" for running tests on multiple machines in parallel" )
189+ print (" to speed up test runs and reduce the total time" )
190+ print (" of test suite execution." )
191+ print (" You can start, restart, or stop the Grid Hub server." )
126192 print ("" )
127193
128194
129195def show_grid_node_usage ():
130196 print (" ** grid-node **" )
131197 print ("" )
132198 print (" Usage:" )
133- print (" seleniumbase grid-node {start|stop|restart} [OPTIONS]" )
199+ print (" seleniumbase grid-node {start|stop|restart} [OPTIONS]" )
134200 print (" Options:" )
135- print (" --hub=HUB_IP (The Grid Hub IP Address to connect to.)" )
136- print (" (Default: 127.0.0.1 if not set)" )
137- print (" -v, --verbose (Increase verbosity of logging output.)" )
138- print (" (Default: Quiet logging / not verbose.)" )
201+ print (" --hub=HUB_IP (The Grid Hub IP Address to connect to.)" )
202+ print (" (Default: 127.0.0.1 if not set)" )
203+ print (" -v, --verbose (Increase verbosity of logging output.)" )
204+ print (" (Default: Quiet logging / not verbose.)" )
139205 print (" Output:" )
140- print (" Controls the Selenium Grid node, which serves as a" )
141- print (" worker machine for your Selenium Grid Hub server." )
142- print (" You can start, restart, or stop the Grid node." )
206+ print (" Controls the Selenium Grid node, which serves as a" )
207+ print (" worker machine for your Selenium Grid Hub server." )
208+ print (" You can start, restart, or stop the Grid node." )
143209 print ("" )
144210
145211
@@ -150,6 +216,10 @@ def show_detailed_help():
150216 show_install_usage ()
151217 show_mkdir_usage ()
152218 show_convert_usage ()
219+ show_extract_objects_usage ()
220+ show_inject_objects_usage ()
221+ show_objectify_usage ()
222+ show_revert_objects_usage ()
153223 show_download_usage ()
154224 show_grid_hub_usage ()
155225 show_grid_node_usage ()
@@ -182,6 +252,30 @@ def main():
182252 else :
183253 show_basic_usage ()
184254 show_convert_usage ()
255+ elif command == "extract-objects" or command == "extract_objects" :
256+ if len (command_args ) >= 1 :
257+ objectify .extract_objects ()
258+ else :
259+ show_basic_usage ()
260+ show_extract_objects_usage ()
261+ elif command == "inject-objects" or command == "inject_objects" :
262+ if len (command_args ) >= 1 :
263+ objectify .inject_objects ()
264+ else :
265+ show_basic_usage ()
266+ show_inject_objects_usage ()
267+ elif command == "objectify" :
268+ if len (command_args ) >= 1 :
269+ objectify .objectify ()
270+ else :
271+ show_basic_usage ()
272+ show_objectify_usage ()
273+ elif command == "revert-objects" or command == "revert_objects" :
274+ if len (command_args ) >= 1 :
275+ objectify .revert_objects ()
276+ else :
277+ show_basic_usage ()
278+ show_revert_objects_usage ()
185279 elif command == "mkdir" :
186280 if len (command_args ) >= 1 :
187281 sb_mkdir .main ()
@@ -194,13 +288,13 @@ def main():
194288 else :
195289 show_basic_usage ()
196290 show_download_usage ()
197- elif command == "grid-hub" :
291+ elif command == "grid-hub" or command == "grid_hub" :
198292 if len (command_args ) >= 1 :
199293 grid_hub .main ()
200294 else :
201295 show_basic_usage ()
202296 show_grid_hub_usage ()
203- elif command == "grid-node" :
297+ elif command == "grid-node" or command == "grid_node" :
204298 if len (command_args ) >= 1 :
205299 grid_node .main ()
206300 else :
@@ -220,6 +314,22 @@ def main():
220314 print ("" )
221315 show_convert_usage ()
222316 return
317+ elif command_args [0 ] == "extract-objects" :
318+ print ("" )
319+ show_extract_objects_usage ()
320+ return
321+ elif command_args [0 ] == "inject-objects" :
322+ print ("" )
323+ show_inject_objects_usage ()
324+ return
325+ elif command_args [0 ] == "objectify" :
326+ print ("" )
327+ show_objectify_usage ()
328+ return
329+ elif command_args [0 ] == "revert-objects" :
330+ print ("" )
331+ show_revert_objects_usage ()
332+ return
223333 elif command_args [0 ] == "download" :
224334 print ("" )
225335 show_download_usage ()
0 commit comments