リモートSeleniumサーバーを使用してCapybaraテストを実行するRailsアプリがあります。Docker上のリモートセレンがJavascriptを正しく処理しない
RailsのアプリとSeleniumサーバーはDockerizedと正常に接続されている両方:https://github.com/mottalrd/capybara-on-dockerized-selenium/blob/master/docker-compose.yml
私の問題は、ドッカー上のリモートSeleniumサーバー上でJavascriptを実行すると動作しないということです。たとえば、この行は、私はローカルに自分のブラウザテストを実行する場合は完璧に動作します:
page.execute_script("$('#js-fileupload').fileupload('send', {files: $('#input_file')[0].files});")
しかし、次のようにリモートセレンに失敗しました。何が問題なの?
Failure/Error: page.execute_script("$('#js-fileupload').fileupload('send', {files: $('#input_file')[0].files});")
Selenium::WebDriver::Error::UnknownError:
(WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 12 milliseconds
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'b5f51c04b891', ip: '172.18.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.1.19-boot2docker', java.version: '1.8.0_03-Ubuntu'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=45.0.2, platform=LINUX, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 40cdda26-bc78-4d56-b3d7-1025483a985b (org.openqa.selenium.WebDriverException)
# [remote server] sun.reflect.NativeConstructorAccessorImpl(NativeConstructorAccessorImpl.java):-2:in `newInstance0'
# [remote server] sun.reflect.NativeConstructorAccessorImpl(NativeConstructorAccessorImpl.java):62:in `newInstance'
# [remote server] sun.reflect.DelegatingConstructorAccessorImpl(DelegatingConstructorAccessorImpl.java):45:in `newInstance'
# [remote server] java.lang.reflect.Constructor(Constructor.java):423:in `newInstance'
# [remote server] org.openqa.selenium.remote.ErrorHandler(ErrorHandler.java):206:in `createThrowable'
# [remote server] org.openqa.selenium.remote.ErrorHandler(ErrorHandler.java):158:in `throwIfResponseFailed'
# [remote server] org.openqa.selenium.remote.RemoteWebDriver(RemoteWebDriver.java):678:in `execute'
# [remote server] org.openqa.selenium.remote.RemoteWebDriver(RemoteWebDriver.java):577:in `executeScript'
# [remote server] sun.reflect.GeneratedMethodAccessor20():-1:in `invoke'
# [remote server] sun.reflect.DelegatingMethodAccessorImpl(DelegatingMethodAccessorImpl.java):43:in `invoke'
# [remote server] java.lang.reflect.Method(Method.java):498:in `invoke'
# [remote server] org.openqa.selenium.support.events.EventFiringWebDriver$2(EventFiringWebDriver.java):103:in `invoke'
# [remote server] com.sun.proxy.$Proxy1():-1:in `executeScript'
# [remote server] org.openqa.selenium.support.events.EventFiringWebDriver(EventFiringWebDriver.java):217:in `executeScript'
# [remote server] org.openqa.selenium.remote.server.handler.ExecuteScript(ExecuteScript.java):56:in `call'
# [remote server] java.util.concurrent.FutureTask(FutureTask.java):266:in `run'
# [remote server] org.openqa.selenium.remote.server.DefaultSession$1(DefaultSession.java):176:in `run'
# [remote server] java.util.concurrent.ThreadPoolExecutor(ThreadPoolExecutor.java):1142:in `runWorker'
# [remote server] java.util.concurrent.ThreadPoolExecutor$Worker(ThreadPoolExecutor.java):617:in `run'
# [remote server] java.lang.Thread(Thread.java):745:in `run'
# /var/lib/gems/2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/remote/response.rb:70:in `assert_ok'
# /var/lib/gems/2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/remote/response.rb:34:in `initialize'
# /var/lib/gems/2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/remote/http/common.rb:78:in `new'
# /var/lib/gems/2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/remote/http/common.rb:78:in `create_response'
# /var/lib/gems/2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/remote/http/default.rb:90:in `request'
# /var/lib/gems/2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
# /var/lib/gems/2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/remote/bridge.rb:649:in `raw_execute'
# /var/lib/gems/2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/remote/bridge.rb:627:in `execute'
# /var/lib/gems/2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/remote/bridge.rb:353:in `executeScript'
# /var/lib/gems/2.3.0/gems/selenium-webdriver-2.53.0/lib/selenium/webdriver/common/driver.rb:220:in `execute_script'
# /var/lib/gems/2.3.0/gems/capybara-2.7.0/lib/capybara/selenium/driver.rb:81:in `execute_script'
# /var/lib/gems/2.3.0/gems/capybara-2.7.0/lib/capybara/session.rb:524:in `execute_script'
# ./spec/features/happy_path_spec.rb:95:in `block (3 levels) in <top (required)>'
# /var/lib/gems/2.3.0/gems/vcr-3.0.1/lib/vcr/util/variable_args_block_caller.rb:9:in `call_block'
# /var/lib/gems/2.3.0/gems/vcr-3.0.1/lib/vcr.rb:189:in `use_cassette'
# ./spec/features/happy_path_spec.rb:10:in `block (2 levels) in <top (required)>'
jqueryファイルアップロードライブラリを使用していて、すべてのjavascriptがうまく動作しているようです。いくつかのJSの負荷の問題がありますか? – mottalrd
リモート環境でファイルをアップロードする場合は、LocalFileDetector(https://github.com/SeleniumHQ/selenium/blob/master/java/client/src/org/)のようなものを使用する必要があると思いますopenqa/selenium/remote/LocalFileDetector.java)を使用して、アップロードがリモート環境で正常に動作するようにします。 –