[JAVA] Selenide option list

Preface

When creating an automated test using Selenide, there is an option to switch the operation just by giving a parameter to Selenide without coding. By knowing and utilizing these, you can avoid unnecessary coding, so it is safer to know in advance when using Selenide.

The process of actually loading the options is written in SelenideConfig.java, so let's take a look with the code on SelenideConfig. It also includes a brief explanation and personal impressions based on the content of the document and the experience I have used. Excuse me if I am wrong.

Premise

This explanation is based on version 5.7 of selenide, and the explanation by the official document can also be referred from the following page. https://selenide.org/javadoc/current/com/codeborne/selenide/Configuration.html

Option list

selenide.browser Utilization ★★★ You can specify which browser to use. It's convenient because you don't have to specify the browser in the code when testing with multiple browsers. Choose from chrome "," firefox "," legacy_firefox "(upto ESR 52)," ie "," opera "," edge ".

  private String browser = System.getProperty("selenide.browser", CHROME);

selenide.headless Utilization ★ You can also run in headless mode. However, I think it is safer to avoid it as an E2E test. Is it supposed to be used for scraping? It seems to work only with Chrome (59+) and Firefox (56+).

  private boolean headless = Boolean.parseBoolean(System.getProperty("selenide.headless", "false"));

selenide.remote Utilization ★ It seems that this setting is necessary when using RemoteWebDriver, such as when using Selenium Grid. I haven't used it because the test on multiple terminals is realized by the pipeline of jenkins.

  private String remote = System.getProperty("selenide.remote");

selenide.browserSize Utilization ★★★ You can also specify the window size. I think there are tests that switch the window size, so it's convenient because you can change it with parameters. Whether it works at the guaranteed resolution, or at a higher resolution, etc. It is also important for performing a homogeneous test that does not depend on the test execution terminal.

  private String browserSize = System.getProperty("selenide.browserSize", "1366x768");

selenide.browserVersion Utilization ★★★ It seems that you can also specify the version of the browser. The documentation says (for Internet Explorer).

  private String browserVersion = System.getProperty("selenide.browserVersion");

selenide.browserPosition Utilization ★ You can also specify the browser position at startup. I can't think of many uses.

  private String browserPosition = System.getProperty("selenide.browserPosition");

selenide.startMaximized Utilization ★★ You can choose whether to maximize the browser size when the browser starts. If you maximize it, the visible area will expand and the element to be operated will be displayed easily, so it will tend to be easier to pass the test. However, the fact that the browser size depends on the terminal that executes the test is a little subtle in terms of the credibility of the test results.

  private boolean startMaximized = Boolean.parseBoolean(System.getProperty("selenide.startMaximized", "false"));

selenide.driverManagerEnabled Utilization ★★ You can switch whether or not to automatically download the driver. Basic On is fine, but if you do not need to download it, you can shorten the test execution time. I think that it is also an ant to utilize when test execution is required on a tight schedule See https://github.com/bonigarcia/webdrivermanager for WebDriverManager configuration details.

  private boolean driverManagerEnabled = Boolean.parseBoolean(System.getProperty("selenide.driverManagerEnabled", "true"));

selenide.browserBinary Utilization ★ I haven't used it, but it seems that I can specify the path to the driver. The document says Works only for Chrome, Firefox and Opera. However, looking at the code, it seems that it will work in IE and safari.

  private String browserBinary = System.getProperty("selenide.browserBinary", "");

selenide.pageLoadStrategy Utilization ★★ You can specify how to determine when the page has finished loading. normal: return after the load event fires on the new page (it's default in Selenium webdriver); eager: return after DOMContentLoaded fires; none: return immediately

In the case of normal, it is the most conservative because it waits until the load event fires. When creating a test from now on, it may be good to achieve both stability and speed by selecting ʻeager`, which waits until the DOM reading is completed. none isn't practical because it doesn't wait at all.

  private String pageLoadStrategy = System.getProperty("selenide.pageLoadStrategy", "normal");

selenide.baseUrl Utilization ★★★ When opening the page using Selenide.open (), the URL set here will be opened. This is useful when there are multiple environments to be tested, such as development and staging. Normally, specify the host, domain, and even the port.

  private String baseUrl = System.getProperty("selenide.baseUrl", "http://localhost:8080");

selenide.timeout Utilization ★★★ You can specify the time to wait when checking an element using the should method or the like. If the environment specifications to be tested are low and the response is poor, you can stabilize the test by changing the timeout time.

  private long timeout = Long.parseLong(System.getProperty("selenide.timeout", "4000"));

selenide.pollingInterval Utilization ★ You don't have to specify it. This is the check interval when checking elements.

  private long pollingInterval = Long.parseLong(System.getProperty("selenide.pollingInterval", "200"));

selenide.holdBrowserOpen Utilization ★ You can keep the window open when the test is over. It can be used to investigate when a test run fails. However, since you have to close the window, basically it is better not to use this option if capture acquisition can be substituted.

  private boolean holdBrowserOpen = Boolean.getBoolean("selenide.holdBrowserOpen");

selenide.reopenBrowserOnFail Utilization? According to the document, it seems to be an option to reopen when the browser is closed due to hangs, broken, unexpectedly closed, but even if it is reopened, the process will proceed well after that.

  private boolean reopenBrowserOnFail = Boolean.parseBoolean(System.getProperty("selenide.reopenBrowserOnFail", "true"));

selenide.clickViaJs Utilization ★ It seems that you can choose whether to click the element with the webdriver or use js. ATTENTION! Automatic WebDriver waiting after click isn't working in case of using this feature. It is also written, so I don't think it is necessary to change it unless there is a reason.

  private boolean clickViaJs = Boolean.parseBoolean(System.getProperty("selenide.clickViaJs", "false"));

selenide.screenshots Utilization ★★★ Whether to take a screenshot when the test fails. It is good to be able to capture the capture as evidence when the test fails, or when investigating a problem in the test code, so it is good to be able to switch the capture save necessity with the parameter. ..

  private boolean screenshots = Boolean.parseBoolean(System.getProperty("selenide.screenshots", "true"));

selenide.savePageSource Utilization ★★★ Since you can get the html at runtime, this is also useful for investigating when the test fails.

  private boolean savePageSource = Boolean.parseBoolean(System.getProperty("selenide.savePageSource", "true"));

selenide.reportsFolder Utilization ★★

  private String reportsFolder = System.getProperty("selenide.reportsFolder", "build/reports/tests");

selenide.savePageSource Utilization ★★ You can specify where to download the file.

  private String downloadsFolder = System.getProperty("selenide.downloadsFolder", "build/downloads");

selenide.reportsUrl Utilization ★★ Useful when running in combination with CI. If it's given, names of screenshots are printed as "http://ci.mycompany.com/job/my-job/446/artifact/build/reports/tests/my_test.png " - it's useful to analyze test failures in CI server. Optional: URL of CI server where reports are published to. In case of Jenkins, it is "BUILD_URL/artifact" by default.

  private String reportsUrl = new CiReportUrl().getReportsUrl(System.getProperty("selenide.reportsUrl"));

selenide.fastSetValue Utilization ★★ You can select whether to input the value in the input field with javascript or use Selenium's "sendKey" function. It seems that the input operation is faster using javascript, so it is worth considering if you are concerned about the speed.

  private boolean fastSetValue = Boolean.parseBoolean(System.getProperty("selenide.fastSetValue", "false"));

selenide.versatileSetValue Utilization ★ It seems that the'setValue'and'val' methods can behave like'selectOptionByValue','selectRadio' depending on the type of actual element.

  private boolean versatileSetValue = Boolean.parseBoolean(System.getProperty("selenide.versatileSetValue", "false"));

selenide.fileDownload Utilization ★ You can set whether to go through the proxy server when downloading the file.

  private FileDownloadMode fileDownload = FileDownloadMode.valueOf(System.getProperty("selenide.fileDownload", HTTPGET.name()));

selenide.proxyEnabled Utilization ★ You can set whether to run the browser via the proxy server.

  private boolean proxyEnabled = Boolean.parseBoolean(System.getProperty("selenide.proxyEnabled", "false"));

selenide.proxyHost Utilization ★ You can set the host for running the browser via the proxy server. It is assumed that proxyEnabled == true.

  private String proxyHost = System.getProperty("selenide.proxyHost", "");

selenide.proxyPort Utilization ★ You can set the port number when operating the browser via the proxy server. It is assumed that proxyEnabled == true.

  private int proxyPort = Integer.parseInt(System.getProperty("selenide.proxyPort", "0"));

Afterword

Have you found an option that might be useful for testing? It seems that options are being added from time to time as the library is upgraded, so continuous checking is recommended.

Recommended Posts

Selenide option list
Selenide know-how
Thread-safe list
List method
Work list
Link list