Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'browserName' of undefined #24

Closed
dkpalmer opened this issue Mar 13, 2019 · 6 comments
Closed

TypeError: Cannot read property 'browserName' of undefined #24

dkpalmer opened this issue Mar 13, 2019 · 6 comments

Comments

@dkpalmer
Copy link

Environment (please complete the following information):

  • Node.js version: v10.15.1
  • NPM version: yarn v1.12.0
  • webdriver.io version: wd v1.11.1
  • wdio-appium-service: v0.2.3
  • wdio-cucumber-framework version: v2.2.8
  • wdio-multiple-cucumber-html-reporter version: v0.3.3

Config of webdriver.io and the reporter

reporterOptions: {
    htmlReporter: {
      jsonFolder: './e2e/reports/json',
      reportFolder: './e2e/reports/html',
      displayDuration: true,
      removeFolders: 'true',
    },
  },

Describe the bug
Sometimes, a few seconds after running wdio for iOS simulators (native app) will return back TypeError: Cannot read property 'browserName' of undefined (stacktrace below). This is more frequent on CI and on new developer's machines.

Possibly related to the startup time of the iOS simulators? I tried to pre-load simulators in CI, but so far have still seen 1/2 runs fail with the same error.

To Reproduce
Steps to reproduce the behavior:

  • Fresh install, configure wdio to run a native app on an iOS simulator
  • Run wdio

Expected behavior

  • Tests begin as soon as simulators are ready, report generated after.

Snapshots
Log below.

Additional context

Log:

[18:10:42]  COMMAND	POST 	 "/wd/hub/session"
[18:10:42]  COMMAND	POST 	 "/wd/hub/session"
[18:10:42]  COMMAND	POST 	 "/wd/hub/session"
[18:10:42]  DATA		{"desiredCapabilities":{"javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"app":"./ios/build/DerivedData/Build/Products/Alpha-iphonesimulator/test.app","maxInstances":1,"noReset":true,"orientation":"PORTRAIT","platformName":"iOS","_":"5 more keys: [\"deviceName\",\"platformVersion\",\"metadata\",\"wdaLocalPort\",\"requestOrigins\"]"}}
[18:10:42]  DATA		{"desiredCapabilities":{"javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"app":"./ios/build/DerivedData/Build/Products/Alpha-iphonesimulator/test.app","maxInstances":1,"noReset":true,"orientation":"PORTRAIT","platformName":"iOS","_":"5 more keys: [\"deviceName\",\"platformVersion\",\"metadata\",\"wdaLocalPort\",\"requestOrigins\"]"}}
[18:10:42]  DATA		{"desiredCapabilities":{"javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"app":"./ios/build/DerivedData/Build/Products/Alpha-iphonesimulator/test.app","maxInstances":1,"noReset":true,"orientation":"PORTRAIT","platformName":"iOS","_":"5 more keys: [\"deviceName\",\"platformVersion\",\"metadata\",\"wdaLocalPort\",\"requestOrigins\"]"}}
/Users/distiller/test/node_modules/webdriverio/build/lib/utils/BaseReporter.js:336
                        throw _iteratorError;
                        ^

TypeError: Cannot read property 'browserName' of undefined
    at MultipleCucumberHtmlReporter.determineMetadata (/Users/distiller/test/node_modules/wdio-multiple-cucumber-html-reporter/build/reporter.js:375:54)
    at MultipleCucumberHtmlReporter.runnerResult (/Users/distiller/test/node_modules/wdio-multiple-cucumber-html-reporter/build/reporter.js:145:47)
    at MultipleCucumberHtmlReporter.emit (events.js:189:13)
    at MultipleCucumberHtmlReporter.EventEmitter.emit (domain.js:441:20)
    at BaseReporter.handleEvent (/Users/distiller/test/node_modules/webdriverio/build/lib/utils/BaseReporter.js:324:35)
    at Launcher.messageHandler (/Users/distiller/test/node_modules/webdriverio/build/lib/launcher.js:688:28)
    at ChildProcess.emit (events.js:189:13)
    at ChildProcess.EventEmitter.emit (domain.js:441:20)
    at emit (internal/child_process.js:820:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
error Command failed with exit code 1.
@dkpalmer
Copy link
Author

dkpalmer commented Mar 13, 2019

@wswebcreation This one is unfortunately pretty random. Do you have any insights into reasons why data.body.value is sometimes undefined, sometimes not? Also wondering if there is any harm in the reporter continuing without this value, or if there's any other way to wait for it to be available.

https://github.com/wswebcreation/wdio-multiple-cucumber-html-reporter/blob/master/lib/reporter.js#L332

@dkpalmer
Copy link
Author

@wswebcreation I put up a PR that works around the issue. Please let me know if you have any thoughts on it.

#25

@wswebcreation
Copy link
Owner

Hi @dkpalmer
Are you testing this with an app or with web? For web it should be there, for an app it will not be there. I need to solve it in a different way (never thought about it 🤦‍♂️ )

@dkpalmer
Copy link
Author

@wswebcreation Native app. It must be there sometimes because I do get successful test runs. I'll add some console logs and see what I get back.

@dkpalmer
Copy link
Author

So most of the time locally, I can verify data.body.value is not null:

{ webStorageEnabled: false,
  locationContextEnabled: true,
  browserName: '',
  platform: 'MAC',
  javascriptEnabled: true,
  databaseEnabled: false,
  takesScreenshot: true,
  networkConnectionEnabled: false,
  handlesAlerts: true,
  rotatable: true,
  app:
   './ios/build/Build/Products/Debug-iphonesimulator/test.app',
  maxInstances: 1,
  noReset: true,
  orientation: 'PORTRAIT',
  platformName: 'iOS',
  deviceName: 'iPhone X',
  platformVersion: '12.0',
  metadata:
   { device: 'iPhone X',
     platform: { name: 'iOS', version: '12.0' } },
  wdaLocalPort: 8101,
  requestOrigins:
   { url: 'http://webdriver.io',
     version: '4.14.1',
     name: 'webdriverio' },
  udid: 'CE81FB87-FB13-4DA7-A097-50D21B15E5BC' }

Obviously no browserName, but at least data.body.value is not undefined so the test passes. It's when data.body.value is occasionally null it's a problem.

@wswebcreation
Copy link
Owner

Fixed with version 0.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants