Problems running tests on Sauce Labs with Firefox

Hello,

I’ve been trying to run tests on Sauce Labs with Firefox. But I’ve been getting a java.lang.NullPointerException:

Go to Google --
    Emitted | suite.before ([object Object])
  Show Google
    Emitted | test.before ([object Object])
    [1] Error | Error: java.lang.NullPointerException
    Emitted | test.failed ([object Object])
  ✖ "before each" hook: codeceptjs.before for "Show Google" in 12705ms
    [1] Error | Error: java.lang.NullPointerException
Error: java.lang.NullPointerException
    Emitted | test.after ([object Object])
    Emitted | suite.after ([object Object])

-- FAILURES:

  1) Go to Google
       "before each" hook: codeceptjs.before for "Show Google":
     java.lang.NullPointerException
  rror: java.lang.NullPointerException
      at getErrorFromResponseBody (node_modules/webdriver/build/utils.js:215:10)
      at Request._callback (node_modules/webdriver/build/request.js:103:64)
      at Request.self.callback (node_modules/request/request.js:185:22)
      at Request.EventEmitter.emit (domain.js:448:20)
      at Request.<anonymous> (node_modules/request/request.js:1161:10)
      at Request.EventEmitter.emit (domain.js:448:20)
      at IncomingMessage.<anonymous> (node_modules/request/request.js:1083:12)


  FAIL  | 0 passed, 1 failed, 1 skipped   // 13s
    Emitted | global.result ([object Object])
    Emitted | global.after ([object Object])

This is my config:

const SAUCE_USERNAME = "username"
const SAUCE_ACCESS_KEY = "key"
exports.config = {
  tests: './src/*.spec.js',
  output: './output',
  helpers: {
     WebDriver: {
          url: 'https://google.com',
          browser: 'firefox',
          capabilities: {
             browserName: 'firefox',
          },
         user: SAUCE_USERNAME,
         key: SAUCE_ACCESS_KEY,
     },
  },
 plugins: {
   wdio: {
      enabled: true, 
      user: SAUCE_USERNAME,
      key: SAUCE_ACCESS_KEY,
      region: 'us',
     services: ['sauce'],
   },
 },
 mocha: {},
 name: 'mytests',
}

I’m running CodeceptJS 2.3.0 and webdriverio 5.12.5.

Any idea why this is happening?

Hey, I had this issue too. I got into a whole back and forth over it with Saucelabs and I’m afraid I don’t specifically recall the “solution” but here’s the config I have now:

"WebDriver": {
      "url": "http://localhost",
      "browser": "firefox",
      "remoteFileUpload": false,
      "desiredCapabilities": {
        "platformName": "macOS 10.14",
        "browserVersion": "68.0",
        "sauce:options": {
          "name": "Firefox 68 - macOS"
          "windowSize": "maximum",
          "screenResolution": "1600x1200"
        } 
    }

As an aside, this is a good tool to use if you’re getting stuck on something: https://wiki.saucelabs.com/display/DOCS/Platform+Configurator#/

I also have found this guide really helpful in outlining what versions of selenium are supported on which browser. Sometimes you have to declare a different version if you’re using some browsers: https://wiki.saucelabs.com/display/DOCS/Test+Configuration+Options

The last thing I would recommend trying is to stop using the WDIO plugin. I had some issues when I was running with wdio as part of a bitbucket pipeline. I eventually just stopped using it altogether and now just keep a selenium-server instance running all day. Make sure your package.json file includes:

    "dependencies": {
        "codeceptjs": "^2.3.0",
        "codeceptjs-saucehelper": "^1.3.0",
        "selenium-webdriver": "^4.0.0-alpha.3",
        "webdriverio": "^5.9.6"
    },

Saucehelper renames your tests in saucelabs to match the name of your scenario, if you want to use that all you need to do is add it to your helpers key in the conf.js file:

"SauceHelper": { require: "codeceptjs-saucehelper" }

I hope that helps, otherwise you’ll probably want to open a ticket with saucelabs directly. They’re pretty helpful.