21
21
from seleniumbase .utilities .selenium_grid import grid_hub
22
22
from seleniumbase .utilities .selenium_grid import grid_node
23
23
from seleniumbase .utilities .selenium_ide import convert_ide
24
+ from seleniumbase .utilities .selenium_ide import objectify
24
25
25
26
26
27
def show_usage ():
@@ -39,6 +40,10 @@ def show_basic_usage():
39
40
print (" install [DRIVER_NAME]" )
40
41
print (" mkdir [NEW_TEST_DIRECTORY_NAME]" )
41
42
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]" )
42
47
print (" download [ITEM]" )
43
48
print (" grid-hub [start|stop|restart] [OPTIONS]" )
44
49
print (" grid-node [start|stop|restart] --hub=[HUB_IP] [OPTIONS]" )
@@ -50,96 +55,157 @@ def show_install_usage():
50
55
print (" ** install **" )
51
56
print ("" )
52
57
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)" )
56
61
print (" Example:" )
57
- print (" seleniumbase install chromedriver" )
62
+ print (" seleniumbase install chromedriver" )
58
63
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)" )
65
70
print ("" )
66
71
67
72
68
73
def show_mkdir_usage ():
69
74
print (" ** mkdir **" )
70
75
print ("" )
71
76
print (" Usage:" )
72
- print (" seleniumbase mkdir [DIRECTORY_NAME]" )
77
+ print (" seleniumbase mkdir [DIRECTORY_NAME]" )
73
78
print (" Example:" )
74
- print (" seleniumbase mkdir browser_tests" )
79
+ print (" seleniumbase mkdir browser_tests" )
75
80
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." )
81
86
print ("" )
82
87
83
88
84
89
def show_convert_usage ():
85
90
print (" ** convert **" )
86
91
print ("" )
87
92
print (" Usage:" )
88
- print (" seleniumbase convert [PYTHON_WEBDRIVER_UNITTEST_FILE]" )
93
+ print (" seleniumbase convert [PYTHON_WEBDRIVER_UNITTEST_FILE]" )
89
94
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.' )
95
161
print ("" )
96
162
97
163
98
164
def show_download_usage ():
99
165
print (" ** download **" )
100
166
print ("" )
101
167
print (" Usage:" )
102
- print (" seleniumbase download [ITEM]" )
168
+ print (" seleniumbase download [ITEM]" )
103
169
print (" (Choices: server)" )
104
170
print (" Example:" )
105
- print (" seleniumbase download server" )
171
+ print (" seleniumbase download server" )
106
172
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)" )
109
175
print ("" )
110
176
111
177
112
178
def show_grid_hub_usage ():
113
179
print (" ** grid-hub **" )
114
180
print ("" )
115
181
print (" Usage:" )
116
- print (" seleniumbase grid-hub {start|stop|restart}" )
182
+ print (" seleniumbase grid-hub {start|stop|restart}" )
117
183
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.)" )
120
186
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." )
126
192
print ("" )
127
193
128
194
129
195
def show_grid_node_usage ():
130
196
print (" ** grid-node **" )
131
197
print ("" )
132
198
print (" Usage:" )
133
- print (" seleniumbase grid-node {start|stop|restart} [OPTIONS]" )
199
+ print (" seleniumbase grid-node {start|stop|restart} [OPTIONS]" )
134
200
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.)" )
139
205
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." )
143
209
print ("" )
144
210
145
211
@@ -150,6 +216,10 @@ def show_detailed_help():
150
216
show_install_usage ()
151
217
show_mkdir_usage ()
152
218
show_convert_usage ()
219
+ show_extract_objects_usage ()
220
+ show_inject_objects_usage ()
221
+ show_objectify_usage ()
222
+ show_revert_objects_usage ()
153
223
show_download_usage ()
154
224
show_grid_hub_usage ()
155
225
show_grid_node_usage ()
@@ -182,6 +252,30 @@ def main():
182
252
else :
183
253
show_basic_usage ()
184
254
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 ()
185
279
elif command == "mkdir" :
186
280
if len (command_args ) >= 1 :
187
281
sb_mkdir .main ()
@@ -194,13 +288,13 @@ def main():
194
288
else :
195
289
show_basic_usage ()
196
290
show_download_usage ()
197
- elif command == "grid-hub" :
291
+ elif command == "grid-hub" or command == "grid_hub" :
198
292
if len (command_args ) >= 1 :
199
293
grid_hub .main ()
200
294
else :
201
295
show_basic_usage ()
202
296
show_grid_hub_usage ()
203
- elif command == "grid-node" :
297
+ elif command == "grid-node" or command == "grid_node" :
204
298
if len (command_args ) >= 1 :
205
299
grid_node .main ()
206
300
else :
@@ -220,6 +314,22 @@ def main():
220
314
print ("" )
221
315
show_convert_usage ()
222
316
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
223
333
elif command_args [0 ] == "download" :
224
334
print ("" )
225
335
show_download_usage ()
0 commit comments