运行playwright测试用例报错:
1、如果是在跑测试的时候报错,在创建上下文时设置ignore_https_errors=True就可以了,如:
from idlelib import browser from playwright.sync_api import Playwright def getPage(playwright: Playwright): chromium = playwright.chromium browser = chromium.launch(headless=False) page = browser.new_page(ignore_https_errors=True) # 解决报错问题 return page def test_has_title(playwright: Playwright): page = getPage(playwright) page.goto("https://www.test.com") expect(page).to_have_title(re.compile("XXXX")) # other actions... browser.close()
2、如果是在录制脚本的时候报错,那就是在playwright codegen命令后添加–ignore-https-errors参数即可,如:
playwright codegen --ignore-https-errors https://www.test.com/
标签:errors,NAME,ignore,playwright,报错,https,page From: https://www.cnblogs.com/liyuanhong/p/18357202