There are many ways you can do this. I’ll just give you what we do, and maybe it will give some food for thought.
1.) Handle all of your desired capabilities in the project settings (Project > Settings > Desired Capabilities > WebUI > Chrome). In your case, you would add the “–start-maximized” arg there. For more info on configuring Desired Capabilities this way, see this.
2.) Instead of using driver.get(URL), at the start of every test case you would instead use WebUI.openBrowser(URL). This tells Katalon to instantiate a driver instance, with any capabilities you’ve defined in Step 1.
3.) In your page object hierarchy, you have one abstract class (ours is just called “Page”), which (among other things) asks Katalon for the driver it’s currently using:
public abstract class Page {
protected WebDriver driver = DriverFactory.getWebDriver();
.
.
.
}
4.) Any and all page object classes you write would be subclasses of the generic “Page” class, and thus have access to the current driver by default. For example, a “LoginPage” class might look something like:
public class LoginPage extends Page {
public void setUsernameField(String value) {
WebElement element = driver.findElement(...);
element.sendKeys(value);
}
.
.
.
}
5.) Your scripts end up looking something like:
WebUI.openBrowser(URL);
LoginPage loginPage = new LoginPage();
loginPage.setUsernameField("Billy Babaganoosh");
(or the groovy equivalent, mine is just pure java).
Note: This approach is thread-safe, if you were planning on running scripts in parallel at any point.
Note: This allows you to run any browser type you want, not just chrome.