Disable JavaScript on IE-specific scenarios
This commit is contained in:
@@ -132,26 +132,33 @@ feature "Home" do
|
||||
end
|
||||
|
||||
feature 'IE alert' do
|
||||
scenario 'IE visitors are presented with an alert until they close it', :js do
|
||||
page.driver.headers = { "User-Agent" => "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)" }
|
||||
scenario 'IE visitors are presented with an alert until they close it' do
|
||||
# Selenium API does not include page request/response inspection methods
|
||||
# so we must use Capybara::RackTest driver to set the browser's headers
|
||||
Capybara.current_session.driver.header(
|
||||
'User-Agent',
|
||||
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'
|
||||
)
|
||||
|
||||
visit root_path
|
||||
expect(page).to have_xpath(ie_alert_box_xpath, visible: false)
|
||||
expect(page.driver.cookies['ie_alert_closed']).to be_nil
|
||||
expect(page.driver.request.cookies['ie_alert_closed']).to be_nil
|
||||
|
||||
# faking close button, since a normal find and click
|
||||
# will not work as the element is inside a HTML conditional comment
|
||||
page.driver.set_cookie 'ie_alert_closed', 'true'
|
||||
page.driver.browser.set_cookie('ie_alert_closed=true')
|
||||
|
||||
visit root_path
|
||||
expect(page).not_to have_xpath(ie_alert_box_xpath, visible: false)
|
||||
expect(page.driver.cookies["ie_alert_closed"].value).to eq('true')
|
||||
expect(page.driver.request.cookies['ie_alert_closed']).to eq('true')
|
||||
|
||||
Capybara.current_session.driver.header('', '')
|
||||
end
|
||||
|
||||
scenario 'non-IE visitors are not bothered with IE alerts', :js do
|
||||
scenario 'non-IE visitors are not bothered with IE alerts' do
|
||||
visit root_path
|
||||
expect(page).not_to have_xpath(ie_alert_box_xpath, visible: false)
|
||||
expect(page.driver.cookies['ie_alert_closed']).to be_nil
|
||||
expect(page.driver.request.cookies['ie_alert_closed']).to be_nil
|
||||
end
|
||||
|
||||
def ie_alert_box_xpath
|
||||
|
||||
Reference in New Issue
Block a user