Maximize The Browser Window Using Protractor

Maximize The Browser Window Using Protractor

Protractor is browser automation and end-to-end testing framework built on-top of JavaScript Selenium webdriver for testing Angular based applications. It tests your applications like a real user by running your tests using the real web browsers.

In this post, we’re going to learn to maximize the browser window while running the automation tests.

Protractor comes bundled with feature which allows you to do the same

browser.driver.manage().window().maximize();

To maximize your window all you need to do is use above code inside your tests.

describe('testing super calc using protractor', function() {
  it('should maximize the web browser window', function() {
	browser.driver.manage().window().maximize();
	browser.driver.get('https://juliemr.github.io/protractor-demo/');
  });
});

If you wish to run all your tests in maximized window, you can take advantage of onPrepare method inside your configuration file.

exports.config = {
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: ['*.spec.js'],
  onPrepare: function() {
    browser.driver.manage().window().maximize();
  }
};

And that’s it! In case if you’ve any query or feedback feel free to drop a comment.

Recommended: How to Run Protractor Test Cases in Firefox Browser

Leave a Reply

Your email address will not be published. Required fields are marked *