ダウンロードのAutoItを使用してURLからファイル、およびロボットFrameworkの実行。(また、他のアプリケーションで使用することができます)

把握するには何が必要?

AutoItのにロボットフレームワークから1.PassダウンロードURL。

AutoItのからロボットフレームワークへのパス保存2.Returnファイル。

 

ステップ1:メモ帳++で書くのAutoItスクリプト、downloadFileFromURL.au3として保存

書式#include <InetConstants.au3>

書式#include <MsgBoxConstants.au3>

書式#include <WinAPIFiles.au3>

 

; バックグラウンドでファイルをダウンロードしてください。

; 完全にダウンロードを待ちます。

 

ローカル$ FileDownloadURL = $するCmdLine [1]

;ローカル$ FileDownloadURL = " https://test.com/installer.exe "

$ FileSavePath = @TempDirローカル& "\ awsinstaller.exe"

 

; それが完了するのを待ってファイルをダウンロードしてください。「ローカルキャッシュからファイルを取得」のオプションが選択されています。

ローカル$ iBytesSize = InetGet($ FileDownloadURL、$ FileSavePath、$ INET_FORCERELOAD)

 

; ファイルサイズを取得します。

ローカル$ iFileSize = FileGetSize($ FileSavePath)

 

; パスをファイル保存して戻ります

ConsoleWrite($ FileSavePath)

 

ステップ2:右クリックdownloadFileFromURL.au3、リスト内のコンパイルスクリプトを選択します。

downloadFileFromURL.au3は、exeファイルにコンパイルされます。

 

ステップ3:ロボットFrameworkのコールdownloadFileFromURL.exe。

$ {fileURL}変数の設定https://test.com/installer.exe

$ {} exePath設定された変数D:\\ツール\\ downloadFileFromURL.exe

$ {結果}実行プロセス$ {exePath} $ {fileURL}

ログ$ {} result.stdout

 

AutoItのにロボットのフレームワークからパラメータを渡します。

使用するCmdLineはAutoItので提供しました

$するCmdLine [0]; 配列内の項目の合計数が含まれています。$するCmdLine [1]; 最初のパラメータ。$するCmdLine [2]。二番目のパラメータ。... $するCmdLine [n番目]。n番目のパラメータなど10のアレイは、10の項目が含まれている場合。

AutoItのからロボットフレームワークへの戻り値。

1.UseのAutoItのConsoleWrite、stdoutに書き込む値

ロボットFrameworkの実行プロセスによって返さ2.Use $ {result.stdout}は、標準出力から値を読みます

 

 

 exeファイルにコンパイルのAutoItスクリプト

 

 

 ロボットFrameworkの実行exeファイル

 

 

 

安定性を高めるためには、改善のビットを行います。

オープンIEブラウザのURLをインストールする前に、それはダウンロードに使用のAutoItに、非常に不安定であり、インストールを開始します。

フルのAutoItスクリプトおよびスクリプトロボットフレームワークを伴います。

downloadFileFromURL.au3

#include <InetConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

; Download a file in the background.
; Wait for the download to complete.

;Local $FileDownloadURL = "https://test.com/installer.exe"
Local $FileDownloadURL = $CmdLine[1]
Local $FileName = $CmdLine[2]

Local $FileSavePath = @TempDir & "\" & $FileName

; Download the file by waiting for it to complete. The option of 'get the file from the local cache' has been selected.
Local $iBytesSize = InetGet($FileDownloadURL, $FileSavePath, $INET_FORCERELOAD)

; Retrieve the filesize.
Local $iFileSize = FileGetSize($FileSavePath)

; Return with file save path
ConsoleWrite($FileSavePath)

UninstallAndInstallOfficeUS.txt in Robot Framework

*** Settings ***
Test Timeout      5 minutes
Resource          ../../../04.BasicReferenceSet/businessReferenceSet.html
Resource          ../../../04.BasicReferenceSet/publicReference.html

*** Test Cases ***
InstallOfficeUS
    [Tags]    InstallOfficeUS
    [Setup]    Clean And Close Current App    ${processName}
    [Timeout]    10 minutes
    Delete File From Directory    ${TEMPDIR}/prerequisite.exe
    Delete File From Directory    ${TEMPDIR}/awsinstaller.exe
    Delete File From Directory    ${TEMPDIR}/setup.exe
    Clean Process    chrome
    Clean Process    OUTLOOK
    Clean Process    Teams
    ${fileDownloadURL}    Get Installation Link
    ${installFileName}    Fetch From Right    ${fileDownloadURL}    /
    ${exePath}    Join Path    ${EXECDIR}    06.The_Attachment    Tool    downloadFileFromURL.exe
    ${result}    Run Process    ${exePath}    ${fileDownloadURL}    ${installFileName}
    ${officeUSExePath}    Set Variable    ${result.stdout}
    Run Process    ${officeUSExePath}    timeout=10
    Win Wait    Morningstar Office Prerequisite 3.19 - InstallShield Wizard    TimeOut=120
    AutoItLibrary.Send    !N
    Win Wait    Morningstar Office Prerequisite 3.19 - InstallShield Wizard    InstallShield Wizard Completed    TimeOut=10
    AutoItLibrary.Send    !C
    Run Process    ${officeUSExePath}    timeout=120
    Win Wait    Morningstar Office - InstallShield Wizard    TimeOut=10
    Sleep    1
    AutoItLibrary.Send    !N
    Sleep    1
    AutoItLibrary.Send    !N
    Sleep    1
    AutoItLibrary.Send    !N
    Sleep    1
    AutoItLibrary.Send    !I
    Win Wait    Morningstar Office - InstallShield Wizard    Installing Morningstar Office    TimeOut=10
    Win Wait Close    Morningstar Office - InstallShield Wizard    Installing Morningstar Office    TimeOut=180
    Win Wait    Morningstar Office - InstallShield Wizard    InstallShield Wizard Completed    TimeOut=10
    AutoItLibrary.Control Click    strTitle=Morningstar Office - InstallShield Wizard    strText=InstallShield Wizard Completed    strControl=[CLASSNN:Button5]
    AutoItLibrary.Send    !F
    File Should Exist    C:\\Program Files (x86)\\Morningstar\\Office\\MStarAWD.exe    Install Failed!
    [Teardown]    Clean Process    SavUI

UninstallOfficeUS
    [Tags]    UninstallOfficeUS
    [Setup]    Clean And Close Current App    ${processName}
    Clean Process    msiexec
    AutoItLibrary.Run    C:\\Windows\\System32\\control.exe \ appwiz.cpl
    AutoItLibrary.Win Wait    Programs and Features    TimeOut=5
    AutoItLibrary.Win Activate    Programs and Features
    AutoItLibrary.Send    Morningstar Office
    AutoItLibrary.Send    {ENTER}
    Sleep    1
    AutoItLibrary.Send    !Y
    Win Wait    Morningstar Office    Please wait while Windows configures Morningstar Office    TimeOut=5
    Win Wait Close    Morningstar Office    Please wait while Windows configures Morningstar Office    TimeOut=180
    Sleep    2
    [Teardown]    Run Keywords    Win Close    Programs and Features
    ...    AND    Clean Process    Un_A

UninstallOfficePrerequisite
    [Tags]    UninstallOfficePrerequisite
    [Setup]    Clean And Close Current App    ${processName}
    Clean Process    msiexec
    AutoItLibrary.Run C:\\ Windowsの\\ System32に\\ CONTROL.EXE \ appwiz.cplで
    AutoItLibrary.Winプログラムを待っています
    AutoItLibrary.Winアクティブプログラムと機能
    AutoItLibrary.Sendモーニングスターオフィス前提条件3.19 
    {ENTER} AutoItLibrary.Sendを
    スリープ1 
    AutoItLibraryを.Send!Y 
    スリープ3 
    [ティアダウン]ファイル名を指定して実行キーワード勝利閉じるプログラムと機能
    ... ANDクリーンプロセスUn_A

  

おすすめ

転載: www.cnblogs.com/MasterMonkInTemple/p/12144566.html
おすすめ