So for Chrome, my understanding is that the following allows Protractor to decide the size of the window:
exports.config = {
...
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['--window-size=1440,900', '-window-position=0,0']
},
},
...
}
What I am attempting to do is apply a similar method to other browsers, specifically Firefox and Internet Explorer. I am specifically trying to avoid having the browser resize itself as part of the test process. I decided to start my efforts with Firefox.
Searching for information in the protractor forums led me here which recommends setting the getMultiCapabilities property of the exports.config object to a promise containing an encoded instance of firefox-profile. Attempting to implement that solution caused any attempts to run my test suite to launch Chrome windows instead of Firefox.
As near as I can tell, the demo project in question is simply out of date. Another Stack Overflow post led me towards trying this:
var FirefoxProfile = require('firefox-profile');
exports.config = {
...
capabilities: firefoxCapabilities(),
...
}
function firefoxCapabilities() {
var firefoxProfile = new FirefoxProfile();
return {
browserName: 'firefox',
maxSessions: 1,
firefox_profile : firefoxProfile,
};
}
This almost, ALMOST seems to work. It does at the very least launch Firefox, unlike the example in the demo project. Unfortunately, as per this it seems as though I am supposed to use selenium-webdriver/firefox instead of firefox-profile. Okay, all well and good, I just have to install another package since require can't find selenium-webdriver/firefox; oh wait, that should already be available? Then it's getting complex, and I haven't even seen something to lead me to believe that creating my own Firefox profile will even let me set the window dimensions as I wish.
Changing tack, I found this (specifically, the answer by Martin Sznapka) which seems to be suggesting a much simpler solution: using the onPrepare property to tell the driver what dimensions it should be using. That said, IntelliJ is informing me that onPrepare is an unused function and, when I forge on and try to implement the solution anyway, nothing seems to change. Variations don't seem to help.
So at this point I have spent more than a few hours trying simply to have protractor define the dimensions of the window as it does so easily for Chrome. Between out-of-date demos, extra packages, and solutions that seem completely ineffective, I find myself wondering if I am even on the right track.
Any help or point-in-the-right-direction would be greatly appreciated.
Edit: As per request, here is my full exports.config object. This launches Firefox but does not appear to have any effect on the window size.
exports.config = {
baseUrl: 'http://localhost:8080/',
directConnect: true,
framework: 'jasmine',
capabilities: {
browserName: 'firefox',
maxSessions: 1,
},
// Options to be passed to Jasmine.
jasmineNodeOpts: {
defaultTimeoutInterval: 60000
},
//Ensures that user is signed in before running tests
onPrepare: function () {
var disableNgAnimate = function () {
angular.module('disableNgAnimate', []).run([
'$animate', function ($animate) {
$animate.enabled(false);
}
]);
};
browser.addMockModule('disableNgAnimate', disableNgAnimate);
beforeEach(function () {
browser.ignoreSynchronization = true; // prevents waiting on angular until timing out.
browser.driver.manage().window().setSize(300, 300);
});
},
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['**/*.spec.js'],
suites: {
demo: 'demo/demo.spec.js',
index: 'index/index.spec.js',
}
};