0

Iamはポップアップウィンドウで作業しています。つまり、基本認証ウィンドウを処理しています。テストを実行しようとしている以下のコードを見つけてください。

{

require 'watir/ie'

require 'win32ole'

require 'watir/WindowHelper'

ie=Watir::IE.new

ie.goto "http://www.google.com"

helper = WindowHelper.new

helper.logon('Connect to proxy1','Mohammed','WE8SR')        # where title=Connect to Proxy1 is the auth window,User name= Mohammed and Password=WE8SR.
puts x.inspect

ie.close

}

何が起こるかというと、ユーザー名とパスワードが認証ウィンドウに入力されることはなく、Timedout Error表示されます。

ruby google_search.rb 
C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-1.7.1/lib/watir/ie-class.rb:494:in sleep': execution expired (Timeout::Error) 
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-1.7.1/lib/watir/ie-class.rb:494:in block in wait' 
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-1.7.1/lib/watir/ie-class.rb:491:in wait' 
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/watir-1.7.1/lib/watir/ie-class.rb:357:in goto' 
from google_search.rb:96:in `<main>' 
>Exit code: 1

これは私が使用しているRuby1.9.2のバージョンの問題ですか?

のメソッドのコードを変更して、実行しlogonWindowHelper.rbみました。

// Actual method in the "WindowHelper.rb" file
{

    def logon(title,name = 'john doe',password = 'john doe')

        @autoit.WinWait title, ""

        @autoit.Send name

        @autoit.Send "{TAB}"

        @autoit.Send password

        @autoit.Send "{ENTER}"

    end
 }

私が変更して時々動作することがわかったコード

{

        def logon(title,name,password)

        @autoit.WinWait title, ""

        @autoit.Send name

        @autoit.Send "{TAB}"

        @autoit.Send password

        @autoit.Send "{ENTER}"

    end

}

私はさまざまなブログで解決策を試しました。私が何かを逃しているなら私に提案してください。

4

1 に答える 1

0

エラーテキストに goto メソッドで使用される待機メソッドでタイムアウトエラーが発生したと記載されているため、BASIC 認証を処理する前にスクリプトが停止したと思います。

次のようなgotoメソッドの代わりにie.navigateメソッドを試してください

require 'watir/ie'
require 'win32ole'
require 'watir/WindowHelper'

ie=Watir::IE.new

ie.ie.navigate "http://www.google.com"

helper = WindowHelper.new

helper.logon('Connect to proxy1','Mohammed','WE8SR')        # where title=Connect to Proxy1 is the auth window,User name= Mohammed and Password=WE8SR.
puts x.inspect

ie.close
于 2011-04-14T06:32:10.437 に答える