seleniumbase / SeleniumBase

📊 Python's all-in-one framework for web crawling, scraping, testing, and reporting. Supports pytest. UC Mode provides stealth. Includes many tools.
https://seleniumbase.io
MIT License
5k stars 944 forks source link

Refactor file generators #1957

Closed mdmintz closed 1 year ago

mdmintz commented 1 year ago

Refactor file generators

Console scripts for the chart generator and the presentation generator are missing the BaseCase.main(__name__, __file__) line, which allows running directly with python instead of pytest. The test generator could also use some refactoring.

For a refresher, here are the descriptions of those console scripts / commands:

  ** mkchart **

  Usage:
           seleniumbase mkchart [FILE.py] [LANG]
           OR:    sbase mkchart [FILE.py] [LANG]
  Example:
           sbase mkchart new_chart.py --en
  Language Options:
           --en / --English    |    --zh / --Chinese
           --nl / --Dutch      |    --fr / --French
           --it / --Italian    |    --ja / --Japanese
           --ko / --Korean     |    --pt / --Portuguese
           --ru / --Russian    |    --es / --Spanish
  Output:
           Creates a new SeleniumBase chart presentation.
           If the file already exists, an error is raised.
           By default, the slides are written in English,
           and use a "sky" theme with "slide" transition.
           The chart can be used as a basic boilerplate.
  ** mkpres **

  Usage:
           seleniumbase mkpres [FILE.py] [LANG]
           OR:    sbase mkpres [FILE.py] [LANG]
  Example:
           sbase mkpres new_presentation.py --en
  Language Options:
           --en / --English    |    --zh / --Chinese
           --nl / --Dutch      |    --fr / --French
           --it / --Italian    |    --ja / --Japanese
           --ko / --Korean     |    --pt / --Portuguese
           --ru / --Russian    |    --es / --Spanish
  Output:
           Creates a new presentation with 3 example slides.
           If the file already exists, an error is raised.
           By default, the slides are written in English,
           and use "serif" theme with "slide" transition.
           The slides can be used as a basic boilerplate.
  ** mkfile **

  Usage:
           seleniumbase mkfile [FILE.py] [OPTIONS]
           OR:    sbase mkfile [FILE.py] [OPTIONS]
  Example:
           sbase mkfile new_test.py
  Options:
           -b / --basic  (Basic boilerplate / single-line test)
           -r / --rec  (adds Pdb+ breakpoint for Recorder Mode)
  Language Options:
           --en / --English    |    --zh / --Chinese
           --nl / --Dutch      |    --fr / --French
           --it / --Italian    |    --ja / --Japanese
           --ko / --Korean     |    --pt / --Portuguese
           --ru / --Russian    |    --es / --Spanish
  Syntax Formats:
           --bc / --basecase  (BaseCase class inheritance)
           --pf / --pytest-fixture  (sb pytest fixture)
           --cf / --class-fixture  (class + sb pytest fixture)
           --cm / --context-manager  (SB context manager)
           --dc / --driver-context  (DriverContext manager)
           --dm / --driver-manager  (Driver manager)
  Output:
           Creates a new SBase test file with boilerplate code.
           If the file already exists, an error is raised.
           By default, uses English with BaseCase inheritance,
           and creates a boilerplate with common SeleniumBase
           methods: "open", "type", "click", "assert_element",
           and "assert_text". If using the basic boilerplate
           option, only the "open" method is included. Only the
           BaseCase format supports Languages or Recorder Mode.
mdmintz commented 1 year ago

This was resolved by 4.15.15 - https://github.com/seleniumbase/SeleniumBase/releases/tag/v4.15.15