-3

The main problem I have here, is that when I launch my tests, the window that selenium web-driver opens, is a small window.

In my tests I ask selenium to click on an element, but this element depends on the size of the browser, it hides in a menu. So I would like to know how I could make the browser open completely for all the tests.

And need to change the size so that it opens the whole browser. But I would like to add the code here:

import { After, AfterAll, Status } from '@cucumber/cucumber';
import { Builder, Capabilities } from 'selenium-webdriver';

require('chromedriver');

// driver setup
const capabilities = Capabilities.chrome();
capabilities.set('chromeOptions', { w3c: false });
export const driver = new Builder().withCapabilities(capabilities).build();

After(function (scenario) {
  if (scenario.result.status === Status.FAILED) {
    return driver.takeScreenshot().then(screenShot => {
      this.attach(screenShot, 'image/png');
    });
  }
});

AfterAll(async () => await driver.quit());
Mustapha
  • 1
  • 3

2 Answers2

0

You need to add ChromeOptions and use the start-maximized argument. When I initialize the driver it's like this

ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");

But in your case maybe you need to add to your capabilities like this:

capabilities.set('chromeOptions', { w3c: false, start-maximized: true });
C. Peck
  • 3,641
  • 3
  • 19
  • 36
0

try this code:

driver.manage().window().maximize();
Slava Rozhnev
  • 9,510
  • 6
  • 23
  • 39