Created
October 18, 2013 15:41
-
-
Save singerxt/7043417 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Test Data | |
url = 'http://your-page-adress/', //change url if you need do test another site | |
testCases = [ | |
name_test_1 = { | |
width: 1400, //viewport width. CasperJS run test for viewport 500 | |
height: 1000, //viewport height | |
selector: '#mobile-wrapper', //You can change selector if you need tests another elements | |
exist: false //False = this element should be notexist(eg. display:none), True = this element should be exist. | |
}, | |
name_test_2 = { | |
width: 1024, | |
height: 1000, | |
selector: '#mobile-wrapper', | |
exist: false | |
}, | |
name_test_3 = { | |
width: 320, | |
height: 1000, | |
selector: '#mobile-wrapper', | |
exist: true | |
} | |
] | |
// End Test Data | |
casper.each(testCases, function(self, testCase) { | |
var width = testCase.width, | |
height = testCase.height | |
casper.test.begin('Test exist/notexist elements', function(test) { | |
casper.start(url).then(function() { | |
this.viewport(width,height); | |
if(testCase.exist) { | |
test.assertExists(testCase.selector, testCase.selector + " is exist. On viewport: " + testCase.width ); | |
} | |
else { | |
test.assertNotExists(testCase.selector, testCase.selector + " is exist. On viewport: " + testCase.width); | |
} | |
}).run(function() { | |
test.done(); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment