質問編集履歴

1

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

2019/07/12 05:13

投稿

reon.negi
reon.negi

スコア13

test CHANGED
File without changes
test CHANGED
@@ -232,6 +232,200 @@
232
232
 
233
233
 
234
234
 
235
+ ##3.chromedriverが通ったときと同じoptionを追加
236
+
237
+
238
+
239
+
240
+
241
+ `selenium-webdriver`が正常に動いた時と同じオプションを追加し、`spec/rails_helper.rb`に include。
242
+
243
+
244
+
245
+ `spec/support/selenium_chrome.rb`
246
+
247
+ ```
248
+
249
+ Capybara.register_driver :chrome_headless do |app|
250
+
251
+ options = ::Selenium::WebDriver::Chrome::Options.new
252
+
253
+
254
+
255
+
256
+
257
+ options.add_argument('--headless')
258
+
259
+ options.add_argument('--no-sandbox')
260
+
261
+ options.add_argument('--disable-dev-shm-usage')
262
+
263
+ options.add_argument('--window-size=1400,1400')
264
+
265
+
266
+
267
+
268
+
269
+ Capybara::Selenium::Driver.new(app, browser: :chrome, options: options)
270
+
271
+ end
272
+
273
+ ```
274
+
275
+
276
+
277
+ `spec/rails_helper.rb`
278
+
279
+ ```
280
+
281
+ Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
282
+
283
+
284
+
285
+ RSpec.configure do |config|
286
+
287
+ config.before(:each, type: :system) do
288
+
289
+ driven_by :rack_test
290
+
291
+ end
292
+
293
+
294
+
295
+ config.before(:each, type: :system, js: true) do
296
+
297
+ driven_by :selenium_chrome_headless
298
+
299
+ end
300
+
301
+ end
302
+
303
+ ```
304
+
305
+
306
+
307
+ すると9515番ポートの接続を拒否されました。
308
+
309
+
310
+
311
+ ```
312
+
313
+ 1.3) Failure/Error:
314
+
315
+ raise e, "Failed to open TCP connection to " +
316
+
317
+ "#{conn_address}:#{conn_port} (#{e.message})"
318
+
319
+
320
+
321
+ Errno::ECONNREFUSED:
322
+
323
+ Failed to open TCP connection to 127.0.0.1:9515 (Connection refused - connect(2) for "127.0.0.1" port 9515)
324
+
325
+
326
+
327
+ [Screenshot]: tmp/screenshots/failures_r_spec_example_groups_ideas_xxxx_690.png
328
+
329
+
330
+
331
+
332
+
333
+
334
+
335
+ # /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/remote/http/default.rb:129:in `response_for'
336
+
337
+ # /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/remote/http/default.rb:82:in `request'
338
+
339
+ # /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/remote/http/common.rb:64:in `call'
340
+
341
+ # /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/remote/bridge.rb:167:in `execute'
342
+
343
+ # /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/remote/w3c/bridge.rb:567:in `execute'
344
+
345
+ # /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/remote/w3c/bridge.rb:173:in `window_handles'
346
+
347
+ # /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/common/driver.rb:187:in `window_handles'
348
+
349
+ # /usr/local/bundle/gems/capybara-3.15.1/lib/capybara/selenium/driver.rb:178:in `window_handles'
350
+
351
+ # /usr/local/bundle/gems/capybara-3.15.1/lib/capybara/selenium/driver_specializations/chrome_driver.rb:34:in `reset!'
352
+
353
+ # /usr/local/bundle/gems/capybara-3.15.1/lib/capybara/session.rb:128:in `reset!'
354
+
355
+ # /usr/local/bundle/gems/capybara-3.15.1/lib/capybara.rb:315:in `block in reset_sessions!'
356
+
357
+ # /usr/local/bundle/gems/capybara-3.15.1/lib/capybara.rb:315:in `reverse_each'
358
+
359
+ # /usr/local/bundle/gems/capybara-3.15.1/lib/capybara.rb:315:in `reset_sessions!'
360
+
361
+ # /usr/local/bundle/gems/capybara-3.15.1/lib/capybara/rspec.rb:18:in `block (2 levels) in <top (required)>'
362
+
363
+ # ------------------
364
+
365
+ # --- Caused by: ---
366
+
367
+ # Errno::ECONNREFUSED:
368
+
369
+ # Connection refused - connect(2) for "127.0.0.1" port 9515
370
+
371
+ # /usr/local/bundle/gems/selenium-webdriver-3.142.3/lib/selenium/webdriver/remote/http/default.rb:129:in `response_for'
372
+
373
+ ```
374
+
375
+
376
+
377
+ ##4. chromedriverが起動しているか確かめる
378
+
379
+
380
+
381
+ chromedriverが起動していないのでは?と思い、以下のコマンドで確認したところ、9515番portは起動していませんでした。
382
+
383
+ `netstat -atn|grep LISTEN`
384
+
385
+ ```
386
+
387
+ tcp6 0 0 ::1.3000 *.* LISTEN
388
+
389
+ tcp4 0 0 *.3000 *.* LISTEN
390
+
391
+ tcp6 0 0 ::1.4306 *.* LISTEN
392
+
393
+ tcp4 0 0 *.4306 *.* LISTEN
394
+
395
+ tcp4 0 0 127.0.0.1.53253 *.* LISTEN
396
+
397
+ tcp6 0 0 ::1.53253 *.* LISTEN
398
+
399
+ tcp4 0 0 127.0.0.1.631 *.* LISTEN
400
+
401
+ tcp6 0 0 ::1.631 *.* LISTEN
402
+
403
+ tcp46 0 0 *.33060 *.* LISTEN
404
+
405
+ tcp4 0 0 127.0.0.1.3306 *.* LISTEN
406
+
407
+ ```
408
+
409
+
410
+
411
+ ##chromeのversionを合わせる
412
+
413
+ `ChromeDriver`を`Google Chrome`のバージョンに合わせてみようとしましたが、`ChromeDriver 75.0.3770.100`が見つかりませんでした。
414
+
415
+ - ChromeDriver 75.0.3770.90
416
+
417
+ - Google Chrome 75.0.3770.100
418
+
419
+ 参考: https://chida09.com/selenium-error-tcpconnection/
420
+
421
+
422
+
423
+
424
+
425
+
426
+
427
+ `chromedriver`が起動しない原因がわかりません。
428
+
235
429
 
236
430
 
237
431
  ここ数日間ハマっており、、なかなか解決しません。。よろしくお願いいたします????‍♂️
@@ -242,8 +436,18 @@
242
436
 
243
437
  - **RSpec 3.8**
244
438
 
245
- - **ChromeDriver 73.0.3683.75**
439
+ - **ChromeDriver 75.0.3770.90**
440
+
441
+ - **Google Chrome 75.0.3770.100**
246
442
 
247
443
  - **capybara (3.15.1)**
248
444
 
249
445
  - **[DockerImage](https://hub.docker.com/_/ruby?tab=tags&page=9)**
446
+
447
+ - chromedriverのパスは通っている。
448
+
449
+ - スクリーンショットは真っ白
450
+
451
+ - 使用できるドライバ↓
452
+
453
+ `:selenium, :selenium_headless, :selenium_chrome, :selenium_chrome_headless`の4つ。