Web ページでいくつかのタスクを自動化しようとしています。その一部には、「OK」を押す必要がある JavaScript アラートを表示するリンクをクリックすることが含まれます。問題は、その時点に到達すると、次のエラーで失敗することです
/Users/username/.gem/ruby/2.0.0/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/remote/http/common.rb:66:in `create_response': unexpected response, code=405, content-type="text/plain" (Selenium::WebDriver::Error::WebDriverError)
Invalid Command Method - Request => {"headers":{"Accept":"application/json","Accept-Encoding":"gzip;q=1.0,deflate;q=0.6,identity;q=0.3","Cache-Control":"no-cache","Connection":"close","Host":"127.0.0.1:8910","User-Agent":"Ruby"},"httpVersion":"1.1","method":"GET","url":"/alert_text","urlParsed":{"anchor":"","query":"","file":"alert_text","directory":"/","path":"/alert_text","relative":"/alert_text","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/alert_text","queryKey":{},"chunks":["alert_text"]},"urlOriginal":"/session/6772bf50-2ad9-11e3-86e7-55e618e30fa2/alert_text"}
from /Users/username/.gem/ruby/2.0.0/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/remote/http/default.rb:66:in `request'
from /Users/username/.gem/ruby/2.0.0/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
from /Users/username/.gem/ruby/2.0.0/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/remote/bridge.rb:634:in `raw_execute'
from /Users/username/.gem/ruby/2.0.0/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/remote/bridge.rb:612:in `execute'
from /Users/username/.gem/ruby/2.0.0/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/remote/bridge.rb:150:in `getAlertText'
from /Users/username/.gem/ruby/2.0.0/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/common/alert.rb:9:in `initialize'
from /Users/username/.gem/ruby/2.0.0/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/common/target_locator.rb:76:in `new'
from /Users/username/.gem/ruby/2.0.0/gems/selenium-webdriver-2.35.1/lib/selenium/webdriver/common/target_locator.rb:76:in `alert'
from /Users/username/.gem/ruby/2.0.0/gems/watir-webdriver-0.6.4/lib/watir-webdriver/alert.rb:93:in `assert_exists'
from /Users/username/.gem/ruby/2.0.0/gems/watir-webdriver-0.6.4/lib/watir-webdriver/alert.rb:37:in `ok'
from ./olx:21:in `block in <main>'
from ./olx:19:in `times'
from ./olx:19:in `<main>'
オンラインで検索すると、問題はGhostdriver に関連している可能性があり、おそらく phantomjs はそれを実行できないようですが、その概念は私には少し奇妙に思えます (結局のところ、それは phantom* js*と呼ばれ、アラートはかなり基本的な JavaScript です) )、しかし、私の見方が間違っているのかもしれません。
クロムでスクリプトを実行すると、問題なく動作します。