         throw new Error "Screenshots on this platform are not supported"
 
     opts.path = INITIALIZATION_FILE_PATH
-    takeScreenshot opts
-    rect = findWindow opts
+    tryNo = 0
+    while not rect and tryNo++ < INITIALIZATION_TRIES
+        takeScreenshot opts
+        rect = findWindow opts
+        unless rect
+            log "Cannot initialize screenshots; try #{tryNo} / #{INITIALIZATION_TRIES}"
+        childProcess.execSync "sleep #{INITIALIZATION_TRY_DELAY_SEC}"
     unless rect
         throw new Error "Cannot find application on screenshot; check '#{opts.path}' file"
     rects[opts.clientUid] = rect


DEST = 'tests_results'
INITIALIZATION_FILE_PATH = pathUtils.join DEST, 'initialization.png'

fs.emptyDirSync DEST



fs = require 'fs-extra'
pathUtils = require 'path'
childProcess = require 'child_process'
driver = require './driver'
findWindow = require './server/findWindow'
testScreenshot = require './server/testScreenshot'
