private void setChromeOptions ( final DesiredCapabilities capabilities , ChromeOptions chromeOptions ) { // Set custom downloaded file path. When you check content of downloaded file by robot. final HashMap < String , Object > chromePrefs = new HashMap <> ( ) ; chromePrefs . put ( "download.default_directory" , System . getProperty ( USER_DIR ) + File . separator + DOWNLOADED_FILES_FOLDER ) ; chromeOptions . setExperimentalOption ( "prefs" , chromePrefs ) ; // Set custom chromium (if you not use default chromium on your target device) final String targetBrowserBinaryPath = Context . getWebdriversProperties ( "targetBrowserBinaryPath" ) ; if ( targetBrowserBinaryPath != null && ! "" . equals ( targetBrowserBinaryPath ) ) { chromeOptions . setBinary ( targetBrowserBinaryPath ) ; } capabilities . setCapability ( ChromeOptions . CAPABILITY , chromeOptions ) ; }
Sets the target browser binary path in chromeOptions if it exists in configuration .