Justin Young
Justin Young

Reputation: 2463

Protractor with resolution based tests

I'm just getting into testing my node app with Protractor. Running into an issue with various resolutions, sometimes buttons are hidden/show depending on the screen size & making tests fail occasionally that shouldn't.

Is there a way to set up my tests so that certain tests run with certain resolutions & others are excluded?

Can someone point me to some resources they've found?

Upvotes: 2

Views: 381

Answers (1)

Jesse
Jesse

Reputation: 1723

If you can group the the different types of specs by file then you should use multicapabilities. See https://stackoverflow.com/a/27489765/689411

If you need to mix tests in the same file that each have a special required resolution you can change the resolution once per test

var switchToMobileResolution = function() { browser.manage().window().setSize(500, 900); }
it('does something that only works on mobile',function(){ 
    switchToMobileResolution(); 
    //do something... 
});

Another thing you could do is you could write a simple jasmine reporter that switches resolutions if it matches a special string in the spec name...

var mobileResolutionSpecKey = 'on mobile';
var myReporter = {
 specStarted: function(result) { 
    if(result.fullName.match(mobileResoultionSpecKey) !== null){
      switchToMobileResolution();
    }
}
jasmine.getEnv().addReporter(myReporter);

Upvotes: 1

Related Questions