Moved Cucumber hooks to hooks.rb file
Bug: 49812 Change-Id: Ib927b824a8854d1c4257a17db582595a22d70470
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
Given(/^that my browser's accept language is (.+)$/) do |language|
|
Given(/^that my browser's accept language is (.+)$/) do |language|
|
||||||
@browser = browser(environment, test_name(@scenario), ENV['SAUCE_ONDEMAND_USERNAME'], ENV['SAUCE_ONDEMAND_ACCESS_KEY'], language)
|
@browser = browser(environment, test_name(@scenario), language)
|
||||||
$session_id = @browser.driver.instance_variable_get(:@bridge).session_id
|
$session_id = @browser.driver.instance_variable_get(:@bridge).session_id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -56,11 +56,6 @@ def get_interface_font()
|
|||||||
get_font('body')
|
get_font('body')
|
||||||
end
|
end
|
||||||
|
|
||||||
After('@reset-preferences-after') do |scenario|
|
|
||||||
visit(ResetPreferencesPage)
|
|
||||||
on(ResetPreferencesPage).submit_element.click
|
|
||||||
end
|
|
||||||
|
|
||||||
def uls_position()
|
def uls_position()
|
||||||
if !defined?($uls_position)
|
if !defined?($uls_position)
|
||||||
visit(PanelPage)
|
visit(PanelPage)
|
||||||
@@ -69,15 +64,3 @@ def uls_position()
|
|||||||
$uls_position
|
$uls_position
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Before('@uls-in-sidebar-only') do |scenario|
|
|
||||||
if uls_position() != 'interlanguage'
|
|
||||||
scenario.skip_invoke!
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
Before('@uls-in-personal-only') do |scenario|
|
|
||||||
if uls_position() != 'personal'
|
|
||||||
scenario.skip_invoke!
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|||||||
@@ -80,7 +80,6 @@ def sauce_browser(test_name, language)
|
|||||||
|
|
||||||
browser
|
browser
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_name(scenario)
|
def test_name(scenario)
|
||||||
if scenario.respond_to? :feature
|
if scenario.respond_to? :feature
|
||||||
"#{scenario.feature.name}: #{scenario.name}"
|
"#{scenario.feature.name}: #{scenario.name}"
|
||||||
@@ -88,33 +87,3 @@ def test_name(scenario)
|
|||||||
"#{scenario.scenario_outline.feature.name}: #{scenario.scenario_outline.name}: #{scenario.name}"
|
"#{scenario.scenario_outline.feature.name}: #{scenario.scenario_outline.name}: #{scenario.name}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
config = YAML.load_file('config/config.yml')
|
|
||||||
mediawiki_username = config['mediawiki_username']
|
|
||||||
|
|
||||||
Before('@login') do
|
|
||||||
puts "MEDIAWIKI_PASSWORD environment variable is not defined! Please export a value for that variable before proceeding." unless ENV['MEDIAWIKI_PASSWORD']
|
|
||||||
end
|
|
||||||
|
|
||||||
Before('@language') do |scenario|
|
|
||||||
@language = true
|
|
||||||
@scenario = scenario
|
|
||||||
end
|
|
||||||
|
|
||||||
Before do |scenario|
|
|
||||||
@config = config
|
|
||||||
@random_string = Random.new.rand.to_s
|
|
||||||
@mediawiki_username = mediawiki_username
|
|
||||||
unless @language
|
|
||||||
@browser = browser(environment, test_name(scenario), 'default')
|
|
||||||
$session_id = @browser.driver.instance_variable_get(:@bridge).session_id
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
After do |scenario|
|
|
||||||
if environment == :saucelabs
|
|
||||||
sauce_api(%Q{{"passed": #{scenario.passed?}}})
|
|
||||||
sauce_api(%Q{{"public": true}})
|
|
||||||
end
|
|
||||||
@browser.close unless ENV['KEEP_BROWSER_OPEN'] == 'true'
|
|
||||||
end
|
|
||||||
|
|||||||
46
tests/browser/features/support/hooks.rb
Normal file
46
tests/browser/features/support/hooks.rb
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
config = YAML.load_file('config/config.yml')
|
||||||
|
mediawiki_username = config['mediawiki_username']
|
||||||
|
|
||||||
|
Before do |scenario|
|
||||||
|
@config = config
|
||||||
|
@random_string = Random.new.rand.to_s
|
||||||
|
@mediawiki_username = mediawiki_username
|
||||||
|
unless @language
|
||||||
|
@browser = browser(environment, test_name(scenario), 'default')
|
||||||
|
$session_id = @browser.driver.instance_variable_get(:@bridge).session_id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Before('@language') do |scenario|
|
||||||
|
@language = true
|
||||||
|
@scenario = scenario
|
||||||
|
end
|
||||||
|
|
||||||
|
Before('@login') do
|
||||||
|
puts "MEDIAWIKI_PASSWORD environment variable is not defined! Please export a value for that variable before proceeding." unless ENV['MEDIAWIKI_PASSWORD']
|
||||||
|
end
|
||||||
|
|
||||||
|
Before('@uls-in-personal-only') do |scenario|
|
||||||
|
if uls_position() != 'personal'
|
||||||
|
scenario.skip_invoke!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Before('@uls-in-sidebar-only') do |scenario|
|
||||||
|
if uls_position() != 'interlanguage'
|
||||||
|
scenario.skip_invoke!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
After do |scenario|
|
||||||
|
if environment == :saucelabs
|
||||||
|
sauce_api(%Q{{"passed": #{scenario.passed?}}})
|
||||||
|
sauce_api(%Q{{"public": true}})
|
||||||
|
end
|
||||||
|
@browser.close unless ENV['KEEP_BROWSER_OPEN'] == 'true'
|
||||||
|
end
|
||||||
|
|
||||||
|
After('@reset-preferences-after') do |scenario|
|
||||||
|
visit(ResetPreferencesPage)
|
||||||
|
on(ResetPreferencesPage).submit_element.click
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user