我可以在Seleniumbase框架中更新基本酶类吗?

发布于 2025-02-08 19:00:10 字数 97 浏览 0 评论 0原文

我正在使用硒基框架进行自动化。我们已内置的类是基本酶。在这里,我的应用程序具有带有所需访问权限的不同用户集。我可以创建一种用于登录基本酶中不同用户集的方法,并在测试用例中调用它吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红ご颜醉 2025-02-15 19:00:10

这是您刚才描述的一个示例:(

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")

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)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文