とあるサイトで、とある処理を自動化したくて、SeleniumWebDriverで下記のように書きました。
- Windows8
- ruby 2.2.2p95
driver = Selenium::WebDriver.for :firefox
driver.get("とあるURL")
button.click # とあるボタンをクリックする
wait = Selenium::WebDriver::Wait.new(:timeout => 600) # 10分
wait.until {
driver.find_element(:how, :what) # 表示まで2,3分かかるエレメント
}
ってやると60秒後に
抜粋
Net::ReadTimeout
IO::EWOULDBLOCKWaitReadable:
A non-blocking socket operation could not be completed immediately. - read would block
というエラーになってしまいました。
SeleniumWebDriverで「要素が表示されるまで待つ」と言ったら 上記のwait.until
じゃないですか。これ以外知らないじゃないですか ←勉強不足
巡り巡って、webdriverのタイムアウトを設定する - Qiita
の記事にたどり着いて
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 600 # 10分
driver = Selenium::WebDriver.for :firefox, :http_client => client
driver.get("とあるURL")
button.click # とあるボタンをクリックする
driver.find_element(:how, :what) # 表示まで2,3分かかるエレメント
ってやったらうまくいきました。
んー、でもみなさん client = Selenium::WebDriver::Remote::Http::Default.new
こんなことしてないですよね。どういう時にこういうことになるのかな。。。