1

Hey I currently using selenium webdriver, mocha, Browserstack and a node.js package called "looks-same" for an automated visual regression. I am just trying to do a simple comparison with a reference image I have stored and a snap shot I get from selenium.

The code seems to work fine when I run selenium locally but when I use Browserstack, it works sometimes but most of the time it throws an error.

The Error:

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: Unexpected end of input
    at module.exports.ChunkStream._end (/home/david/Desktop/Camera/node_modules/pngjs/lib/chunkstream.js:100:7)
    at module.exports.ChunkStream._process (/home/david/Desktop/Camera/node_modules/pngjs/lib/chunkstream.js:203:12)
    at module.exports.<anonymous> (/home/david/Desktop/Camera/node_modules/pngjs/lib/chunkstream.js:32:10)
    at _combinedTickCallback (internal/process/next_tick.js:132:7)
    at Immediate._tickCallback [as _onImmediate] (internal/process/next_tick.js:181:9)
    at runCallback (timers.js:810:20)
    at tryOnImmediate (timers.js:768:5)
    at processImmediate [as _immediateCallback] (timers.js:745:5)


These are my browser stack capabilities:

const browserStackCapabilities = {
    'browserName' : 'android',
    'device' : 'Samsung Galaxy S8',
    'realMobile' : 'true',
    'os_version' : '7.0',
    'browserstack.debug' : 'true'
}

This is the code:

it('Should compare screenshot of homepage', function() {
    this.timeout(50000)
    return new Promise( async (resolve, reject) => {
        await browser.get(serverUri)

        await browser.saveScreenshot('homePage.png')

        await looksSame('homePageReference.png', 'homePage.png', function(error, {equal}) {
            console.log(equal)
            console.log(error)

            expect(equal).to.equal(true)
        });
        resolve()
        browser.quit()
    })
})

I expect it to continuously compare the images and give a result either true or false using Browerstack.

Did I do something wrong with error handling?

David Ramsdale
  • 113
  • 1
  • 5
  • At least in the snippet shown above you need another closing bracket and parenthesis at the end of the test.. May I assume that's just left off here? – C. Peck Mar 29 '19 at 03:08
  • @C.Peck sorry that was a mistake edited, thank you. – David Ramsdale Mar 29 '19 at 03:15
  • Ok let’s see... you say it works “sometimes but most of the time throws an error”. Is it that same error every time? Are you able to tell which line invokes the error? – C. Peck Mar 29 '19 at 13:16

0 Answers0