Can i update BaseCase class in seleniumbase framework?

Viewed 24

I'm using selenium base framework for automation. we have inbuilt class as BaseCase. Here, my application has different set of users with desired access.can i create a method for logging to different set of users in BaseCase and call it in test case?

1 Answers

Here's an example of what you just described:

from seleniumbase import BaseCase

class SwagLabsTests(BaseCase):
    def login_to_swag_labs(self, username="standard_user"):
        """Login to Swag Labs and verify success."""
        self.open("https://www.saucedemo.com")
        if username not in self.get_text("#login_credentials"):
            self.fail("Invalid user for login: %s" % username)
        self.type("#user-name", username)
        self.type("#password", "secret_sauce")
        self.click('input[type="submit"]')
        self.assert_element("div.inventory_list")
        self.assert_element('.inventory_item:contains("Sauce Labs Backpack")')

    def test_swag_labs_basic_flow(self):
        """This test checks functional flow of the Swag Labs store."""
        self.login_to_swag_labs(username="standard_user")

(From test_swag_labs.py)

Related