'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:
- I know how to maximize
- 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.
- 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 1:[1]
Try this:
@WhenPageOpens
public void maximiseScreen() {
getDriver().manage().window().maximize();
}
Solution 2:[2]
in serenity.properties you can use --start-maximized command for chrome.
chrome.switches = --start-maximized
Solution 3:[3]
In your serenity.properties file
// To maximize
chrome.switches = """--start-maximized"""
// To Resize
serenity.browser.width=981
serenity.browser.height=644
Solution 4:[4]
I'm not sure exactly what your problem is as your description is confusing. It kind of sounds like you have multiple tests in one class and when the first test finishes the driver closes and opens again as a new instance.
Try using the BeforeMethod instead of BeforeClass. Something like
@BeforeMethod(alwaysRun = true)
public void setup()
{
WebDriver driver;
driver.manage().window().maximize();
}
Solution 5:[5]
Put this in serenity.properties in project folder
serenity.browser.maximized = true
This will maximise the browser in serenity-bdd
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | lukad |
| Solution 2 | CihangirT |
| Solution 3 | |
| Solution 4 | Ray |
| Solution 5 | Gaurav Khurana |
