推荐学习书目
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
pandameng
V2EX  ›  Python

selenium firefox 多标签页自动关闭问题

  •  
  •   pandameng · Jan 8, 2022 · 2322 views
    This topic created in 1605 days ago, the information mentioned may be changed or developed.
    python 3.9 selenium 4.1
    模拟手工操作,一窗口打开多页面等待到指定时间做后面流程.
    但过五六分钟后页面慢慢自动关闭,先打开的页面先被关闭,最后只剩一个页面,还没有相关日志.

    查了下资料大概有两种情况
    1.设置参数 options.set_preference('detach', True)解决
    2.pycharm 可能会回收内存,在命令行执行就没有问题

    两种都试了没有解决,而且 mac/windows 都会出现关闭现象,目前只能猜测
    1.最后还剩一个页面,那可能其他页面因为长时间未使用被垃圾回收了
    2.驱动 /浏览器版本不兼容或参数没起效果

    有思路的兄弟帮忙参考下
    Supplement 1  ·  Jan 8, 2022
    1.等待的时间内循环切换每个页面活动一下,无效果
    2."--headless"无页面后台,无效果
    2 replies    2022-01-09 20:23:51 +08:00
    Elliota
        1
    Elliota  
       Jan 9, 2022
    为什么要用 Firefox? 注意用主流工具, 这样未知 bug 会少一些
    pandameng
        2
    pandameng  
    OP
       Jan 9, 2022
    @Elliota 其他浏览器也会多多少少碰到一些问题,就目前 firefox 开发的比较顺利,除了当前碰到的 bug
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3024 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 14:59 · PVG 22:59 · LAX 07:59 · JFK 10:59
    ♥ Do have faith in what you're doing.