SeldomQA / seldom

Seldom automation testing framework based on unittest
https://seldomqa.github.io/
Apache License 2.0
803 stars 328 forks source link

Web UI 自动化测试建议可以手动初始化 driver #224

Closed xianyiLuo closed 5 months ago

xianyiLuo commented 5 months ago
    def test_case(self):
        """
        A simple test
        """
        page = BaiduPage(self.driver, print_log=True)
        page.open("https://www.baidu.com")
        page.search_input.send_keys("seldom")
        page.search_button.click()
        self.assertTitle("seldom_百度搜索")

官方 Web UI 测试 - Page Object 文档中的教程,这段代码 page = BaiduPage(self.driver, print_log=True),这里传入 self.driver 是 None,会报错,主动赋值 self.driver 显示为只读属性,只能通过 self.open() 才能初始化 driver

xianyiLuo commented 5 months ago

看了源代码发现seldom.TestCase 类下面有个 browser() 可以解决上面问题。