質問するログイン新規登録

質問編集履歴

1

試したこと、補足情報、新しいエラーの追加をしました。

2019/07/12 05:13

投稿

reon.negi
reon.negi

スコア13

title CHANGED
File without changes
body CHANGED
@@ -115,11 +115,113 @@
115
115
  ```
116
116
  しかし、エラー内容は変わりませんでした。
117
117
 
118
+ ##3.chromedriverが通ったときと同じoptionを追加
118
119
 
120
+
121
+ `selenium-webdriver`が正常に動いた時と同じオプションを追加し、`spec/rails_helper.rb`に include。
122
+
123
+ `spec/support/selenium_chrome.rb`
124
+ ```
125
+ Capybara.register_driver :chrome_headless do |app|
126
+ options = ::Selenium::WebDriver::Chrome::Options.new
127
+
128
+
129
+ options.add_argument('--headless')
130
+ options.add_argument('--no-sandbox')
131
+ options.add_argument('--disable-dev-shm-usage')
132
+ options.add_argument('--window-size=1400,1400')
133
+
134
+
135
+ Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
136
+ end
137
+ ```
138
+
139
+ `spec/rails_helper.rb`
140
+ ```
141
+ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
142
+
143
+ RSpec.configure do |config|
144
+ config.before(:each, type: :system) do
145
+ driven_by :rack_test
146
+ end
147
+
148
+ config.before(:each, type: :system, js: true) do
149
+ driven_by :selenium_chrome_headless
150
+ end
151
+ end
152
+ ```
153
+
154
+ すると9515番ポートの接続を拒否されました。
155
+
156
+ ```
157
+ 1.3) Failure/Error:
158
+ raise e, "Failed to open TCP connection to " +
159
+ "#{conn_address}:#{conn_port} (#{e.message})"
160
+
161
+ Errno::ECONNREFUSED:
162
+ Failed to open TCP connection to 127.0.0.1:9515 (Connection refused - connect(2) for "127.0.0.1" port 9515)
163
+
164
+ [Screenshot]: tmp/screenshots/failures_r_spec_example_groups_ideas_xxxx_690.png
165
+
166
+
167
+
168
+ # /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/remote/http/default.rb:129:in `response_for'
169
+ # /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/remote/http/default.rb:82:in `request'
170
+ # /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/remote/http/common.rb:64:in `call'
171
+ # /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/remote/bridge.rb:167:in `execute'
172
+ # /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/remote/w3c/bridge.rb:567:in `execute'
173
+ # /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/remote/w3c/bridge.rb:173:in `window_handles'
174
+ # /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/common/driver.rb:187:in `window_handles'
175
+ # /usr/local/bundle/gems/capybara-3.15.1/lib/capybara/selenium/driver.rb:178:in `window_handles'
176
+ # /usr/local/bundle/gems/capybara-3.15.1/lib/capybara/selenium/driver_specializations/chrome_driver.rb:34:in `reset!'
177
+ # /usr/local/bundle/gems/capybara-3.15.1/lib/capybara/session.rb:128:in `reset!'
178
+ # /usr/local/bundle/gems/capybara-3.15.1/lib/capybara.rb:315:in `block in reset_sessions!'
179
+ # /usr/local/bundle/gems/capybara-3.15.1/lib/capybara.rb:315:in `reverse_each'
180
+ # /usr/local/bundle/gems/capybara-3.15.1/lib/capybara.rb:315:in `reset_sessions!'
181
+ # /usr/local/bundle/gems/capybara-3.15.1/lib/capybara/rspec.rb:18:in `block (2 levels) in <top (required)>'
182
+ # ------------------
183
+ # --- Caused by: ---
184
+ # Errno::ECONNREFUSED:
185
+ # Connection refused - connect(2) for "127.0.0.1" port 9515
186
+ # /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/remote/http/default.rb:129:in `response_for'
187
+ ```
188
+
189
+ ##4. chromedriverが起動しているか確かめる
190
+
191
+ chromedriverが起動していないのでは?と思い、以下のコマンドで確認したところ、9515番portは起動していませんでした。
192
+ `netstat -atn|grep LISTEN`
193
+ ```
194
+ tcp6 0 0 ::1.3000 *.* LISTEN
195
+ tcp4 0 0 *.3000 *.* LISTEN
196
+ tcp6 0 0 ::1.4306 *.* LISTEN
197
+ tcp4 0 0 *.4306 *.* LISTEN
198
+ tcp4 0 0 127.0.0.1.53253 *.* LISTEN
199
+ tcp6 0 0 ::1.53253 *.* LISTEN
200
+ tcp4 0 0 127.0.0.1.631 *.* LISTEN
201
+ tcp6 0 0 ::1.631 *.* LISTEN
202
+ tcp46 0 0 *.33060 *.* LISTEN
203
+ tcp4 0 0 127.0.0.1.3306 *.* LISTEN
204
+ ```
205
+
206
+ ##chromeのversionを合わせる
207
+ `ChromeDriver`を`Google Chrome`のバージョンに合わせてみようとしましたが、`ChromeDriver 75.0.3770.100`が見つかりませんでした。
208
+ - ChromeDriver 75.0.3770.90
209
+ - Google Chrome 75.0.3770.100
210
+ 参考: https://chida09.com/selenium-error-tcpconnection/
211
+
212
+
213
+
214
+ `chromedriver`が起動しない原因がわかりません。
215
+
119
216
  ここ数日間ハマっており、、なかなか解決しません。。よろしくお願いいたします????‍♂️
120
217
  ### 補足情報(FW/ツールのバージョンなど)
121
218
  - **Rails 5.1.7**
122
219
  - **RSpec 3.8**
123
- - **ChromeDriver 73.0.3683.75**
220
+ - **ChromeDriver 75.0.3770.90**
221
+ - **Google Chrome 75.0.3770.100**
124
222
  - **capybara (3.15.1)**
125
- - **[DockerImage](https://hub.docker.com/_/ruby?tab=tags&page=9)**
223
+ - **[DockerImage](https://hub.docker.com/_/ruby?tab=tags&page=9)**
224
+ - chromedriverのパスは通っている。
225
+ - スクリーンショットは真っ白
226
+ - 使用できるドライバ↓
227
+ `:selenium, :selenium_headless, :selenium_chrome, :selenium_chrome_headless`の4つ。