自动化神器Playwright-python(3)-设备仿真

2024-04-18 09:30:21 浏览数 (1)

自动化神器Playwright-python(3)-设备仿真

playwright可通过浏览器的设备仿真技术, 测试移动端应用

设备仿真

代码语言:javascript复制
from playwright.sync_api import sync_playwright
from loguru import logger

def run():
    with sync_playwright() as pw:
        # 获取设备配置信息
        iphone14 = pw.devices['iPhone 14']
        # 初始化一个设备环境, 打开页面
        browser = pw.chromium.launch(headless=False)
        context = browser.new_context(**iphone14)
        page = context.new_page()
        page.goto("http://baidu.com")
        page.pause()

0 人点赞