SeeTraffic & Grabbing network traffic not working

未关闭
#4,524 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
javascript
领域
testing

调研方向

首先,使用提供的 WebDriver 配置以及 seeTraffic 和 grabRecordedNetworkTraffics 调用重现该问题。检查 helper/network/utils.js 中的 startRecordingTraffic 和 RequestPostDataObject,包括第 101 行报告的用法。完成的标准是:记录的流量包含已填充的 response 字段,并且 seeTraffic 能正确评估 requestPostData,而不是无条件地传递它。

由索引模型根据 Issue 内容生成。

描述

What are you trying to achieve?

I am trying to use seeTraffic and grabRecordedNetworkTraffics functions. grab* function is returning array with empty values or each field. seeTraffic is always passing because it is not able to assert on 'requestPostData'

What do you get instead?

for grabRecordedNetworkTraffics I am getting empty values like below:

for seeTraffic, it is always passing.

As per my analysis,

  1. For grabRecordedNetworkTraffics, startRecordingTraffic() always returning data with _response = null. Which is causing grabRecordedNetworkTraffics to return empty values.

  2. For seeTraffic API call, I found that variable 'RequestPostDataObject' inside helper/network/utils.js is stringified but it is being used as object at line number 101 in the file.

Provide console output if related. Use --verbose mode for more details.

I grab recorded network traffics 
Network traffic [
  { url: '', response: { status: '', statusText: '', body: '' } },
  { url: '', response: { status: '', statusText: '', body: '' } }
]
    I stop recording traffic 
  ✔ OK in 15331ms
I.amOnPage(`http://localhost:3000`);
  
    I.startRecordingTraffic();
    I.click('[data-testid="capture-button"]');
    I.wait(3);
    I.seeTraffic({
        name: 'random', // not sure what to put here
        url: 'http://localhost:3000/mock-data',
        // parameters: { key: 'value' },
        requestPostData: {
            operations: [
                {
                   //some data
                },
            ],
       }     
    });
    const networkTraffic2 = await I.grabRecordedNetworkTraffics();
    console.log('Network traffic', networkTraffic2);
Details

I am trying to assert some network API payload so that I can ensure, on submitting a form it is sending the correct data.

  • CodeceptJS version: 3.6.3-beta.2
  • NodeJS Version: 20.16.0 /16.14.2
  • Operating System: Mac
  • puppeteer || webdriverio || testcafe version (if related) webdriverio
  • Configuration file:
 helpers: {
        WebDriver: {
            url: getBaseUrl(),
            browser: 'chrome',
            windowSize: '1366x768',
            desiredCapabilities: {
                chromeOptions: {
                    args: [
                        ...webDriverAdditionalArgs,
                        '--no-sandbox',
                        '--unexpectedAlertBehavior=accept',
                        '--unhandledPromptBehavior=accept',
                    ],
                },
主要语言
JavaScript
星标
4.2k
派生
756
平均合并
2 天 9 小时
30 天内合并 PR
16

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

codeceptjs/CodeceptJS 的其他 Issue

查看 codeceptjs/CodeceptJS 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。