CodeceptJS icon indicating copy to clipboard operation
CodeceptJS copied to clipboard

Keep LocalStorage

Open Statfine opened this issue 4 years ago • 1 comments

What are you trying to achieve?

i want keep LocalStorage like keepCookies

What do you get instead?

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

My First Test --
  test something
    我 在页面 "https://....com/"
    我 保存屏幕截图 "see-first.jpg"
    我 看到 "text"
    我 等 2
    我 单击 "客户/广告主", ".ant-btn"
    我 wait for navigation 
    我 等待元素 ".right", 5
    我 单击 "账号登录", ".right"
    我 单击 "密码登录", ".TabR"
    我 填写字段 "#Authorize_username", "[email protected]"
    我 填写字段 "#Authorize_password", "123456"
    我 单击 "立即登录", ".ant-btn-primary"
    我 等 5
    我 保存屏幕截图 "see-chengfayun.jpg"
  ✔ OK in 14313ms

Provide test source code if related

// paste test
Feature('My First Test');

Scenario('test something', ({ I }) => {
  I.amOnPage('https://....com/');
  I.saveScreenshot("see-first.jpg")
  I.see('text');
  I.wait(2);
  I.click('客户/广告主', '.ant-btn');
  I.waitForNavigation();
  I.waitForElement('.right', 5);
  I.click('账号登录', '.right');
  I.click('密码登录', '.TabR');
  I.fillField('#Authorize_username', '[email protected]');
  I.fillField('#Authorize_password', '123456');
  I.click('立即登录', '.ant-btn-primary');
  I.wait(5)
  //截图
  I.saveScreenshot("see-chengfayun.jpg")
});

Details

  • CodeceptJS version: 3.0.7
  • NodeJS Version: v14.16.1
  • Operating System: macos
  • puppeteer
  • Configuration file:
# paste config here
exports.config = {
  tests: './*_test.js',
  output: './output',
  helpers: {
    Puppeteer: {
      url: 'http://localhost',
      show: true,
      windowSize: '1200x900',
      keepBrowserState: true,
    }
  },
  include: {
    I: './steps_file.js'
  },
  bootstrap: null,
  mocha: {},
  name: 'PuppeteerTests',
  translation: 'zh-CN',
  plugins: {
    pauseOnFail: {},
    retryFailedStep: {
      enabled: true
    },
    tryTo: {
      enabled: true
    },
    screenshotOnFail: {
      enabled: true
    }
  }
}

Statfine avatar Jul 30 '21 12:07 Statfine

The way I managed this was to store localStorage at the end of every test, and restore it at the start of every test as soon as the page url had been reached but before any of the page javascript had run. I'm happy to share more details on how to achieve this if you're interested.

finnmerlett avatar Feb 18 '22 15:02 finnmerlett