有时 Jenkins 上的 Sahi Pro 脚本(运行 with ant)根本找不到元素

Sometimes Sahi Pro script on Jenkins (run with ant) can't find elements at all

错误 - 记录异常:步骤 >_sahi._takePageScreenShot()< 未在 90 秒内完成。

此错误的出现没有任何逻辑原因。有一次我 运行 构建 - 一切都很好。其他时间 - 出现此错误并且构建失败。

这里可以看出,只有两次,脚本真的是运行ning。没有卡在第一位。

当我收到此错误时,它出现在第一个试图在浏览器中查找内容的对象上。

控制台日志:

[sahi] Nov 07, 2017 2:16:10 AM in.co.sahi.distributed.DSahiRunner startNonDistributedRun
 [sahi] INFO: SuiteId : sahi_dde93c7c0a6640408608e800eeba549960a0
 [sahi] Nov 07, 2017 2:16:10 AM in.co.sahi.distributed.DSahiRunner startNonDistributedRun
 [sahi] INFO: URL : http://localhost:9999/_s_/dyn/in.co.sahi.command.Master_runNonDistributed?1=1&baseURL=http%3A%2F%2Fnewbrick.tietolatvia.lv%3A3650%2F&browserType=chrome&emailPasswordHidden=true&emailProp=&emailProperties=%2Fhome%2Fjenkins%2Fsahi%2Fsahi_pro_runner%2Fuserdata%2Fconfig%2Femail.properties&emailTrigger=success%2Cfailure&failedSuiteName=fail_chrome.dd.csv&host=localhost&isSendEmailS=false&isSingleSessionS=true&jsCodeCoverage=%24%7BjsCodeCoverage%7D&logsInfo=html%3A%2Fhome%2Fjenkins%2Fjenkins%2Fworkspace%2FPAIS1%2Freports%2Cjunit%3A%2Fhome%2Fjenkins%2Fjenkins%2Fworkspace%2FPAIS1%2Freports&port=9999&scriptsPathMaster=%2Fhome%2Fjenkins%2Fsahi%2Fsahi_pro_runner%2Fuserdata%2Fscripts&sendEmailPeriodicallyS=false&sendEmailPeriodicallyTime=&showPeriodicSummary=true&suiteId=sahi_dde93c7c0a6640408608e800eeba549960a0&suitePath=%2Fhome%2Fjenkins%2Fjenkins%2Fworkspace%2FPAIS1%2FPAIS1.dd.csv&threads=5
 [java] Nov 07, 2017 2:16:10 AM in.co.sahi.command.Master addNodes
 [java] INFO: syncNodes = false
 [java] Nov 07, 2017 2:16:10 AM in.co.sahi.distributed.DSuiteRunner addNode
 [java] INFO: Adding localhost:9999
 [java] Nov 07, 2017 2:16:10 AM in.co.sahi.datastore.SahiDB createTables
 [java] INFO: Check tables version
 [java] Nov 07, 2017 2:16:11 AM in.co.sahi.datastore.SahiDB createTables
 [java] INFO: versionFromDB=2017-04-21 21:05:44
 [java] Nov 07, 2017 2:16:11 AM in.co.sahi.datastore.SahiDB createTables
 [java] INFO: version=2017-04-21 21:05:44
 [java] Nov 07, 2017 2:16:11 AM in.co.sahi.datastore.SahiDB createTables
 [java] INFO: At current version. No changes were done.
 [java] Nov 07, 2017 2:16:11 AM in.co.sahi.datastore.SahiDB createTables
 [java] INFO: {result: [["SAHIKEY","SAHIVALUE"],["dbVersion","89"],["versionNo","2017-04-21 21:05:44"]]}
 [java] Nov 07, 2017 2:16:11 AM in.co.sahi.datastore.SahiDB createTables
 [java] INFO: Finished preparing report tables: 445ms
 [java] Nov 07, 2017 2:16:11 AM net.sf.sahi.test.ProcessHelper execute
 [java] INFO: env DISPLAY=:1 google-chrome --no-default-browser-check --no-first-run --start-maximized --user-data-dir=/home/jenkins/sahi/sahi_pro_runner/userdata/browser/chrome/profiles/sahi0 --proxy-server=127.0.0.1:9999 --disable-popup-blocking --always-authorize-plugins --allow-outdated-plugins --enable-npapi --disable-translate --no-managed-user-acknowledgment-check --disable-session-crashed-bubble --incognito http://sahi.example.com/_s_/dyn/Player_auto?startUrl=http%3A%2F%2Fnewbrick.tietolatvia.lv%3A3650%2F__SahiAmpersandSahi__sahisid=sahi_dde93c7c0a6640408608e800eeba549960a0sahix6cb39e7b0cb3f0486e09b270f80b45ed9098x__SahiAmpersandSahi__isSingleSession=true
 [java] Nov 07, 2017 2:16:11 AM net.sf.sahi.test.TestLauncher execute
 [java] INFO: #### Running Script: /home/jenkins/jenkins/workspace/PAIS1/Scen01.sah
 [java] Nov 07, 2017 2:16:11 AM net.sf.sahi.test.ProcessHelper$PIDGatherer run
 [java] INFO: PIDs: [32001, 32017, 32020, 32023, 32058, 32060]; 351 ms
 [sahi] Nov 07, 2017 02:16:11 AM STARTED: Scen01.sah BROWSER: chrome
 [sahi] Nov 07, 2017 02:16:11 AM Testcases: 0/0, Scripts: 0/0 BROWSER: chrome
 [java] Rhino lib: startMode = BROWSER
 [java] Rhino lib:Setting mode: BROWSER
 [java] Nov 07, 2017 2:16:21 AM net.sf.sahi.RemoteRequestProcessor processHttp
 [java] WARNING: Returning CannotConnectResponse for: https://ssl.gstatic.com/safebrowsing/csd/client_model_v5_variation_0.pb
 [java] Nov 07, 2017 2:16:21 AM net.sf.sahi.RemoteRequestProcessor processHttp
 [java] WARNING: Returning CannotConnectResponse for: https://ssl.gstatic.com/safebrowsing/csd/client_model_v5_ext_variation_0.pb
 [java] Rhino lib:/home/jenkins/jenkins/workspace/PAIS1/Page/Base.sah already included.
 [java] Rhino lib:/home/jenkins/jenkins/workspace/PAIS1/Page/Base.sah already included.
 [java] Rhino lib:/home/jenkins/jenkins/workspace/PAIS1/Page/Base.sah already included.
 [java] Rhino lib:/home/jenkins/jenkins/workspace/PAIS1/Page/Base.sah already included.
 [java] Rhino lib:/home/jenkins/jenkins/workspace/PAIS1/Page/Order.sah already included.
 [java] Rhino lib:/home/jenkins/jenkins/workspace/PAIS1/Page/Base.sah already included.
 [java] Rhino lib:Step >_sahi._takePageScreenShot()< did not complete in 90 seconds.
 [java] message = ALREADY_LOGGED (RhinoScriptRunner.run#1660)
 [java] token = ALREADY_LOGGED (RhinoScriptRunner.run#1660)
 [java] Nov 07, 2017 2:19:10 AM net.sf.sahi.RemoteRequestProcessor processHttp
 [java] WARNING: Returning CannotConnectResponse for: https://safebrowsing.google.com/safebrowsing/downloads?client=googlechrome&appver=58.0.3029.110&pver=3.0&key=AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw&ext=0
 [java] Nov 07, 2017 2:19:10 AM net.sf.sahi.RemoteRequestProcessor processHttp
 [java] WARNING: Returning CannotConnectResponse for: https://alt2-safebrowsing.google.com/safebrowsing/downloads?client=googlechrome&appver=58.0.3029.110&pver=3.0&key=AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw
 [java] Nov 07, 2017 2:20:10 AM net.sf.sahi.RemoteRequestProcessor processHttp
 [java] WARNING: Returning CannotConnectResponse for: https://safebrowsing.google.com/safebrowsing/downloads?client=googlechrome&appver=58.0.3029.110&pver=3.0&key=AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw&ext=0
 [java] Nov 07, 2017 2:20:10 AM net.sf.sahi.RemoteRequestProcessor processHttp
 [java] WARNING: Returning CannotConnectResponse for: https://alt2-safebrowsing.google.com/safebrowsing/downloads?client=googlechrome&appver=58.0.3029.110&pver=3.0&key=AIzaSyBOti4mM-6x9WDnZIjIeyEU21OpBXqWBgw
 [java] Rhino lib:Step >_sahi._takePageScreenShot()< did not complete in 90 seconds.
 [sahi] Nov 07, 2017 02:21:16 AM FAILED: Scen01.sah BROWSER: chrome
 [sahi] Nov 07, 2017 02:21:16 AM Testcases: 0/1, Scripts: 0/2 BROWSER: chrome

你遇到过这个错误吗?你如何摆脱它?

没有摆脱它的可靠方法。这个问题很老了,看看相关的论坛条目 https://www.google.com/search?safe=off&ei=A5YCWomKH4P0aJSZl8gP&q=_sahi+did+not+complete+site%3Asahipro.com

您可以通过调整 sahi.properties

中的某些属性来降低此问题的发生频率
# Script execution params

#Time (in milliseconds) delay between steps
script.time_between_steps=100
#Time (in milliseconds) delay between retries once an error occurs
script.time_between_steps_on_error=2000
#Number of retries once an error occurs
script.max_reattempts_on_error=5
#Number of cycles Sahi will wait for the page to load before it proceeds with execution
#Time spent is (script.max_cycles_for_page_load x script.time_between_steps) milliseconds
script.max_cycles_for_page_load=1200
#No of times Sahi should wait for stability of AJAX and page loads before continuing. min value is 1
script.stability_index=5

虽然根据我的经验,这只会增加脚本不可避免地失败的时间。