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?
Asked
Active
Viewed 50 times
1
-
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jun 21 '22 at 01:14
1 Answers
0
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)

Michael Mintz
- 9,007
- 6
- 31
- 48