1

iphoneUI自動化テストを定期的に実行するようにJenkinsを設定しました。

自動化の最初のテストスクリプトが実行されると、セキュリティ上の理由から、OSXはユーザー名とパスワードの入力を求めます。

そこで、Expectからコマンドを生成し、ユーザー名とパスワードを送信するperlスクリプトを作成しました。

何らかの理由で、ユーザー名は送信されますが、パスワードは送信されません。

パスワードは最終的に送信されますが、コマンドがタイムアウトした後です。

以下のコード:

my $cmdString = "instruments -t $traceTemplatePath $AppFolder -e UIASCRIPT $escapedTest " .
    "-e UIARESULTSPATH Logs";
if ($isFirst == 1) {

    $isFirst = 0;

    $password = `cat /Users/\$USER/.password`;

    # Actually spawn the command from Expect.
    my $exp = Expect->spawn($cmdString) 
        or die "Failed to spawn command in Expect: $! \n";
    #change delay if necessary
    $exp->expect(30, [qr/Name .*/]);
    $exp->send("\n");

    $exp->expect(undef, [qr/Password/]);
    $exp->send("$password\n");
}

私がやりたいのは、コマンドがタイムアウトする前にパスワードを送信して、テストスクリプトを実行することです。

4

1 に答える 1

0

クエリを組み合わせて、exp_continueを次のように使用してみてください。

$exp->expect($timeout,
             [ qr/username: /i, sub { my $self = shift;
                                      $self->send("$username\n");
                                      exp_continue; }],
             [ qr/password: /i, sub { my $self = shift;
                                      $self->send("$password\n");
                                      exp_continue; }],
             $shell_prompt);
于 2012-11-23T01:44:54.457 に答える