SimpliTest 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -21
- data/SimpliTest.gemspec +42 -42
- data/bin/SimpliTest +22 -22
- data/lib/SimpliTest.rb +2 -2
- data/lib/SimpliTest/cli/main.rb +333 -333
- data/lib/SimpliTest/config/configuration.rb +107 -107
- data/lib/SimpliTest/config/directory_paths.rb +36 -36
- data/lib/SimpliTest/config/environment.rb +67 -67
- data/lib/SimpliTest/config/local_environment.rb +20 -20
- data/lib/SimpliTest/config/profiles/chrome.rb +18 -18
- data/lib/SimpliTest/config/profiles/firefox.rb +14 -14
- data/lib/SimpliTest/config/profiles/internet_explorer.rb +11 -11
- data/lib/SimpliTest/config/profiles/phantom.rb +9 -9
- data/lib/SimpliTest/config/profiles/phantom_debug.rb +12 -12
- data/lib/SimpliTest/config/profiles/selenium.rb +13 -13
- data/lib/SimpliTest/config/screen_size.rb +25 -25
- data/lib/SimpliTest/config/steps.rb +8 -8
- data/lib/SimpliTest/helpers/data_validation.rb +60 -60
- data/lib/SimpliTest/helpers/file.rb +38 -38
- data/lib/SimpliTest/helpers/project_setup.rb +186 -186
- data/lib/SimpliTest/helpers/step_helpers/custom_chrome_helpers.rb +14 -14
- data/lib/SimpliTest/helpers/step_helpers/custom_date_helpers.rb +64 -64
- data/lib/SimpliTest/helpers/step_helpers/custom_form_helpers.rb +66 -66
- data/lib/SimpliTest/helpers/step_helpers/custom_phantomjs_helpers.rb +49 -49
- data/lib/SimpliTest/helpers/step_helpers/custom_selenium_helpers.rb +41 -41
- data/lib/SimpliTest/helpers/step_helpers/html_selectors_helpers.rb +154 -154
- data/lib/SimpliTest/helpers/step_helpers/navigation_helpers.rb +206 -206
- data/lib/SimpliTest/helpers/step_helpers/tolerance_for_sync_issues.rb +38 -38
- data/lib/SimpliTest/helpers/step_helpers/within_helpers.rb +6 -6
- data/lib/SimpliTest/helpers/windows_ui.rb +51 -51
- data/lib/SimpliTest/steps/debugging_steps.rb +19 -19
- data/lib/SimpliTest/steps/form_steps.rb +348 -352
- data/lib/SimpliTest/steps/form_verification_steps.rb +189 -189
- data/lib/SimpliTest/steps/navigation_steps.rb +58 -47
- data/lib/SimpliTest/steps/scoper.rb +42 -42
- data/lib/SimpliTest/steps/verification_steps.rb +306 -306
- data/lib/SimpliTest/tasks/document.rb +169 -169
- data/lib/SimpliTest/tasks/examples.rb +18 -18
- data/lib/SimpliTest/tasks/testinstall.rb +5 -5
- data/lib/SimpliTest/templates/NewSimpliTestProject/Readme.txt +4 -4
- data/lib/SimpliTest/templates/NewSimpliTestProject/cucumber.yml +26 -26
- data/lib/SimpliTest/templates/NewSimpliTestProject/documentation/step_definitions.html +88 -87
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/specifications/RegressionTests/HelloWorld.feature +3 -3
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/specifications/SmokeTest/HelloWorld.feature +3 -3
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/specifications/accessibilityTests/HelloWorld.feature +3 -3
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/environments.yml +10 -10
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/pages.yml +26 -26
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/selectors.yml +44 -44
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/config/settings.yml +26 -26
- data/lib/SimpliTest/templates/NewSimpliTestProject/features/support/env.rb +33 -33
- data/lib/SimpliTest/templates/NewSimpliTestProject/license.txt +29 -29
- data/lib/SimpliTest/templates/document/css/style.css +28 -28
- data/lib/SimpliTest/templates/document/index.html +60 -60
- data/lib/version.rb +3 -3
- metadata +4 -4
@@ -1,14 +1,14 @@
|
|
1
|
-
#The chrome profile loads Selenium Helpers as well. These methods
|
2
|
-
#override the methods available in Selenium Helpers
|
3
|
-
module CustomChromeHelpers
|
4
|
-
def maximize_window
|
5
|
-
page.driver.browser.manage.window.resize_to(MAX_WIDTH,MAX_HEIGHT)
|
6
|
-
end
|
7
|
-
def keydown_on(element)
|
8
|
-
element.native.send_key(:arrow_down)
|
9
|
-
end
|
10
|
-
|
11
|
-
def capture_screenshot(filename)
|
12
|
-
page.driver.browser.save_screenshot(filename)
|
13
|
-
end
|
14
|
-
end
|
1
|
+
#The chrome profile loads Selenium Helpers as well. These methods
|
2
|
+
#override the methods available in Selenium Helpers
|
3
|
+
module CustomChromeHelpers
|
4
|
+
def maximize_window
|
5
|
+
page.driver.browser.manage.window.resize_to(MAX_WIDTH,MAX_HEIGHT)
|
6
|
+
end
|
7
|
+
def keydown_on(element)
|
8
|
+
element.native.send_key(:arrow_down)
|
9
|
+
end
|
10
|
+
|
11
|
+
def capture_screenshot(filename)
|
12
|
+
page.driver.browser.save_screenshot(filename)
|
13
|
+
end
|
14
|
+
end
|
@@ -1,64 +1,64 @@
|
|
1
|
-
module CustomDateHelpers
|
2
|
-
def calculated_date_from(date_rule)
|
3
|
-
# Takes strings like "Today's Date", "4 days ago", "5 days since" etc. and
|
4
|
-
# returns a calculated date in the default_date_format
|
5
|
-
potential_date_formats = /[0-9]+\/[0-9]+\/[0-9]+/x
|
6
|
-
first_and_last_regex = /the (nearest|first|last) (.*)/
|
7
|
-
date = case date_rule
|
8
|
-
when potential_date_formats
|
9
|
-
date_rule
|
10
|
-
when /Today's Date/i
|
11
|
-
Date.today
|
12
|
-
when /(\d+) days (ago|since)/i
|
13
|
-
number_of_days = $1.to_i rescue nil
|
14
|
-
time_travel_method = $2.downcase.to_sym
|
15
|
-
raise "Invalid number of days. Please enter a valid number" if number_of_days.nil?
|
16
|
-
number_of_days.send(:days).send(time_travel_method)
|
17
|
-
when first_and_last_regex
|
18
|
-
first_and_last_date_rule(rule)
|
19
|
-
end
|
20
|
-
date.respond_to?(:strftime) ? date.strftime(default_date_format) : date
|
21
|
-
end
|
22
|
-
|
23
|
-
def first_and_last_date_rule(phrase)
|
24
|
-
# Takes a phrase like "the first day of the month" or "last day of the
|
25
|
-
# previous month" and returns a calculated date in the default_date_format
|
26
|
-
case phrase
|
27
|
-
when /the (first|last) day of the month/i
|
28
|
-
Date.today.send(beginning_or_end($1))
|
29
|
-
when /the (first|last) day of next month/i
|
30
|
-
1.month.since.send(beginning_or_end($1))
|
31
|
-
when /the (first|last) day of previous month/i
|
32
|
-
1.month.ago.send(beginning_or_end($1))
|
33
|
-
when /the (first|last) day of (.*)/i
|
34
|
-
date_from_phrase($1, $2)
|
35
|
-
when /the nearest (first|last) day of month/i
|
36
|
-
rule = Date.today.day >= 15 ? "the #{$1} day of next month" : "the #{$1} day of the month"
|
37
|
-
calculated_date_from(rule)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def beginning_or_end(first_or_last)
|
42
|
-
first_or_last == 'first' ? :beginning_of_month : :end_of_month
|
43
|
-
end
|
44
|
-
|
45
|
-
def default_date_format
|
46
|
-
format_for_strftime SimpliTest.config_settings['DEFAULT_DATE_FORMAT']
|
47
|
-
end
|
48
|
-
|
49
|
-
def date_from_phrase(first_or_last, month)
|
50
|
-
month_name = month.downcase.camelize
|
51
|
-
month = Date::MONTHNAMES.index(month_name)
|
52
|
-
if month.nil?
|
53
|
-
raise "Oops you provided an invalid month name. Please use a valid month name from January to December"
|
54
|
-
end
|
55
|
-
date = Date.parse("#{month}/1") #mm/dd in current year
|
56
|
-
date = date.send(:end_of_month) if first_or_last == 'last'
|
57
|
-
end
|
58
|
-
|
59
|
-
def format_for_strftime(string)
|
60
|
-
string.gsub('mm', '%m').gsub('dd', '%d').gsub('yyyy', '%Y').gsub('yy', '%y')
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
World(CustomDateHelpers)
|
1
|
+
module CustomDateHelpers
|
2
|
+
def calculated_date_from(date_rule)
|
3
|
+
# Takes strings like "Today's Date", "4 days ago", "5 days since" etc. and
|
4
|
+
# returns a calculated date in the default_date_format
|
5
|
+
potential_date_formats = /[0-9]+\/[0-9]+\/[0-9]+/x
|
6
|
+
first_and_last_regex = /the (nearest|first|last) (.*)/
|
7
|
+
date = case date_rule
|
8
|
+
when potential_date_formats
|
9
|
+
date_rule
|
10
|
+
when /Today's Date/i
|
11
|
+
Date.today
|
12
|
+
when /(\d+) days (ago|since)/i
|
13
|
+
number_of_days = $1.to_i rescue nil
|
14
|
+
time_travel_method = $2.downcase.to_sym
|
15
|
+
raise "Invalid number of days. Please enter a valid number" if number_of_days.nil?
|
16
|
+
number_of_days.send(:days).send(time_travel_method)
|
17
|
+
when first_and_last_regex
|
18
|
+
first_and_last_date_rule(rule)
|
19
|
+
end
|
20
|
+
date.respond_to?(:strftime) ? date.strftime(default_date_format) : date
|
21
|
+
end
|
22
|
+
|
23
|
+
def first_and_last_date_rule(phrase)
|
24
|
+
# Takes a phrase like "the first day of the month" or "last day of the
|
25
|
+
# previous month" and returns a calculated date in the default_date_format
|
26
|
+
case phrase
|
27
|
+
when /the (first|last) day of the month/i
|
28
|
+
Date.today.send(beginning_or_end($1))
|
29
|
+
when /the (first|last) day of next month/i
|
30
|
+
1.month.since.send(beginning_or_end($1))
|
31
|
+
when /the (first|last) day of previous month/i
|
32
|
+
1.month.ago.send(beginning_or_end($1))
|
33
|
+
when /the (first|last) day of (.*)/i
|
34
|
+
date_from_phrase($1, $2)
|
35
|
+
when /the nearest (first|last) day of month/i
|
36
|
+
rule = Date.today.day >= 15 ? "the #{$1} day of next month" : "the #{$1} day of the month"
|
37
|
+
calculated_date_from(rule)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def beginning_or_end(first_or_last)
|
42
|
+
first_or_last == 'first' ? :beginning_of_month : :end_of_month
|
43
|
+
end
|
44
|
+
|
45
|
+
def default_date_format
|
46
|
+
format_for_strftime SimpliTest.config_settings['DEFAULT_DATE_FORMAT']
|
47
|
+
end
|
48
|
+
|
49
|
+
def date_from_phrase(first_or_last, month)
|
50
|
+
month_name = month.downcase.camelize
|
51
|
+
month = Date::MONTHNAMES.index(month_name)
|
52
|
+
if month.nil?
|
53
|
+
raise "Oops you provided an invalid month name. Please use a valid month name from January to December"
|
54
|
+
end
|
55
|
+
date = Date.parse("#{month}/1") #mm/dd in current year
|
56
|
+
date = date.send(:end_of_month) if first_or_last == 'last'
|
57
|
+
end
|
58
|
+
|
59
|
+
def format_for_strftime(string)
|
60
|
+
string.gsub('mm', '%m').gsub('dd', '%d').gsub('yyyy', '%Y').gsub('yy', '%y')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
World(CustomDateHelpers)
|
@@ -1,66 +1,66 @@
|
|
1
|
-
module CustomFormHelpers
|
2
|
-
|
3
|
-
def numerize(number_name)
|
4
|
-
case number_name
|
5
|
-
when 'first'; 0
|
6
|
-
when 'last'; -1
|
7
|
-
else number_name.match(/[0-9]/)[1].to_i + 1 rescue 0 #take the first one if you cant figure it out
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def blur(selector_and_xpath)
|
12
|
-
css_selector, xpath = selector_and_xpath
|
13
|
-
selector = xpath ? xpath : css_selector
|
14
|
-
if xpath
|
15
|
-
return
|
16
|
-
else
|
17
|
-
#TODO: Hate how this done...need to come back to this
|
18
|
-
execute_script_for_driver(SimpliTest.config_driver, %Q{ $('#{selector}').blur(); })
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def fill_in_masked_field(css_selector, value)
|
23
|
-
STDOUT.puts "Entering #{value} in Masked Field #{css_selector} now" #TODO: Delete this debugging statement
|
24
|
-
execute_script_for_driver(SimpliTest.config_driver, %Q{ $("#{css_selector}").val("#{value}"); })
|
25
|
-
STDOUT.puts "Blurring the field now" #TODO: Delete this debugging statement
|
26
|
-
execute_script_for_driver(SimpliTest.config_driver, %Q{ $("#{css_selector}").blur(); })
|
27
|
-
#page.driver.debug
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
def press_key(key)
|
32
|
-
keycode = keycode_for[key.downcase.gsub(' ','_')]
|
33
|
-
keypress_script = "var e = $.Event('keydown', { keyCode: #{keycode} }); $('body').trigger(e);"
|
34
|
-
execute_js(keypress_script)
|
35
|
-
end
|
36
|
-
|
37
|
-
def tab_on(element)
|
38
|
-
element.native.send_key(:tab)
|
39
|
-
end
|
40
|
-
|
41
|
-
def keypress_on(elem, key, charCode = 0)
|
42
|
-
keyCode = keycode_for[key]
|
43
|
-
elem.base.invoke('keypress', false, false, false, false, keyCode, charCode);
|
44
|
-
end
|
45
|
-
|
46
|
-
def keycode_for
|
47
|
-
{
|
48
|
-
:tab => 9,
|
49
|
-
:enter => 13,
|
50
|
-
:up_arrow => 38,
|
51
|
-
:down_arrow => 40,
|
52
|
-
:left_arrow => 37,
|
53
|
-
:right_arrow => 39,
|
54
|
-
:escape => 27,
|
55
|
-
:spacebar => 32,
|
56
|
-
:ctrl => 17,
|
57
|
-
:alt => 18,
|
58
|
-
:shift => 16,
|
59
|
-
:caps_lock => 20,
|
60
|
-
:backspace => 8,
|
61
|
-
:delete => 46
|
62
|
-
}
|
63
|
-
end
|
64
|
-
end
|
65
|
-
World(CustomFormHelpers)
|
66
|
-
|
1
|
+
module CustomFormHelpers
|
2
|
+
|
3
|
+
def numerize(number_name)
|
4
|
+
case number_name
|
5
|
+
when 'first'; 0
|
6
|
+
when 'last'; -1
|
7
|
+
else number_name.match(/[0-9]/)[1].to_i + 1 rescue 0 #take the first one if you cant figure it out
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def blur(selector_and_xpath)
|
12
|
+
css_selector, xpath = selector_and_xpath
|
13
|
+
selector = xpath ? xpath : css_selector
|
14
|
+
if xpath
|
15
|
+
return
|
16
|
+
else
|
17
|
+
#TODO: Hate how this done...need to come back to this
|
18
|
+
execute_script_for_driver(SimpliTest.config_driver, %Q{ $('#{selector}').blur(); })
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def fill_in_masked_field(css_selector, value)
|
23
|
+
STDOUT.puts "Entering #{value} in Masked Field #{css_selector} now" #TODO: Delete this debugging statement
|
24
|
+
execute_script_for_driver(SimpliTest.config_driver, %Q{ $("#{css_selector}").val("#{value}"); })
|
25
|
+
STDOUT.puts "Blurring the field now" #TODO: Delete this debugging statement
|
26
|
+
execute_script_for_driver(SimpliTest.config_driver, %Q{ $("#{css_selector}").blur(); })
|
27
|
+
#page.driver.debug
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
def press_key(key)
|
32
|
+
keycode = keycode_for[key.downcase.gsub(' ','_')]
|
33
|
+
keypress_script = "var e = $.Event('keydown', { keyCode: #{keycode} }); $('body').trigger(e);"
|
34
|
+
execute_js(keypress_script)
|
35
|
+
end
|
36
|
+
|
37
|
+
def tab_on(element)
|
38
|
+
element.native.send_key(:tab)
|
39
|
+
end
|
40
|
+
|
41
|
+
def keypress_on(elem, key, charCode = 0)
|
42
|
+
keyCode = keycode_for[key]
|
43
|
+
elem.base.invoke('keypress', false, false, false, false, keyCode, charCode);
|
44
|
+
end
|
45
|
+
|
46
|
+
def keycode_for
|
47
|
+
{
|
48
|
+
:tab => 9,
|
49
|
+
:enter => 13,
|
50
|
+
:up_arrow => 38,
|
51
|
+
:down_arrow => 40,
|
52
|
+
:left_arrow => 37,
|
53
|
+
:right_arrow => 39,
|
54
|
+
:escape => 27,
|
55
|
+
:spacebar => 32,
|
56
|
+
:ctrl => 17,
|
57
|
+
:alt => 18,
|
58
|
+
:shift => 16,
|
59
|
+
:caps_lock => 20,
|
60
|
+
:backspace => 8,
|
61
|
+
:delete => 46
|
62
|
+
}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
World(CustomFormHelpers)
|
66
|
+
|
@@ -1,49 +1,49 @@
|
|
1
|
-
module CustomPhantomjsHelpers
|
2
|
-
def maximize_window
|
3
|
-
page.driver.resize_window(MAX_WIDTH,MAX_HEIGHT)
|
4
|
-
end
|
5
|
-
|
6
|
-
def tab_on(element)
|
7
|
-
element.native.send_key(:Tab)
|
8
|
-
end
|
9
|
-
|
10
|
-
def accept_confirmation
|
11
|
-
#TODO: accept confirmation
|
12
|
-
raise "NotImplementedError"
|
13
|
-
end
|
14
|
-
|
15
|
-
def execute_js(script)
|
16
|
-
page.execute_script(script)
|
17
|
-
end
|
18
|
-
|
19
|
-
def get_text_from(element)
|
20
|
-
element.native.all_text
|
21
|
-
end
|
22
|
-
|
23
|
-
def click_element(element)
|
24
|
-
begin
|
25
|
-
element.click
|
26
|
-
rescue Capybara::Poltergeist::MouseEventFailed
|
27
|
-
element.trigger('click')
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def key_in(character, element)
|
32
|
-
element.native.send_key(character)
|
33
|
-
end
|
34
|
-
|
35
|
-
def keydown_on(element)
|
36
|
-
key_in('Down', element)
|
37
|
-
end
|
38
|
-
|
39
|
-
def capture_screenshot(filename)
|
40
|
-
page.save_screenshot(filename)
|
41
|
-
end
|
42
|
-
|
43
|
-
def change_window(first_or_last)
|
44
|
-
raise "Invalid window name #{first_or_last}. You can only use 'first' or 'last'" unless first_or_last =~ /first|last/
|
45
|
-
window_handle = page.driver.browser.window_handles.send(first_or_last.to_sym)
|
46
|
-
page.driver.browser.switch_to_window(window_handle)
|
47
|
-
wait_for(page.driver.browser.window_handles.size, 1)
|
48
|
-
end
|
49
|
-
end
|
1
|
+
module CustomPhantomjsHelpers
|
2
|
+
def maximize_window
|
3
|
+
page.driver.resize_window(MAX_WIDTH,MAX_HEIGHT)
|
4
|
+
end
|
5
|
+
|
6
|
+
def tab_on(element)
|
7
|
+
element.native.send_key(:Tab)
|
8
|
+
end
|
9
|
+
|
10
|
+
def accept_confirmation
|
11
|
+
#TODO: accept confirmation
|
12
|
+
raise "NotImplementedError"
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute_js(script)
|
16
|
+
page.execute_script(script)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_text_from(element)
|
20
|
+
element.native.all_text
|
21
|
+
end
|
22
|
+
|
23
|
+
def click_element(element)
|
24
|
+
begin
|
25
|
+
element.click
|
26
|
+
rescue Capybara::Poltergeist::MouseEventFailed
|
27
|
+
element.trigger('click')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def key_in(character, element)
|
32
|
+
element.native.send_key(character)
|
33
|
+
end
|
34
|
+
|
35
|
+
def keydown_on(element)
|
36
|
+
key_in('Down', element)
|
37
|
+
end
|
38
|
+
|
39
|
+
def capture_screenshot(filename)
|
40
|
+
page.save_screenshot(filename)
|
41
|
+
end
|
42
|
+
|
43
|
+
def change_window(first_or_last)
|
44
|
+
raise "Invalid window name #{first_or_last}. You can only use 'first' or 'last'" unless first_or_last =~ /first|last/
|
45
|
+
window_handle = page.driver.browser.window_handles.send(first_or_last.to_sym)
|
46
|
+
page.driver.browser.switch_to_window(window_handle)
|
47
|
+
wait_for(page.driver.browser.window_handles.size, 1)
|
48
|
+
end
|
49
|
+
end
|
@@ -1,41 +1,41 @@
|
|
1
|
-
module CustomSeleniumHelpers
|
2
|
-
def maximize_window
|
3
|
-
page.driver.browser.manage.window.resize_to(MAX_WIDTH, MAX_HEIGHT)
|
4
|
-
end
|
5
|
-
|
6
|
-
def capture_screenshot(filename)
|
7
|
-
page.driver.browser.save_screenshot(filename)
|
8
|
-
end
|
9
|
-
|
10
|
-
def accept_confirmation
|
11
|
-
page.driver.browser.switch_to.alert.accept
|
12
|
-
end
|
13
|
-
|
14
|
-
def execute_js(script)
|
15
|
-
page.driver.browser.execute_script(script)
|
16
|
-
end
|
17
|
-
|
18
|
-
def get_text_from(element)
|
19
|
-
element.text
|
20
|
-
end
|
21
|
-
|
22
|
-
def click_element(element)
|
23
|
-
element.click
|
24
|
-
end
|
25
|
-
|
26
|
-
def key_in(character, element)
|
27
|
-
element.native.send_key(character)
|
28
|
-
end
|
29
|
-
|
30
|
-
def keydown_on(element)
|
31
|
-
key_in(:arrow_down, element)
|
32
|
-
end
|
33
|
-
|
34
|
-
def change_window(first_or_last)
|
35
|
-
raise "Invalid window name #{first_or_last}. You can only use 'first' or 'last'" unless first_or_last =~ /first|last/
|
36
|
-
window_handle = page.driver.browser.window_handles.send(first_or_last.to_sym)
|
37
|
-
page.driver.browser.switch_to.window(window_handle)
|
38
|
-
wait_for(page.driver.browser.window_handles.size, 1)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
1
|
+
module CustomSeleniumHelpers
|
2
|
+
def maximize_window
|
3
|
+
page.driver.browser.manage.window.resize_to(MAX_WIDTH, MAX_HEIGHT)
|
4
|
+
end
|
5
|
+
|
6
|
+
def capture_screenshot(filename)
|
7
|
+
page.driver.browser.save_screenshot(filename)
|
8
|
+
end
|
9
|
+
|
10
|
+
def accept_confirmation
|
11
|
+
page.driver.browser.switch_to.alert.accept
|
12
|
+
end
|
13
|
+
|
14
|
+
def execute_js(script)
|
15
|
+
page.driver.browser.execute_script(script)
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_text_from(element)
|
19
|
+
element.text
|
20
|
+
end
|
21
|
+
|
22
|
+
def click_element(element)
|
23
|
+
element.click
|
24
|
+
end
|
25
|
+
|
26
|
+
def key_in(character, element)
|
27
|
+
element.native.send_key(character)
|
28
|
+
end
|
29
|
+
|
30
|
+
def keydown_on(element)
|
31
|
+
key_in(:arrow_down, element)
|
32
|
+
end
|
33
|
+
|
34
|
+
def change_window(first_or_last)
|
35
|
+
raise "Invalid window name #{first_or_last}. You can only use 'first' or 'last'" unless first_or_last =~ /first|last/
|
36
|
+
window_handle = page.driver.browser.window_handles.send(first_or_last.to_sym)
|
37
|
+
page.driver.browser.switch_to.window(window_handle)
|
38
|
+
wait_for(page.driver.browser.window_handles.size, 1)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|