目前 playwright- Python 还是不完善 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
hanssx

目前 playwright- Python 还是不完善

  •  
  •   hanssx 2023 年 11 月 15 日 1684 次点击
    这是一个创建于 891 天前的主题,其中的信息可能已经有所发展或是发生改变。

    今天发现一个 BUG ,主要是开启调试的情况下,运行完会导致浏览器 crash ,插件全部 crash (和插件本身无关),相关 issue: https://github.com/microsoft/playwright-python/issues/2160

    我这边目前 100%复现,代码很简单,我贴一个,有兴趣的可以复现一下。


    "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-address=0.0.0.0 --remote-debugging-port=2333 --new-window https://www.google.com 

    playwright 代码

    from playwright.sync_api import Playwright, sync_playwright, expect def run(playwright: Playwright) -> None: browser = playwright.chromium.connect_over_cdp('http://127.0.0.1:2333') cOntext= browser.contexts[0] # context.tracing.start(screenshots=True, snapshots=True, sources=True) page = context.pages[0] page.goto("https://www.baidu.com/") # context.tracing.stop(path = "trace.zip") # page.close() # 加上 page.close()可以解决,但是会关闭网页啊,这没法继续后面的操作了。 # context.close() # browser.close() with sync_playwright() as playwright: run(playwright) 

    selenium 代码

    from selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options chrome_service = Service('./chromedriver.exe') chrome_optiOns= Options() chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:2333") driver = wedriver.Chrome(service=chrome_service, optiOns=chrome_options) driver.get('https://www.baidu.com/') 
    第 1 条附言    2023 年 11 月 16 日
    我收回昨天的话,playwright 可以自动处理 shadow root ,selenium 没法自动处理 shadow root ,其实各有优劣。
    第 2 条附言    2023 年 11 月 16 日
    解决了,我自己的问题,playwright 版本和 chrome 版本不对应导致,应该严格遵守 github release page 上面的版本对应关系,118 的 chrome 就不会崩溃了。
    hanssx
        1
    hanssx  
    OP
       2024 年 2 月 21 日
    今天发现 playwright 有头定位元素是根据前端视窗定位的?而不是根据前端源码?当我定位某个页面元素时,虽然它存在于前端源码中,但在当前分辨率下并没有出现在屏幕上,比如说有一个水平的滑动窗口,可以通过向左和向右的按钮来控制窗口中显示不同的内容,当前没有显示的话, 这种情况下定位会导致视口上下晃动,直到发生 timeout 错误。

    相关 issue: https://github.com/microsoft/playwright/issues/21784
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     4394 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 30ms UTC 10:02 PVG 18:02 LAX 03:02 JFK 06:02
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86