1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00
teamcapybara--capybara/spec/selenium_spec_chrome.rb

66 lines
2.4 KiB
Ruby
Raw Normal View History

2016-03-07 19:52:19 -05:00
# frozen_string_literal: true
require 'spec_helper'
2015-05-21 14:00:36 -04:00
require 'selenium-webdriver'
require 'shared_selenium_session'
2015-07-21 20:43:11 -04:00
Capybara.register_driver :selenium_chrome do |app|
args = ENV['TRAVIS'] ? ['no-sandbox' ] : []
2017-05-03 18:21:07 -04:00
if ENV['CAPYBARA_CHROME_HEADLESS']
args << 'headless'
Selenium::WebDriver::Chrome.path='/usr/bin/google-chrome-beta' if ENV['TRAVIS']
end
Capybara::Selenium::Driver.new(app, :browser => :chrome, :args => args)
end
Capybara.register_driver :selenium_chrome_clear_storage do |app|
args = ENV['TRAVIS'] ? ['no-sandbox' ] : []
2017-05-03 18:21:07 -04:00
if ENV['CAPYBARA_CHROME_HEADLESS']
args << 'headless'
Selenium::WebDriver::Chrome.path='/usr/bin/google-chrome-beta' if ENV['TRAVIS']
end
Capybara::Selenium::Driver.new(app, :browser => :chrome,
:args => args,
clear_local_storage: true,
clear_session_storage: true)
end
module TestSessions
2015-05-21 14:00:36 -04:00
Chrome = Capybara::Session.new(:selenium_chrome, TestApp)
end
2016-10-20 12:53:42 -04:00
skipped_tests = [:response_headers, :status_code, :trigger]
skipped_tests << :windows if ENV['TRAVIS'] && ENV['SKIP_WINDOW']
# skip window tests when headless for now - closing a window not supported by chromedriver/chrome
skipped_tests << :windows if ENV['TRAVIS'] && ENV['CAPYBARA_CHROME_HEADLESS']
2016-10-20 12:53:42 -04:00
Capybara::SpecHelper.run_specs TestSessions::Chrome, "selenium_chrome", capybara_skip: skipped_tests
RSpec.describe "Capybara::Session with chrome" do
include Capybara::SpecHelper
include_examples "Capybara::Session", TestSessions::Chrome, :selenium_chrome
context "storage" do
describe "#reset!" do
it "does not clear either storage by default" do
@session = TestSessions::Chrome
@session.visit('/with_js')
@session.find(:css, '#set-storage').click
@session.reset!
@session.visit('/with_js')
expect(@session.driver.browser.local_storage.keys).not_to be_empty
expect(@session.driver.browser.session_storage.keys).not_to be_empty
end
it "clears storage when set" do
@session = Capybara::Session.new(:selenium_chrome_clear_storage, TestApp)
@session.visit('/with_js')
@session.find(:css, '#set-storage').click
@session.reset!
@session.visit('/with_js')
expect(@session.driver.browser.local_storage.keys).to be_empty
expect(@session.driver.browser.session_storage.keys).to be_empty
end
end
end
end