0

Basically I'm trying to resize the screen to full height and width using values returned from the execute function. I'm struggling to figure out how to pass the values from the execute function to my resize function and was hoping someone could take a look at my code and show me where I'm going wrong? when I check saucelabs command executions I don't see the resize command getting fired before the screenshot. So I'm not certain exactly where the breakdown is (whether the size isn't being passed correctly or the timing is incorrect. When I hardcode the size instead of trying to get it from execute, it works perfectly. Thank you!!

    registerSuite('homepage', {
  'homepage'() { 
    return this.remote.get('myurl') 
      .setWindowPosition(0,0)
      .maximizeWindow() 
      .execute(() => [
        document.documentElement.scrollWidth,
        document.documentElement.scrollHeight
      ])
      .then(([width, height]) => { return helpers.resizeWindow(width, height) }) 
      .takeScreenshot() 
      .then(assertVisuals(this, { missingBaseline: 'snapshot', regenerateBaselines: true }) );
  }
});
0

I was actually able to solve this by doing 2 things. I removed the helper.resizeWindow and used the regular command.resizeWindow, and instead of embedding it within the callback function, i just placed it there without the curly braces and without a return statement. I'm unsure why this syntax works and the other did not.

registerSuite('homepage', {
    'homepage'() {
            return this.remote.get('mypage')
            .setWindowPosition(0,0)
            .maximizeWindow()
            .execute(() => [document.documentElement.scrollWidth, document.documentElement.scrollHeight])
            .then(([width, height]) => this.remote.setWindowSize(width, height))
            .takeScreenshot()
            .then(
                assertVisuals(this, {
                    missingBaseline: 'snapshot',
                    regenerateBaselines: true
                })
            );
    }
});


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.