Search code examples
serenity-bdd

Is there a way to add -Dchrome.switches chrome properties to serenity.properties or serenity.conf files?


I tried to add the below in the serenity.conf file to always load the chrome browser with these options but it fails to load the browser. When I pass in the below options via command line like so "gradle test -Dchrome.switches="--no-sandbox,--ignore-certificate-errors,--homepage=about:blank,--no-first-run" the browser starts successfully.

"-Dchrome.switches="--no-sandbox,--ignore-certificate-errors,--homepage=about:blank,--no-first-run"

Is there a way to always open chrome browser without having to pass this via command line or have the chrome driver as part of the framework?

serenity.conf

  #
  # WebDriver configuration
  #
   webdriver {
   driver = chrome
   autodownload = true
  }
  #headless.mode = true

  serenity.test.root = java

#
# Chrome options can be defined using the chrome.switches property
#
chrome.switches = """--start-maximized;--test-type;--no-sandbox;--ignore-certificate-errors;
              --disable-popup-blocking;--disable-default-apps;--disable-extensions-file-access-check;
              --disable-web-security;--incognito;--disable-infobars,--disable-gpu,--homepage=about:blank,--no-first-run"""

Thanks!


Solution

  • Thank you!

    I have switched to
    @Managed
    WebDriver driver;

    https://serenity-bdd.github.io/theserenitybook/latest/web-testing-in-serenity.html#_a_simple_selenium_web_test

    Below is the information on manned drivers in serenity.

    Serenity reduces the amount of code you need to write and maintain when you write web tests. For example, it takes care of creating WebDriver instances, and of opening and closing the browser for you. The following is a very simple Selenium web test using Serenity: