CodeceptJS icon indicating copy to clipboard operation
CodeceptJS copied to clipboard

Wrong window size is used in next tests after using I.resizeWindow()

Open chilikasha opened this issue 5 years ago • 3 comments

What are you trying to achieve?

run tests on different viewports

What do you get instead?

I have several tests in my suit. most of them use window size set in codecept.conf.js. But in some tests in Before hook I have I.resizeWindow(375, 812). what I get is:

  1. firstly some tests with default viewport are executed
  2. then a test with I.resizeWindow(375, 812) is executed
  3. after this ALL tests (even without I.resizeWindow() command) are executed on (375, 812) window size.

I was only able to stop this behavior with restart: true,

Details

  • CodeceptJS version: 2.6.8
  • NodeJS Version: 12.6.3
  • Operating System: Mac OS Mojave / Ubuntu
  • Playwright 1.3.0
  • Configuration file:
const { setHeadlessWhen } = require("@codeceptjs/configure")

// turn on headless mode when running with HEADLESS=true environment variable
// HEADLESS=true npx codecept run
setHeadlessWhen(process.env.HEADLESS)

exports.config = {
  tests: "./tests/*.js",
  output: "./output",
  helpers: {
    Playwright: {
      url: process.env.URL || "https://some.url",
      browser: "chromium",
      show: true,
      restart: true,
      windowSize: "1440x900",
      chromium: {
        args: [
          "--no-sandbox",
          "--disable-dev-shm-usage",
        ],
        defaultViewport: {
          width: 1440,
          height: 900,
        },
      },
      waitForAction: 200,
      waitForNavigation: "load",
      getPageTimeout: 30000,
      waitForTimeout: 5000,
    },
    ChaiWrapper: {
      require: "codeceptjs-chai",
    },
    ifElementExists: {
      require: "./helpers/ifElementExists.js",
    },
    extendWithPlaywright: {
      require: "./helpers/accessPlaywright.js",
    },
    REST: {
      // endpoint: config.url,
    },
  },
  multiple: {
    basic: {
      browsers: ["chromium"],
    },
    firefox: {
      grep: "@firefox",
      browsers: ["firefox"],
    },
  },
  include: {
    // some files here
  },
  bootstrap: null,
  mocha: {},
  name: "web-app-tests",
  plugins: {
    retryFailedStep: {
      retries: 3,
      enabled: true,
      defaultIgnoredSteps: ["amOnPage", "wait*"],
    },
    screenshotOnFail: {
      enabled: true,
    },
    customLocator: {
      enabled: true,
      attribute: "data-testid",
    },
  },
}

chilikasha avatar Aug 16 '20 14:08 chilikasha

same happens in v.3 and even if I set:

restart: false,
keepBrowserState: false

chilikasha avatar Oct 19 '20 14:10 chilikasha

What about 3.1.0? still there?

DavertMik avatar Sep 05 '21 18:09 DavertMik

@DavertMik I have the same issue with viewport when opened new tab. It resised to default value. It looks like the context is lost when opening a new tab. It ease to test - open any page in browser and click to add new tab.

my packages: playwright: 1.17.1 codeceptjs: 3.2.2

DerFersy avatar Dec 20 '21 12:12 DerFersy

Closed for now! Feel free to reopen if you still encounter the issue with latest version and would be nice to provide a sample code to reproduce the issue.

kobenguyent avatar Feb 05 '24 09:02 kobenguyent