From 8408bfdcf00f7cb97b21b578e2caca4779cf1d6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 27 May 2020 18:51:43 +0200 Subject: [PATCH] Don't use ckeditor.setData in specs After upgrading to chromedriver 80, tests checking CKEditor's content were causing chromedriver to hang. That's why we were configuring webdrivers to use an older chromedriver. Version 80 of chromedriver introduced several issues regarding frames. Debugging shows in this case chromedriver froze when we used `setData` and then `within_frame`. Since adding a `sleep` call made it work, we think `within_frame` was being executed before `setData` had finished. The fact that `setData` causes the browser to enter the frame having CKEditor is probably the reason. Even though the `setData` method provides a callback when it's finished, configuring it so the rest of the Ruby code isn't executed until that happens leads to complex code. Using Capybara's `set` to fill in the editor is IMHO a bit easier to understand. After this change, since we're using a method provided by Capybara instead of executing asynchronous JavaScript code, we don't have to check CKEditor has been filled anymore. The "Admin Active polls add" test, which failed on my machine without that check, now passes. --- spec/support/common_actions/verifications.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/spec/support/common_actions/verifications.rb b/spec/support/common_actions/verifications.rb index 92ef462e0..d9c4b2c68 100644 --- a/spec/support/common_actions/verifications.rb +++ b/spec/support/common_actions/verifications.rb @@ -51,14 +51,8 @@ module Verifications sleep 0.01 end - # Fill the editor content - page.execute_script <<-SCRIPT - var ckeditor = CKEDITOR.instances.#{locator} - ckeditor.setData("#{with}") - ckeditor.focus() - ckeditor.updateElement() - SCRIPT - - expect(page).to have_ckeditor label, with: with + within("#cke_#{locator}") do + within_frame(0) { find("body").set(with) } + end end end