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
wq2016
V2EX  ›  Python

Selenium 当页面 JS 触发之后,页面加载了新的内容, driver 如何获取?

  •  1
     
  •   wq2016 · 2016-02-21 20:42:42 +08:00 · 3465 次点击
    这是一个创建于 2958 天前的主题,其中的信息可能已经有所发展或是发生改变。

    当我执行一个 click 动作之后,页面加载了更多的内容,这个时候, driver 应该如何做才能获取新的内容呢?

    4 条回复    2016-02-22 23:23:37 +08:00
    hantsy
        1
    hantsy  
       2016-02-21 22:22:22 +08:00
    页面 End 2 End 测试用高级一点 Geb/Spock 更简单一些, JS 交互也不会有问题。
    wq2016
        2
    wq2016  
    OP
       2016-02-22 11:00:33 +08:00
    @hantsy 用的 Python , Spock 是 JAVA 平台的吧?
    finfou
        3
    finfou  
       2016-02-22 21:53:29 +08:00
    selenium 操作的是当前浏览器显示的内容, driver 获取的就是最新的内容,只是通常要确保页面加载完成,比如  selenium.webdriver.support.ui.WebDriverWait
    wq2016
        4
    wq2016  
    OP
       2016-02-22 23:23:37 +08:00
    @finfou 对的,现在已经解决了,在 StackOverFlow 上问了~
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3012 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 15:04 · PVG 23:04 · LAX 08:04 · JFK 11:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.