支持更多测试库
seldom 集成了selenium
、appium
、requests
,他们都是非常优秀且成熟的库,这并不是说,你不能在seldom使用别的测试库。
seldom 作为一个测试框架,理论上可以与任何测试库一起使用。
seldom + playwright
playwright就微软推出的优秀的 web UI 自动化测试库。
官方地址: https://playwright.dev/
- pip 安装
> pip install playwright
- 使用例子
import seldom
from playwright.sync_api import sync_playwright
from playwright.sync_api import expect
class Playwright(seldom.TestCase):
def start(self):
p = sync_playwright().start()
self.browser = p.chromium.launch()
self.page = self.browser.new_page()
def end(self):
self.browser.close()
def test_start(self):
page = self.page
page.goto("http://playwright.dev")
print(page.title())
expect(page).to_have_title("Fast and reliable end-to-end testing for modern web apps | Playwright")
get_started = page.locator('text=Get Started')
expect(get_started).to_have_attribute('href', '/docs/intro')
get_started.click()
expect(page).to_have_url('http://playwright.dev/docs/intro')
if __name__ == '__main__':
seldom.main()
seldom + uiautomator2
uiautomator2是openatx推出的优秀的Android自动化测试工具,Api简单,同样得到广泛应用。
github地址: https://github.com/openatx/uiautomator2
- pip安装
pip install uiautomator2
- 使用例子
import seldom
import uiautomator2 as u2
class MyAppTest(seldom.TestCase):
def start(self):
# 链接设备
self.d = u2.connect('192.168.31.234')
# 启动App
self.d.app_start("com.meizu.mzbbs")
def end(self):
# 停止app
self.d.app_stop("com.meizu.mzbbs")
def test_app(self, user):
""" 使用 uiautomator2 """
# 搜索
self.d(resourceId="com.meizu.flyme.flymebbs:id/nw").click()
# 输入关键字
self.d(resourceId="com.meizu.flyme.flymebbs:id/nw").set_text("flyme")
# 搜索按钮
self.d(resourceId="com.meizu.flyme.flymebbs:id/o1").click()
self.sleep(2)
if __name__ == '__main__':
seldom.main(debug=True)