typescriptcucumberjsspectron

Electron app not completely visible on test execution server


I have been having some issues with executing my cucumber scenarios successfully because, for some unknown reason, the electron app we are testing isn't completely shown (table with 1 missing column on the right). For some reason, this only happens on our windows test execution server, not on my local laptop. Server resolution is 1920x1080. Tests are started via Azure DevOps Server pipeline.

We test the electron app via spectron with the cucumber-js framework in typescript.

import * as path from 'path';

import { Application } from 'spectron';

import * as settings from './globalvars';

export const SUT = new Application({
  path: `${settings.sutExecutablePath}`,
  args: [path.join(__dirname, '../'), '--headless', '--window-size=1920,1080'],
  env: {
    RUNNING_IN_SPECTRON: true,
    XXXXXX_DEV_TOOLS: false,
    SPECTRON_AUTOMATION_VARS: settings.testDataIndex
  },
  chromeDriverArgs: ['--headless', '--window-size=1920,1080', 'resolution=1920x1080', 'resolution: 1920x1080', '--width=1920', '--height=1080'],
  chromeDriverLogPath: path.join(settings.reportPath, 'chromedriver.log'),
  waitTimeout: settings.spectronDefaultImplicitWaitTimeout
});

I have been messing around with:

none of the changes seem to have any impact on how the application is started, in fact, changing the window size or starting it maximized doesn't even have any effect on my laptop as well.

this is a snippet of the chromedriver log. Had to redact it but could still be usefull.

[1623923272.920][INFO]: Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
[1623923272.989][INFO]: [c56aabc7011e3a87307e2b8d55b9f003] COMMAND InitSession {
   "capabilities": {
      "alwaysMatch": {
         "goog:chromeOptions": {
            "args": [ "spectron-path=c:\\xxxx\\xxxx\\win-unpacked\\xxxxxx.exe", "spectron-arg0=C:\\git\\xxxxx\\02-sxxxx\\", "spectron-env-RUNNING_IN_SPECTRON=true", "spectron-env-xxxxx_DEV_TOOLS=false", "spectron-env-SPECTRON_AUTOMATION_VARS=C:\\git\\xxxx.xxxxxx\\automation-vars.json", "--window-size=800,600" ],
            "binary": "C:\\git\\xxxx\\02-xxxxxx\\node_modules\\spectron\\lib\\launcher.bat",
            "windowTypes": [ "app", "webview" ]
         }
      },
      "firstMatch": [ {

      } ]
   },
   "desiredCapabilities": {
      "goog:chromeOptions": {
         "args": [ "spectron-path=c:\\xxxxx\\xxxxxxx\\win-unpacked\\xxxxxx.exe", "spectron-arg0=C:\\git\\xxxxxx\\02-xxxxxxx\\", "spectron-env-RUNNING_IN_SPECTRON=true", "spectron-env-xxxxxxxx_DEV_TOOLS=false", "spectron-env-SPECTRON_AUTOMATION_VARS=C:\\git\\xxxxxx\\automation-vars.json", "--window-size=800,600" ],
         "binary": "C:\\git\\xxxxx\\02-xxxxxxxxxxxmodules\\spectron\\lib\\launcher.bat",
         "windowTypes": [ "app", "webview" ]
      }
   }
}

[1623923272.994][INFO]: Launching chrome: "C:\git\xxxxxxxx\02-xxxxxxx\node_modules\spectron\lib\launcher.bat" --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-blink-features=ShadowDOMV0 --enable-logging --log-level=0 --no-first-run --no-service-autorun --password-store=basic --remote-debugging-port=0 --spectron-arg0="C:\git\xxxxxxxxx\02-xxxxxxx\\" --spectron-env-running_in_spectron=true --spectron-env-xxxxx_dev_tools=false --spectron-env-spectron_automation_vars="C:\git\xxxxxxxx\automation-vars.json" --spectron-path="c:\bxxxxxxx\xxxxxxxxxx\win-unpacked\xxxxxxx.exe" --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\xxxxx\AppData\Local\Temp\scoped_dir33580_700219467" --window-size=800,600 data:,
[1623923273.323][DEBUG]: DevTools HTTP Request: http://localhost:54323/json/version
[1623923273.637][DEBUG]: DevTools HTTP Response: {

   "Browser": "Chrome/87.0.4280.141",

   "Protocol-Version": "1.3",

   "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) xxxxxxxx/1.0.0-alpha.2022 Chrome/87.0.4280.141 Electron/11.2.2 Safari/537.36",

   "V8-Version": "8.7.220.31",

   "WebKit-Version": "537.36 (@5236eb7c7e51a459c497e4ab474bf474ad7000ef)",

   "webSocketDebuggerUrl": "ws://localhost:54323/devtools/browser/62881ab4-ea89-4b48-b75e-4234f709931b"

}


[1623923273.637][DEBUG]: DevTools HTTP Request: http://localhost:54323/json/list
[1623923273.639][DEBUG]: DevTools HTTP Response: [ {

   "description": "",

   "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:54323/devtools/page/30283E47D490358108E12219527675CE",

   "id": "30283E47D490358108E12219527675CE",

   "title": "index.html",

   "type": "page",

   "url": "file:///C:/xxxxxxxxx/xxxxxxxxx/win-unpacked/resources/app.asar/build/index.html",

   "webSocketDebuggerUrl": "ws://localhost:54323/devtools/page/30283E47D490358108E12219527675CE"

} ]
"test:inProgress": "node ./node_modules/cucumber/bin/cucumber-js feature-files/*.feature --format summary --format progress-bar --format node_modules/cucumber-pretty --logLevel=error --require step-definitions/**/*.ts --require-module ts-node/register --require support/*.ts --format json:../reports/02-xxxx/cucumber-report.json --format node_modules/cucumber-junit-formatter:../reports/02-xxxx/testresults.junit --format-options '{\"scenarioAsStep\":true}' --tags \"@inProgress\"",
    "devDependencies": {
    "@cucumber/cucumber": "^7.0.0",
    "@types/chai": "^4.2.14",
    "@types/cucumber": "^6.0.1",
    "@types/jsonpath": "^0.2.0",
    "@types/xml2js": "^0.4.8",
    "@typescript-eslint/eslint-plugin": "^4.4.0",
    "@typescript-eslint/parser": "^4.4.0",
    "chai": "^4.2.0",
    "cucumber": "^6.0.5",
    "cucumber-html-reporter": "^5.3.0",
    "cucumber-junit-formatter": "^0.2.2",
    "cucumber-pretty": "^6.0.0",
    "date-fns": "^2.21.3",
    "electron": "^10.0.0",
    "eslint": "^7.11.0",
    "eslint-config-prettier": "^7.1.0",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-prettier": "^3.3.1",
    "filecompare": "^1.0.4",
    "jsonpath": "^1.1.0",
    "prettier": "2.2.0",
    "spectron": "^13.0.0",
    "ts-node": "^9.1.1",
    "typescript": "^4.1.3",
    "xml2js": "^0.4.23"
  },```


Solution

  • For anyone that might encounter this issue in the future. What solved my issue was pretty basic. Just had to set the bounds of the client application manually.

    SUT.browserWindow.setSize(1920, 1080);
    SUT.browserWindow.setPosition(0, 0);