SeleniumBase core areas

Basic API (Test methods/functions) Example

from seleniumbase import BaseCase

class MyTestClass(BaseCase):

    def test_basic(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_text("About")
        self.click_link_text("comic #249")
        self.assert_element('img[alt*="Chess"]')

Command-line Options Example

$ 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
$ pytest basic_test.py --slow
$ pytest -v -m marker2 --headless --save-screenshot
$ pytest test_suite.py --reuse-session --html=report.html
$ pytest basic_test.py --incognito
$ pytest parameterized_test.py --guest --reuse-session

Console scripts interface Example

$ 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 (creating a presentation) 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