Skip to content

Commit

Permalink
rb - update spec guards from legacy safari to apple safari
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Sep 18, 2016
1 parent 6d52426 commit 88fdb88
Show file tree
Hide file tree
Showing 7 changed files with 194 additions and 163 deletions.
20 changes: 12 additions & 8 deletions rb/spec/integration/selenium/webdriver/element_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ module WebDriver
driver.find_element(id: 'working').send_keys('foo', 'bar')
end

it 'should send key presses' do
driver.navigate.to url_for('javascriptPage.html')
key_reporter = driver.find_element(id: 'keyReporter')
not_compliant_on browser: :safari do
it 'should send key presses' do
driver.navigate.to url_for('javascriptPage.html')
key_reporter = driver.find_element(id: 'keyReporter')

key_reporter.send_keys('Tet', :arrow_left, 's')
expect(key_reporter.attribute('value')).to eq('Test')
key_reporter.send_keys('Tet', :arrow_left, 's')
expect(key_reporter.attribute('value')).to eq('Test')
end
end

# PhantomJS on windows issue: https://github.com/ariya/phantomjs/issues/10993
Expand Down Expand Up @@ -130,9 +132,11 @@ module WebDriver
expect(driver.find_element(class: 'header').text).to eq('XHTML Might Be The Future')
end

it 'should get displayed' do
driver.navigate.to url_for('xhtmlTest.html')
expect(driver.find_element(class: 'header')).to be_displayed
not_compliant_on browser: :safari do
it 'should get displayed' do
driver.navigate.to url_for('xhtmlTest.html')
expect(driver.find_element(class: 'header')).to be_displayed
end
end

it 'should get location' do
Expand Down
36 changes: 17 additions & 19 deletions rb/spec/integration/selenium/webdriver/navigation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,29 @@
require_relative 'spec_helper'

describe 'Navigation' do
not_compliant_on browser: :safari do
it 'should navigate back and forward' do
form_title = 'We Leave From Here'
result_title = 'We Arrive Here'
form_url = url_for 'formPage.html'
result_url = url_for 'resultPage.html'
it 'should navigate back and forward' do
form_title = 'We Leave From Here'
result_title = 'We Arrive Here'
form_url = url_for 'formPage.html'
result_url = url_for 'resultPage.html'

driver.navigate.to form_url
expect(driver.title).to eq(form_title)
driver.navigate.to form_url
expect(driver.title).to eq(form_title)

driver.find_element(id: 'imageButton').click
wait.until { driver.title != form_title }
driver.find_element(id: 'imageButton').click
wait.until { driver.title != form_title }

expect(driver.current_url).to include(result_url)
expect(driver.title).to eq(result_title)
expect(driver.current_url).to include(result_url)
expect(driver.title).to eq(result_title)

driver.navigate.back
driver.navigate.back

expect(driver.current_url).to include(form_url)
expect(driver.title).to eq(form_title)
expect(driver.current_url).to include(form_url)
expect(driver.title).to eq(form_title)

driver.navigate.forward
expect(driver.current_url).to include(result_url)
expect(driver.title).to eq(result_title)
end
driver.navigate.forward
expect(driver.current_url).to include(result_url)
expect(driver.title).to eq(result_title)
end

it 'should refresh the page' do
Expand Down
133 changes: 68 additions & 65 deletions rb/spec/integration/selenium/webdriver/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,97 +21,100 @@

module Selenium
module WebDriver
describe Options do
not_compliant_on browser: [:firefox, :ie, :edge] do
describe 'logs' do
compliant_on driver: :remote do
it 'can fetch remote log types' do
expect(driver.manage.logs.available_types).to include(:server, :client)
# Safari bug - no logs or cookies
not_compliant_on browser: :safari do
describe Options do
not_compliant_on browser: [:firefox, :ie, :edge] do
describe 'logs' do
compliant_on driver: :remote do
it 'can fetch remote log types' do
expect(driver.manage.logs.available_types).to include(:server, :client)
end
end
end

# Phantomjs Returns har instead of driver
not_compliant_on browser: :phantomjs do
it 'can fetch available log types' do
expect(driver.manage.logs.available_types).to include(:browser, :driver)
# Phantomjs Returns har instead of driver
not_compliant_on browser: :phantomjs do
it 'can fetch available log types' do
expect(driver.manage.logs.available_types).to include(:browser, :driver)
end
end
end

# All other browsers show empty
compliant_on browser: [:firefox, :ff_legacy] do
it 'can get the browser log' do
driver.navigate.to url_for('simpleTest.html')
# All other browsers show empty
compliant_on browser: [:firefox, :ff_legacy] do
it 'can get the browser log' do
driver.navigate.to url_for('simpleTest.html')

entries = driver.manage.logs.get(:browser)
expect(entries).not_to be_empty
expect(entries.first).to be_kind_of(LogEntry)
entries = driver.manage.logs.get(:browser)
expect(entries).not_to be_empty
expect(entries.first).to be_kind_of(LogEntry)
end
end
end

# Phantomjs Returns har instead of driver
not_compliant_on browser: :phantomjs do
it 'can get the driver log' do
driver.navigate.to url_for('simpleTest.html')
# Phantomjs Returns har instead of driver
not_compliant_on browser: :phantomjs do
it 'can get the driver log' do
driver.navigate.to url_for('simpleTest.html')

entries = driver.manage.logs.get(:driver)
expect(entries).not_to be_empty
expect(entries.first).to be_kind_of(LogEntry)
entries = driver.manage.logs.get(:driver)
expect(entries).not_to be_empty
expect(entries.first).to be_kind_of(LogEntry)
end
end
end
end
end

not_compliant_on browser: :phantomjs do
describe 'cookie management' do
it 'should get all' do
driver.navigate.to url_for('xhtmlTest.html')
driver.manage.add_cookie name: 'foo', value: 'bar'
not_compliant_on browser: :phantomjs do
describe 'cookie management' do
it 'should get all' do
driver.navigate.to url_for('xhtmlTest.html')
driver.manage.add_cookie name: 'foo', value: 'bar'

cookies = driver.manage.all_cookies
cookies = driver.manage.all_cookies

expect(cookies.size).to eq(1)
expect(cookies.first[:name]).to eq('foo')
expect(cookies.first[:value]).to eq('bar')
end
expect(cookies.size).to eq(1)
expect(cookies.first[:name]).to eq('foo')
expect(cookies.first[:value]).to eq('bar')
end

# Edge BUG - https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/5751773/
not_compliant_on browser: :edge do
it 'should delete one' do
driver.navigate.to url_for('xhtmlTest.html')
driver.manage.add_cookie name: 'foo', value: 'bar'
# Edge BUG - https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/5751773/
not_compliant_on browser: :edge do
it 'should delete one' do
driver.navigate.to url_for('xhtmlTest.html')
driver.manage.add_cookie name: 'foo', value: 'bar'

driver.manage.delete_cookie('foo')
driver.manage.delete_cookie('foo')
end
end
end

# Edge BUG - https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/5751773/
not_compliant_on browser: :edge do
it 'should delete all' do
driver.navigate.to url_for('xhtmlTest.html')
# Edge BUG - https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/5751773/
not_compliant_on browser: :edge do
it 'should delete all' do
driver.navigate.to url_for('xhtmlTest.html')

driver.manage.add_cookie name: 'foo', value: 'bar'
driver.manage.delete_all_cookies
expect(driver.manage.all_cookies).to be_empty
driver.manage.add_cookie name: 'foo', value: 'bar'
driver.manage.delete_all_cookies
expect(driver.manage.all_cookies).to be_empty
end
end
end

# Firefox - https://bugzilla.mozilla.org/show_bug.cgi?id=1256007
not_compliant_on browser: [:safari, :firefox] do
it 'should use DateTime for expires' do
driver.navigate.to url_for('xhtmlTest.html')
# Firefox - https://bugzilla.mozilla.org/show_bug.cgi?id=1256007
not_compliant_on browser: :firefox do
it 'should use DateTime for expires' do
driver.navigate.to url_for('xhtmlTest.html')

expected = DateTime.new(2039)
driver.manage.add_cookie name: 'foo',
value: 'bar',
expires: expected
expected = DateTime.new(2039)
driver.manage.add_cookie name: 'foo',
value: 'bar',
expires: expected

actual = driver.manage.cookie_named('foo')[:expires]
expect(actual).to be_kind_of(DateTime)
expect(actual).to eq(expected)
actual = driver.manage.cookie_named('foo')[:expires]
expect(actual).to be_kind_of(DateTime)
expect(actual).to eq(expected)
end
end
end
end
end
end # Options
end
end # WebDriver
end # Selenium
6 changes: 4 additions & 2 deletions rb/spec/integration/selenium/webdriver/safari/driver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ module Selenium
module WebDriver
module Safari
compliant_on browser: :safari do
describe Driver do
it_behaves_like 'driver that can be started concurrently', :safari
not_compliant_on browser: :safari do
describe Driver do
it_behaves_like 'driver that can be started concurrently', :safari
end
end
end
end # Safari
Expand Down
Loading

0 comments on commit 88fdb88

Please sign in to comment.