建立批次指令
這個範例在「探索」階段使用 Selenium Script 來執行掃描。相同的原則可以套用到任何其他的自動化架構。
執行這項作業的原因和時機
假設為 Selenium Script,會在 Selenium 和 AppScan Standard之間使用 56232 埠。您當然可以依照需要來變更。
註: 在每一個程式碼範例中,會以粗體強調顯示在該步驟中新增的程式碼。
如果您要自己完整執行此範例,可在下列位置找到包含檔案的資料夾:
[AppScan Standard installation folder]\Docs\Selenium Example
註: 如果您的 AppScan 資料夾路徑不同,則必須變更 JAR 檔中的路徑。
程序
- 建立 TXT 檔案並在文字編輯器中開啟該檔案。
-
輸入 AppScan 指令以開啟 AppScan,並定義「起始 URL」、登入認證、「僅測試」選項、開放 Proxy 和 Proxy 接聽埠:
START "" "[AppScan Standard installation folder]\AppScanCMD.exe" /starting_url "https://demo.testfire.net" /credentials "jsmith:demo1234" /test_only /opr /lp "53262"
提示: 您可以依照需要來新增額外的指令,例如定義特定的「測試原則」或建立報告的指令(如需詳細資料,請參閱CLI)。 -
新增 15 秒逾時批次,讓 AppScan 有時間開啟:
START "" "[AppScan Standard installation folder]\AppScanCMD.exe" /starting_url "https://demo.testfire.net" /credentials "jsmith:demo1234" /test_only /opr /lp "53262" timeout /t 15
-
新增您的 Selenium Script:
START "" "[AppScan Standard installation folder]\AppScanCMD.exe" /starting_url "https://demo.testfire.net" /credentials "jsmith:demo1234" /test_only /opr /lp "53262" timeout /t 15 java -jar selenium-server-standalone-2.52.0.jar -trustAllSSLCertificates -htmlSuite "*firefox" "https://demo.testfire.net" "mytestsuite.html" "results.html"
重要: Selenium 的「起始 URL」必須與 AppScan 範本中的「起始 URL」完全相同。 -
將 Selenium 要對其傳送要求的 AppScan Proxy 埠和主機插入 Selenium Script:
START "" "[AppScan Standard installation folder]\AppScanCMD.exe" /starting_url "https://demo.testfire.net" /credentials "jsmith:demo1234" /test_only /opr /lp "53262" timeout /t 15 java -Dhttp.proxyHost=localhost -Dhttp.proxyPort=56232 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=56232 -jar selenium-server-standalone-2.52.0.jar -trustAllSSLCertificates -htmlSuite "*firefox" "https://demo.testfire.net" "mytestsuite.html" "results.html"
-
在結尾新增指令以關閉 AppScan Proxy 及啟動「測試」階段:
START "" "[AppScan Standard installation folder]\AppScanCMD.exe" /scan_template " C:\Users\<username>\Documents\AppScan\QA Automation Demo Template.scant " /test_only /opr /lp "56232" timeout /t 15 java -Dhttp.proxyHost=localhost -Dhttp.proxyPort=64345 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=56232 -jar selenium-server-standalone-2.52.0.jar -trustAllSSLCertificates -htmlSuite "*firefox" "https://demo.testfire.net" "mytestsuite.html" "results.html" "[AppScan Standard installation folder]\AppScanCMD.exe" cpr
- 儲存檔案,使用指令行來執行檔案。
結果
重要: 如果因為任何原因而未完成程序,您可能會發現 Internet Explorer 和 Chrome 瀏覽器 Proxy 設定已經變更,而必須手動復原變更。