[ruby-list:50760] Re: [質問] rescue節で、他パッケージのメッセージ出力を抑止したい
From:
Tadashi Saito <tad.a.digger@...>
Date:
2019-05-03 16:00:04 UTC
List:
ruby-list #50760
山口さん
斎藤です。
2019年5月4日(土) 0:26 <yamataka@u08.itscom.net>:
> > 最新 version のみにしました。
> > しばらくモニタリングしてみます。
>
> 2019-05-04 00:12:13 +0900 [INFO] Click This device
> 2019-05-04 00:12:13 +0900 [INFO] Checking alertTitle dialog ...
> 2019-05-04 00:14:14 WARN Selenium [DEPRECATION]
> Selenium::WebDriver::Error::TimeOutError is deprecated. Use
> Selenium::WebDriver::Error::TimeoutError (ensure the driver supports W3C
> WebDriver specification) instead.
> 2019-05-04 00:14:14 +0900 [INFO] No alertTitle dialog
>
> となり、Selenium WebDriver Error 出力されてしまいます。
>
> https://github.com/yamatakau08/appium_sample/blob/40a067dbaec33861f383d51b4f40b9c88a70d560/tidal/tidal.rb#L141
> の箇所です。
>
>
なるほど、うまく行かなくて残念です。ただ調べていると、3.141.5926 (2019-04-18) のchangelog相当には
> Fixed an issue when Selenium itself would print deprecation warning for
TimeoutError
https://github.com/SeleniumHQ/selenium/blob/8389311401473048c215f0885dc5dc5488a311eb/rb/CHANGES#L53-L55
というのがあるので、やはり selenium-webdriver gem側が相当あやしいように思います。
もしご自身で、deprecatedな定数を直接触っていないのであれば、
* プロセスの再起動をしていない等、古いバージョンのgemを使ったままになっている
(これは実行環境によるので、何とも言えないところです)
* 間接依存している他のgemが古い方の定数を使っている
くらいしか、残りの可能性はない気がします。
参考までに、自分は以下の3行のプログラムを実行してみました
require 'selenium-webdriver'
wait = Selenium::WebDriver::Wait.new(timeout: 0)
wait.until { sleep(1) }
が、deprecationの警告は出ませんでした。
Traceback (most recent call last):
1: from sample.rb:5:in `<main>'
/home/tadashi/git/selenium-sample/vendor/bundle/ruby/2.6.0/gems/selenium-webdriver-3.142.0/lib/selenium/webdriver/common/wait.rb:73:in
`until': timed out after 0 seconds
(Selenium::WebDriver::Error::TimeoutError)
またこういう時、Bundler(Gemfile,Gemfile.lock)を使うと、依存するgemのバージョンを固定・明示できて便利です。
自分が試したものは、ここに上げておきました。参考にしてください。
https://github.com/tadd/selenium-sample
もちろん、他の方が挙げてくださった方法で「出力を無視する」というのも、アリだと思います。
--
斎藤 匡