SeleniumBase core areas
Basic API (test methods). Example test:
from seleniumbase import BaseCase class MyTestClass(BaseCase): def test_basics(self): self.open("https://store.xkcd.com/search") self.type('input[name="q"]', "xkcd book\n") self.assert_text("xkcd book", "div.results") self.open("https://xkcd.com/353/") self.click('a[rel="license"]') self.go_back() self.click_link("About") self.click_link("comic #249") self.assert_element('img[alt*="Chess"]')
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 basic_test.py --incognito
The Console Scripts interface. Examples:
$ sbase install chromedriver $ sbase install chromedriver latest $ sbase mkdir new_test_folder $ sbase mkfile new_test.py $ sbase print basic_test.py -n $ sbase translate basic_test.py -p --chinese -n $ sbase translate basic_test.py -p --japanese $ sbase translate basic_test.py -c --russian $ sbase download server $ sbase grid-hub start $ sbase grid-node start --hub="127.0.0.1" $ sbase grid-node stop $ sbase grid-hub stop $ 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