SeleniumBase/examples/raw_parameter_script.py

89 lines
3.0 KiB
Python
Raw Normal View History

""" The main purpose of this file is to demonstrate running SeleniumBase
scripts without the use of Pytest by calling the script directly
with Python or from a Python interactive interpreter. Based on
2019-01-15 09:12:41 +08:00
whether relative imports work or don't, the script can autodetect
how this file was run. With pure Python, it will initialize
all the variables that would've been automatically initialized
2019-01-15 09:12:41 +08:00
by the Pytest plugin. The setUp() and tearDown() methods are also
now called from the script itself.
One big advantage to running tests with Pytest is that most of this
is done for you automatically, with the option to update any of the
parameters through command line parsing. Pytest also provides you
with other plugins, such as ones for generating test reports,
handling multithreading, and parametrized tests. Depending on your
specific needs, you may need to call SeleniumBase commands without
using Pytest, and this example shows you how. """
try:
# Running with Pytest / (Finds test methods to run using autodiscovery)
# Example run command: "pytest raw_parameter_script.py"
from .my_first_test import MyTestClass # (relative imports work: ".~")
except (ImportError, ValueError):
# Running with pure Python OR from a Python interactive interpreter
# Example run command: "python raw_parameter_script.py"
from my_first_test import MyTestClass # (relative imports DON'T work)
2019-09-16 17:14:29 +08:00
sb = MyTestClass("test_basic")
sb.browser = "chrome"
sb.headless = False
sb.headed = False
sb.start_page = None
sb.locale_code = None
2019-09-16 17:14:29 +08:00
sb.servername = "localhost"
sb.port = 4444
sb.data = None
sb.environment = "test"
sb.user_agent = None
2020-01-08 12:45:59 +08:00
sb.incognito = False
sb.guest_mode = False
sb.devtools = False
sb.mobile_emulator = False
sb.device_metrics = None
2019-09-16 17:14:29 +08:00
sb.extension_zip = None
sb.extension_dir = None
sb.database_env = "test"
sb.log_path = "latest_logs/"
sb.archive_logs = False
sb.disable_csp = False
sb.enable_ws = False
2019-09-16 17:14:29 +08:00
sb.enable_sync = False
sb.use_auto_ext = False
sb.no_sandbox = False
sb.disable_gpu = False
sb._reuse_session = False
sb._crumbs = False
2019-09-16 17:14:29 +08:00
sb.visual_baseline = False
sb.maximize_option = False
sb.save_screenshot_after_test = False
sb.timeout_multiplier = None
sb.pytest_html_report = None
sb.with_db_reporting = False
sb.with_s3_logging = False
sb.js_checking_on = False
sb.report_on = False
2019-09-16 17:14:29 +08:00
sb.is_pytest = False
2019-11-07 14:31:58 +08:00
sb.slow_mode = False
2019-09-16 17:14:29 +08:00
sb.demo_mode = False
sb.time_limit = None
2019-09-16 17:14:29 +08:00
sb.demo_sleep = 1
sb.message_duration = 2
sb.block_images = False
2019-09-16 17:14:29 +08:00
sb.settings_file = None
sb.user_data_dir = None
sb.proxy_string = None
sb.swiftshader = False
2019-09-16 17:14:29 +08:00
sb.ad_block_on = False
sb.highlights = None
sb.check_js = False
sb.cap_file = None
sb.cap_string = None
2019-09-16 17:14:29 +08:00
sb.setUp()
try:
2019-09-16 17:14:29 +08:00
sb.test_basic()
finally:
2019-09-16 17:14:29 +08:00
sb.tearDown()
del sb