Merge "[BrowserTest] Browser can now zoom out whenever required"

This commit is contained in:
jenkins-bot 2014-08-07 08:56:49 +00:00 committed by Gerrit Code Review
commit 623b59e4a5
2 changed files with 12 additions and 6 deletions

View file

@ -123,7 +123,7 @@ Then(/^I should see pull-down menu containing Page Settings$/) do
end
Then(/^I take screenshot of Visual Editor insert menu$/) do
capture_screenshot("#{@scenario.name}-#{ENV['LANGUAGE_SCREENSHOT_CODE']}.png", [@current_page.tools_menu_element, @current_page.page_option_menu_element])
capture_screenshot("#{@scenario.name}-#{ENV['LANGUAGE_SCREENSHOT_CODE']}.png", [@current_page.tools_menu_element, @current_page.page_option_menu_element], nil, 0)
end
Then(/^I should see Insert pull-down menu$/) do
@ -152,18 +152,18 @@ end
Then(/^I should see Special character Insertion window$/) do
on(VisualEditorPage).iframe_element.when_present.should be_visible
capture_screenshot("#{@scenario.name}-#{ENV['LANGUAGE_SCREENSHOT_CODE']}.png", [@current_page.iframe_element])
capture_screenshot("#{@scenario.name}-#{ENV['LANGUAGE_SCREENSHOT_CODE']}.png", [@current_page.iframe_element], nil, -2)
end
Then(/^I should see save changes dialog box$/) do
on(VisualEditorPage).iframe_element.when_present.should be_visible
capture_screenshot("#{@scenario.name}-#{ENV['LANGUAGE_SCREENSHOT_CODE']}.png", [@current_page.iframe_element])
capture_screenshot("#{@scenario.name}-#{ENV['LANGUAGE_SCREENSHOT_CODE']}.png", [@current_page.iframe_element], nil, -2)
end
Then(/^I should see Page settings dialog box$/) do
on(VisualEditorPage).iframe_element.when_present.should be_visible
capture_screenshot("#{@scenario.name}-#{ENV['LANGUAGE_SCREENSHOT_CODE']}.png", [@current_page.iframe_element])
capture_screenshot("#{@scenario.name}-#{ENV['LANGUAGE_SCREENSHOT_CODE']}.png", [@current_page.iframe_element], nil, 0)
capture_screenshot("VisualEditor_Page_Settings_Redirects-#{ENV['LANGUAGE_SCREENSHOT_CODE']}.png", [@current_page.page_settings_heading_element, @current_page.prevent_redirect_element], @current_page.iframe_element, 0)

View file

@ -2,9 +2,15 @@ def capture_screenshot(file_name, page_elements, offset_element=nil, browser_zoo
screenshot_directory = ENV["LANGUAGE_SCREENSHOT_PATH"] || "screenshots"
FileUtils.mkdir_p screenshot_directory
screenshot_path = "#{screenshot_directory}/#{file_name}"
browser_zoom.times do
@browser.send_keys [:control, :add]
browser_zoom.abs.times do
if browser_zoom > 0
@browser.send_keys [:control, :add]
else
@browser.send_keys [:control, :subtract]
end
end
@browser.screenshot.save screenshot_path
crop_image screenshot_path, page_elements, offset_element
end