【问题标题】:Is there is a way to detect data sent from client to server in Selenium?有没有办法在 Selenium 中检测从客户端发送到服务器的数据?
【发布时间】:2018-04-16 10:09:20
【问题描述】:

我正在使用 selenuim 和 phantomjs 开展一个项目。在填写表格并单击提交按钮后,我需要知道数据是发送到服务器还是未使用数据。我试图检查按下提交按钮后得到的 har 文件,但结果证明这是一个糟糕的解决方案。 还有其他方法吗?

谢谢。

【问题讨论】:

    标签: selenium phantomjs webtest


    【解决方案1】:

    我不知道您使用的是什么语言,但也许这些会有所帮助:

    using proxy and selenium

    BrowserMob 代理和 Selenium 示例

    from browsermobproxy import Server
    
        server = Server("path/to/browsermob-proxy")
        server.start()
        proxy = server.create_proxy()
    
        from selenium import webdriver
        profile  = webdriver.FirefoxProfile()
        profile.set_proxy(proxy.selenium_proxy())
        driver = webdriver.Firefox(firefox_profile=profile)
    
        proxy.new_har("google")
        driver.get("http://www.google.co.uk")
        proxy.har # returns a HAR JSON blob
    
        proxy.stop()
        driver.quit()
    

    post request and selenium

    在这种情况下,您必须:

    1. 使用 Java 发送帖子
    2. 添加 cookie
    3. 将所有内容发送到 Web 驱动程序

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-12
      相关资源
      最近更新 更多