點此獲取更多相關(guān)資料
本文為霍格沃茲測試開發(fā)學(xué)社學(xué)員學(xué)習(xí)筆記分享
原文鏈接:https://ceshiren.com/t/topic/27185
一、多瀏覽器測試介紹
1.1、多瀏覽器測試背景
- 用戶使用的瀏覽器(firefox,chrome,IE 等)
- web 應(yīng)用應(yīng)該能在任何瀏覽器上正常的工作,這樣能吸引更多的用戶來使用
1.2、多瀏覽器測試概述
- 是跨不同瀏覽器組合驗證網(wǎng)站或 web 應(yīng)用程序功能的過程
- 是兼容性測試的一個分支,用于保持功能和質(zhì)量的一致性
- 適用于面向客戶的網(wǎng)站和組織內(nèi)部使用的站點
二、多瀏覽器測試實現(xiàn)
2.1、多瀏覽器的實現(xiàn)方案
actor 測試工程師 as tester
participant 命令行參數(shù) as command
participant 配置信息 as config
participant 底層代碼 as code
autonumber
tester -> command : 通過命令執(zhí)行測試用例,通過參數(shù)指定瀏覽器: pytest --browser=Chrome
command -> config : 獲得配置信息
config -> code: 傳給底層代碼,使用配置信息
2.2、pytest hook 函數(shù)
-
pytest_addoption
添加命令行參數(shù)組/命令行參數(shù) -
pytest_configure
解析命令行選項,每個插件都會用到這個hook函數(shù)
2.3、pytest_addoption 與 pytest_configure
-
pytest_addoption:文章來源:http://www.zghlxwxcb.cn/news/detail-705352.html
- parser.getgroup 創(chuàng)建/獲取組名
- addoption 添加一個命令行選項
-
pytest_configure:文章來源地址http://www.zghlxwxcb.cn/news/detail-705352.html
- 通過config 對象的getoption()方法獲取命令行參數(shù)
- 將命令行獲取到的內(nèi)容賦值給變量
web_env = {}
def pytest_addoption(parser: Parser):
hogwarts = parser.getgroup("hogwarts")
hogwarts.addoption("--browser", default='Chrome', dest='browser')
def pytest_configure(config: Config):
browser = config.getoption("--browser", default="Chrome")
print(f"通過命令行獲取到的瀏覽器為{browser}")
web_env["browser"] = browser
到了這里,關(guān)于軟件測試/測試開發(fā)丨Selenium Web自動化多瀏覽器處理的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!