测试之家
  • 社区
  • 问答
  • 招聘
  • 社区学堂新
  • 开源项目
  • 活动
  • Wiki
  • 注册
  • 登录
会员
liujin (禅)
第 63755 位会员 / 2021-08-19
1 篇帖子 • 8 条回帖
0 关注者
0 正在关注
0 收藏
未设置 GitHub 信息.
  • 個人信息
  • 個人專欄
  • 帖子
  • 回帖
  • 收藏
  • 正在關注
  • 關注者
  • 热门话题
  • 最近回帖
  • Selenium 如何通过 selenium 获得 Chrome 浏览器中 Console 输出的数据信息。
    0 个赞 / 12 条回复
  • 如何通过 selenium 获得 Chrome 浏览器中 Console 输出的数据信息。 at 2024年03月14日

    感觉像是 selenium 版本问题

  • 如何通过 selenium 获得 Chrome 浏览器中 Console 输出的数据信息。 at 2023年06月12日

    我看这个用法是这样的,拿的数据里面好像没有要找的 array 数组诶

    import json
    
    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
    chrome_options = Options()
    chrome_options.add_argument("--enable-logging")
    
    capabilities = DesiredCapabilities.CHROME.copy()
    # capabilities['goog:loggingPrefs'] = {'browser': 'ALL'}
    capabilities["goog:loggingPrefs"] = {"performance": "ALL"}
    driver = webdriver.Chrome(options=chrome_options, desired_capabilities=capabilities)
    driver.get('https://testerhome.com/topics/36719')
    
    # 获取控制台日志
    
    # logs = driver.get_log('browser')
    browser_log_list = driver.get_log("performance")
    logs = [json.loads(log['message'])['message'] for log in browser_log_list]
    # for entry in logs:
    #     print(entry)
    #     print(entry['message'])
    # logs_2 = driver.execute_script("return window.console.logs")
    # print(logs_2)
    print(logs)
    # 关闭浏览器
    driver.quit()
    
  • 如何通过 selenium 获得 Chrome 浏览器中 Console 输出的数据信息。 at 2023年06月12日

    空的诶

  • 如何通过 selenium 获得 Chrome 浏览器中 Console 输出的数据信息。 at 2023年06月12日

    是拿到值了,但是 message 中的值 是字符串 array(6),而我想要的是一个 array 的数组中的数据。
    print(entry['message']) 的话,只会打印出来图中的内容。

  • 如何通过 selenium 获得 Chrome 浏览器中 Console 输出的数据信息。 at 2023年06月12日

    执行完成之后没有返回数据,有什么可以办法可以拿到数据吗。

  • 如何通过 selenium 获得 Chrome 浏览器中 Console 输出的数据信息。 at 2023年06月12日

    之前也看过类似的方法。目前会在执行 js 脚本的时候报错

关于 / 活跃用户 / 中国移动互联网测试技术大会 / 反馈 / Github / API / 帮助推广
TesterHome社区,测试之家,由众多测试工程师组织和维护的技术社区,致力于帮助新人成长,提高测试地位,推进质量发展。Inspired by RubyChina
友情链接 WeTest腾讯质量开放平台 / InfoQ / 掘金 / SegmentFault / 测试窝 / 百度测试吧 / IT大咖说
简体中文 / 正體中文 / English

©testerhome.com 测试之家   渝ICP备2022001292号
  渝公网安备 50022202000435号    版权所有 © 重庆年云聚力信息技术有限公司