Skip to content
Permalink
Browse files

#3391 Switch to selenium with chrome headless

  • Loading branch information...
bricesanchez committed Aug 23, 2018
1 parent 42282ca commit 8fdbb5e7ee95f355861530c7bd017140de7718d7
@@ -11,7 +11,7 @@ end

gem 'spring'
gem 'spring-commands-rspec'
gem 'poltergeist', '>= 1.8.1'
gem 'selenium-webdriver', require: false

# Add support for refinerycms-acts-as-indexed
gem 'refinerycms-acts-as-indexed', ['~> 3.0', '>= 3.0.0']
@@ -443,7 +443,7 @@ var link_dialog = {
}
}

$('.form-actions-dialog #cancel_button').trigger('click');
$('.form-actions-dialog #cancel_button').click;
});
},

@@ -22,7 +22,7 @@
$(".form-actions.form-actions-dialog .form-actions-left a.close_dialog").click (e) ->
titlebar_close_button = $('.ui-dialog-titlebar-close')
titlebar_close_button = parent.$('.ui-dialog-titlebar-close') if parent
titlebar_close_button.trigger('click')
titlebar_close_button.click
e.preventDefault()

$("a.suppress").on "click", (e) ->
@@ -1,6 +1,6 @@
shared_context 'admin images tab' do

let(:open_upload_dialog) { find('a', text: ::I18n.t('create_new_image', scope: 'refinery.admin.images.actions')).trigger(:click) }
let(:open_upload_dialog) { find('a', text: ::I18n.t('create_new_image', scope: 'refinery.admin.images.actions')).click }
let(:select_upload) {}
let(:initialize_context) {}
let(:index_in_frame) {false}
@@ -152,7 +152,7 @@ module Admin
it "Creates a page", js:true do
visit refinery.admin_pages_path

find('a', text: 'Add new page').trigger(:click)
find('a', text: 'Add new page').click

fill_in "Title", :with => "My first page"
expect { click_button "Save" }.to change(Refinery::Page, :count).from(0).to(1)
@@ -173,7 +173,7 @@ module Admin

fill_in "Title", :with => "My first page"

find('#toggle_advanced_options').trigger(:click)
find('#toggle_advanced_options').click

fill_in "Menu title", :with => "The first page"

@@ -215,7 +215,7 @@ module Admin

context 'when saving and returning to index' do
it "updates page", js: true do
find("a[href$='#{updateable_page.slug}/edit']").trigger(:click)
find("a[href$='#{updateable_page.slug}/edit']").click

fill_in "Title", :with => "Updated"
find("#submit_button").click
@@ -366,7 +366,7 @@ module Admin

find('a[tooltip^=Edit]').click
fill_in 'Title', :with => 'Searchable'
find('#toggle_advanced_options').trigger(:click)
find('#toggle_advanced_options').click
select 'Searchable', :from => 'View template'
Timeout::timeout(5) do
click_button 'Preview'
@@ -380,7 +380,7 @@ module Admin
it "will not save when just previewing", js:true do
visit refinery.admin_pages_path

find('a', text: 'Add new page').trigger(:click)
find('a', text: 'Add new page').click
fill_in "Title", :with => "My first page"
window = window_opened_by do
click_button "Preview"
@@ -421,7 +421,9 @@ module Admin
it "will show delete button" do
visit refinery.admin_pages_path

find('a[tooltip="Remove this page forever"]').trigger(:click)
find('a[tooltip="Remove this page forever"]').click

page.accept_alert

expect(page).to have_content("'Delete me' was successfully removed.")

@@ -474,7 +476,7 @@ module Admin
describe "add a page with title for default locale", js:true do
before do
visit refinery.admin_pages_path
find('a', text: "Add new page").trigger(:click)
find('a', text: "Add new page").click
fill_in "Title", :with => "News"
click_button "Save"
end
@@ -622,7 +624,7 @@ module Admin

it "lets you add a Russian title without an English title" do
ru_page.destroy!
find('a', text: 'Add new page').trigger(:click)
find('a', text: 'Add new page').click
switch_page_form_locale "RU"

fill_in "Title", :with => ru_page_title
@@ -684,7 +686,7 @@ module Admin
expect(sub_page.parent).to eq(parent_page)
visit refinery.admin_pages_path
within "#page_#{sub_page.id}" do
find("a.edit_icon").trigger(:click)
find("a.edit_icon").click
end
fill_in "Title", :with => ru_page_title
click_button "Save"
@@ -701,7 +703,7 @@ module Admin

it "adds new page part", js: true do
visit refinery.new_admin_page_path
find("#add_page_part").trigger(:click)
find("#add_page_part").click

within "#new_page_part_dialog" do
fill_in "new_page_part_title", :with => "testy"
@@ -735,7 +737,7 @@ module Admin
end

2.times do
find("#delete_page_part").trigger(:click)
find("#delete_page_part").click
# Poltergeist automatically accepts dialogues.
if Capybara.javascript_driver != :poltergeist
page.driver.browser.switch_to.alert.accept
@@ -776,7 +778,7 @@ module Admin
specify 'sub page should inherit them', js: true do
visit refinery.edit_admin_page_path(@page.id)

find('#toggle_advanced_options').trigger(:click)
find('#toggle_advanced_options').click

within '#page_layout_template' do
expect(page.find('option[value=refinery]')).to be_selected
@@ -806,7 +808,7 @@ module Admin

specify "should retain the html", js:true do
visit refinery.admin_pages_path
find('a[tooltip="Edit this page"]').trigger(:click)
find('a[tooltip="Edit this page"]').click
Capybara.ignore_hidden_elements = false
expect(page).to have_content("header class='regression'")
Capybara.ignore_hidden_elements = true
@@ -22,7 +22,7 @@ module Admin
context "new/create" do
it "uploads file", :js => true do
visit refinery.admin_resources_path
find('a', text: 'Upload new file').trigger(:click)
find('a', text: 'Upload new file').click

expect(page).to have_selector 'iframe#dialog_iframe'

@@ -62,10 +62,14 @@
require support_file
end

Capybara.register_driver :poltergeist_debug do |app|
Capybara::Poltergeist::Driver.new(app, debug: false, js_errors: true, inspector: :open)
require "selenium/webdriver"

Capybara.register_driver :selenium_chrome_headless do |app|
browser_options = ::Selenium::WebDriver::Chrome::Options.new
browser_options.args << '--headless'
browser_options.args << '--disable-gpu'
browser_options.args << '--window-size=1440,1080'
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
end

require 'capybara/poltergeist'
Capybara.javascript_driver = :poltergeist
Capybara.always_include_port = true
Capybara.javascript_driver = (ENV['CAPYBARA_DRIVER'] || :selenium_chrome_headless).to_sym
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
s.add_dependency 'database_cleaner', '~> 1.6'
s.add_dependency 'factory_bot_rails', '~> 4.8'
s.add_dependency 'rspec-rails', '~> 3.5'
s.add_dependency 'capybara', '~> 2.7'
s.add_dependency 'capybara', '~> 2.18'
s.add_dependency 'rails-controller-testing', '~> 0.1.1'

s.required_ruby_version = Refinery::Version.required_ruby_version

0 comments on commit 8fdbb5e

Please sign in to comment.
You can’t perform that action at this time.