SeleniumBase core areas
Basic API (test methods). Example test:
from seleniumbase import BaseCase class TestMFALogin(BaseCase): def test_mfa_login(self): self.open("seleniumbase.io/realworld/login") self.type("#username", "demo_user") self.type("#password", "secret_pass") self.enter_mfa_code("#totpcode", "GAXG2MTEOR3DMMDG") self.assert_text("Welcome!", "h1") self.highlight("img#image1") self.click('a:contains("This Page")') self.save_screenshot_to_logs() self.click_link("Sign out") self.assert_element('a:contains("Sign in")')
Command-line options. Examples:
$ pytest my_first_test.py $ pytest test_swag_labs.py --mobile $ pytest edge_test.py --browser=edge $ pytest basic_test.py --headless $ pytest my_first_test.py --demo --guest $ pytest basic_test.py --slow $ pytest -v -m marker2 --headless --save-screenshot $ pytest parameterized_test.py --reuse-session $ pytest test_suite.py --html=report.html --rs $ pytest test_suite.py --dashboard --html=report.html $ pytest github_test.py --demo --disable-csp $ pytest test_suite.py -n=2 --rs --crumbs $ pytest test_demo_site.py --incognito $ pytest verify_undetected.py --uc $ pytest basic_test.py --sjw --pls=none
The Console Scripts interface. Examples:
$ sbase get chromedriver $ sbase mkdir new_test_folder $ sbase mkfile new_test.py $ sbase mkpres new_presentation.py $ sbase mkchart new_chart.py $ sbase print basic_test.py -n $ sbase translate basic_test.py -p --ru -n $ sbase grid-hub start $ sbase grid-node start --hub="127.0.0.1" $ sbase grid-node stop $ sbase grid-hub stop $ sbase recorder $ sbase commander $ sbase methods $ sbase options
Advanced API. "Presenter" example:
from seleniumbase import BaseCase class MyPresenterClass(BaseCase): def test_presenter(self): self.create_presentation(theme="serif") self.add_slide("Welcome to Presenter!") self.add_slide( "Add code to slides:", code=( "from seleniumbase import BaseCase\n\n" "class MyPresenterClass(BaseCase):\n\n" " def test_presenter(self):\n" " self.create_presentation()\n")) self.begin_presentation( filename="demo.html", show_notes=True)
The End