|
7 | 7 |
|
8 | 8 | Examples:
|
9 | 9 | sbase install chromedriver
|
| 10 | +sbase methods |
| 11 | +sbase options |
10 | 12 | sbase mkdir ui_tests
|
11 | 13 | sbase mkfile new_test.py
|
12 | 14 | sbase mkpres new_presentation.py
|
13 |
| -sbase options |
14 | 15 | sbase convert webdriver_unittest_file.py
|
15 | 16 | sbase print my_first_test.py -n
|
16 | 17 | sbase translate my_first_test.py --zh -p
|
@@ -66,6 +67,7 @@ def show_basic_usage():
|
66 | 67 | sc += ("\n")
|
67 | 68 | sc += ("COMMANDS:\n")
|
68 | 69 | sc += (" install [DRIVER] [OPTIONS]\n")
|
| 70 | + sc += (" methods (List common Python methods)\n") |
69 | 71 | sc += (" options (List common pytest options)\n")
|
70 | 72 | sc += (" mkdir [DIRECTORY] [OPTIONS]\n")
|
71 | 73 | sc += (" mkfile [FILE.py] [OPTIONS]\n")
|
@@ -501,6 +503,62 @@ def show_package_location():
|
501 | 503 | print("%s" % location)
|
502 | 504 |
|
503 | 505 |
|
| 506 | +def show_methods(): |
| 507 | + c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX |
| 508 | + c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX |
| 509 | + c3 = colorama.Fore.BLUE + colorama.Back.LIGHTYELLOW_EX |
| 510 | + c4 = colorama.Fore.MAGENTA + colorama.Back.LIGHTYELLOW_EX |
| 511 | + c5 = colorama.Fore.LIGHTRED_EX + colorama.Back.LIGHTGREEN_EX |
| 512 | + cr = colorama.Style.RESET_ALL |
| 513 | + sc = ("\n " + c2 + " ** " + c3 + " SeleniumBase Python Methods " |
| 514 | + "" + c2 + " ** " + cr) |
| 515 | + print(sc) |
| 516 | + print("") |
| 517 | + line = "Here are some common methods that come with SeleniumBase:" |
| 518 | + line = c1 + line + cr |
| 519 | + print(line) |
| 520 | + line = "(Some optional args are not shown here)" |
| 521 | + print(line) |
| 522 | + print("") |
| 523 | + sbm = "" |
| 524 | + sbm += ('*.open(url) => Navigate the browser window to the URL.\n') |
| 525 | + sbm += ('*.type(selector, text) => Update the field with the text.\n') |
| 526 | + sbm += ('*.click(selector) => Click the element with the selector.\n') |
| 527 | + sbm += ('*.click_link(link_text) => Click the link containing text.\n') |
| 528 | + sbm += ('*.go_back() => Navigate back to the previous URL.\n') |
| 529 | + sbm += ('*.select_option_by_text(dropdown_selector, option)\n') |
| 530 | + sbm += ('*.hover_and_click(hover_selector, click_selector)\n') |
| 531 | + sbm += ('*.drag_and_drop(drag_selector, drop_selector)\n') |
| 532 | + sbm += ('*.get_text(selector) => Get the text from the element.\n') |
| 533 | + sbm += ('*.get_current_url() => Get the URL of the current page.\n') |
| 534 | + sbm += ('*.get_page_source() => Get the HTML of the current page.\n') |
| 535 | + sbm += ('*.get_attribute(selector, attribute) => Get element attribute.\n') |
| 536 | + sbm += ('*.get_title() => Get the title of the current page.\n') |
| 537 | + sbm += ('*.switch_to_frame(frame) => Switch into the iframe container.\n') |
| 538 | + sbm += ('*.switch_to_default_content() => Leave the iframe container.\n') |
| 539 | + sbm += ('*.open_new_window() => Open a new window in the same browser.\n') |
| 540 | + sbm += ('*.switch_to_window(window) => Switch to the browser window.\n') |
| 541 | + sbm += ('*.switch_to_default_window() => Switch to the original window.\n') |
| 542 | + sbm += ('*.get_new_driver(OPTIONS) => Open a new driver with OPTIONS.\n') |
| 543 | + sbm += ('*.switch_to_driver(driver) => Switch to the browser driver.\n') |
| 544 | + sbm += ('*.switch_to_default_driver() => Switch to the original driver.\n') |
| 545 | + sbm += ('*.is_element_visible(selector) => Return True if item visible.\n') |
| 546 | + sbm += ('*.is_text_visible(text) => Return True if text is visible.\n') |
| 547 | + sbm += ('*.save_screenshot(name) => Save a screenshot in PNG format.\n') |
| 548 | + sbm += ('*.assert_element(selector) => Verify the element is visible.\n') |
| 549 | + sbm += ('*.assert_text(text, selector) => Verify text in the element.\n') |
| 550 | + sbm += ('*.assert_title(title) => Verify the title of the web page.\n') |
| 551 | + sbm += ('*.assert_downloaded_file(file) => Verify file was downloaded.\n') |
| 552 | + sbm += ('*.assert_no_404_errors() => Verify there are no broken links.\n') |
| 553 | + sbm += ('*.assert_no_js_errors() => Verify there are no JS errors.\n') |
| 554 | + sbm = sbm.replace("*.", "self." + c1).replace('(', cr + '(') |
| 555 | + sbm = sbm.replace("self.", c2 + "self" + c5 + "." + cr) |
| 556 | + sbm = sbm.replace('(', c3 + '(' + c4) |
| 557 | + sbm = sbm.replace(')', c3 + ')' + cr) |
| 558 | + print(sbm) |
| 559 | + print("") |
| 560 | + |
| 561 | + |
504 | 562 | def show_options():
|
505 | 563 | c1 = colorama.Fore.BLUE + colorama.Back.LIGHTCYAN_EX
|
506 | 564 | c2 = colorama.Fore.BLUE + colorama.Back.LIGHTGREEN_EX
|
@@ -739,6 +797,8 @@ def main():
|
739 | 797 | print()
|
740 | 798 | else:
|
741 | 799 | show_basic_usage()
|
| 800 | + elif command == "methods" or command == "--methods": |
| 801 | + show_methods() |
742 | 802 | elif command == "options" or command == "--options":
|
743 | 803 | show_options()
|
744 | 804 | elif command == "help" or command == "--help":
|
|
0 commit comments