Search code examples
javaseleniumthucydidescucumber-serenity

Serenity manage webdriver to run in maximize window


Is it possible to run each Scenario in webdriver maximize mode?

I was trying to add to Runner class method with using TestNG annotation @BeforeClass and it works just once, but when scenario passed or failed than the browser get closed and then again open in minimize mode. From other hand I do not want to add @Before cucumber annotation to all my feature files. I just want to change it at one place.

I was not able to override open() method because it's final. I'm looking for a solution when I can do it in runner class or even better in properties directly.

Any help will be appreciated.

Also:

  1. I know how to maximize
  2. I was trying to maximize with extend PageObject class and in custom class, directly in constructor wrote getDriver().manage().window().maximize(); this solution works great but for me looks not so good as it can be, coz it's just extra call to the method which should not be called every time on pageObject initialization.
  3. Also I was trying to do it in properties by adding height and weight of browser, but I don't like this way.

Thanks.


Solution

  • have you tried

     driver.manage().window().maximize() 
    

    reference