selenium-cucumber 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/generate.rb +20 -20
- data/bin/helper.rb +50 -50
- data/bin/selenium-cucumber +26 -26
- data/doc/canned_steps.md +463 -361
- data/doc/installation.md +16 -13
- data/doc/selenium-cucumber-API.md +81 -78
- data/doc/selenium-cucumber-help.md +18 -18
- data/features-skeleton/my_first.feature +5 -5
- data/features-skeleton/step_definitions/custom_steps.rb +4 -4
- data/features-skeleton/support/env.rb +38 -38
- data/features-skeleton/support/hooks.rb +33 -33
- data/lib/selenium-cucumber.rb +2 -2
- data/lib/selenium-cucumber/assertion_steps.rb +11 -4
- data/lib/selenium-cucumber/input_steps.rb +20 -24
- data/lib/selenium-cucumber/methods/assertion_methods.rb +19 -0
- data/lib/selenium-cucumber/methods/input_methods.rb +11 -4
- data/lib/selenium-cucumber/methods/navigate_methods.rb +29 -8
- data/lib/selenium-cucumber/navigation_steps.rb +11 -1
- data/lib/selenium-cucumber/version.rb +1 -1
- metadata +2 -3
- data/doc/selenium-cucumber-help.txt +0 -16
@@ -146,4 +146,23 @@ def check_alert_text text
|
|
146
146
|
if get_alert_text!=text
|
147
147
|
raise TestCaseFailed , "Text on alert pop up not matched"
|
148
148
|
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def is_option_from_dropdown_selected(access_type, by, option, access_name, should_be_selected=true)
|
152
|
+
dropdown = WAIT.until {$driver.find_element(:"#{access_type}" => "#{access_name}")}
|
153
|
+
select_list = Selenium::WebDriver::Support::Select.new(dropdown)
|
154
|
+
|
155
|
+
puts select_list.first_selected_option.attribute("value")
|
156
|
+
|
157
|
+
if by=="text"
|
158
|
+
actual_value = select_list.first_selected_option.text
|
159
|
+
else
|
160
|
+
actual_value = select_list.first_selected_option.attribute("value")
|
161
|
+
end
|
162
|
+
|
163
|
+
if !actual_value==option && should_be_selected
|
164
|
+
raise "Option Not Selected From Dropwdown"
|
165
|
+
elsif actual_value==option && !should_be_selected
|
166
|
+
raise "Option Selected From Dropwdown"
|
167
|
+
end
|
149
168
|
end
|
@@ -12,14 +12,21 @@ end
|
|
12
12
|
|
13
13
|
# method to select option from dropdwon list
|
14
14
|
def select_option_from_dropdown(access_type, by, option, access_name)
|
15
|
-
|
15
|
+
dropdown = WAIT.until {$driver.find_element(:"#{access_type}" => "#{access_name}")}
|
16
16
|
select_list = Selenium::WebDriver::Support::Select.new(dropdown)
|
17
17
|
select_list.select_by(:"#{by}", "#{option}")
|
18
18
|
end
|
19
19
|
|
20
|
+
# method to select all option from dropdwon list
|
21
|
+
def select_all_option_from_multiselect_dropdown(access_type, access_name)
|
22
|
+
dropdown = WAIT.until {$driver.find_element(:"#{access_type}" => "#{access_name}")}
|
23
|
+
select_list = Selenium::WebDriver::Support::Select.new(dropdown)
|
24
|
+
select_list.select_all()
|
25
|
+
end
|
26
|
+
|
20
27
|
# method to unselect all option from dropdwon list
|
21
|
-
def
|
22
|
-
|
28
|
+
def unselect_all_option_from_multiselect_dropdown(access_type, access_name)
|
29
|
+
dropdown = WAIT.until {$driver.find_element(:"#{access_type}" => "#{access_name}")}
|
23
30
|
select_list = Selenium::WebDriver::Support::Select.new(dropdown)
|
24
31
|
select_list.deselect_all()
|
25
32
|
end
|
@@ -63,7 +70,7 @@ def select_option_from_radio_button_group(access_type, by, option, access_name)
|
|
63
70
|
|
64
71
|
getter = ->(rb, by) { by == 'value' ? rb.attribute('value') : rb.text }
|
65
72
|
|
66
|
-
ele = radio_button_group.find { |rb|
|
73
|
+
ele = radio_button_group.find { |rb| getter.call(rb, by)==option }
|
67
74
|
|
68
75
|
if !ele.selected?
|
69
76
|
ele.click
|
@@ -1,27 +1,25 @@
|
|
1
1
|
require_relative 'required_files'
|
2
2
|
|
3
|
-
|
3
|
+
#method to open link
|
4
4
|
def navigate_to(link)
|
5
5
|
$driver.get link
|
6
6
|
end
|
7
7
|
|
8
|
+
#method to navigate back & forword
|
8
9
|
def navigate(direction)
|
9
10
|
if direction=="back"
|
10
11
|
$driver.navigate.back
|
11
12
|
else
|
12
|
-
$driver.navigate.
|
13
|
+
$driver.navigate.forward
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
17
|
+
#method to quite webdriver instance
|
16
18
|
def close_driver
|
17
19
|
$driver.close
|
18
20
|
end
|
19
21
|
|
20
|
-
|
21
|
-
ele_scroll = WAIT.until {$driver.find_element(:"#{access_type}" => "#{access_name}")}
|
22
|
-
ele_scroll.location_once_scrolled_into_view
|
23
|
-
end
|
24
|
-
|
22
|
+
#Method to zoom in/out page
|
25
23
|
def zoom_in_out(in_out)
|
26
24
|
if get_os=="windows"
|
27
25
|
key="control"
|
@@ -32,7 +30,7 @@ def zoom_in_out(in_out)
|
|
32
30
|
$driver.action.key_down(:"#{key}").send_keys(:"#{in_out}").key_up(:"#{key}").perform
|
33
31
|
end
|
34
32
|
|
35
|
-
|
33
|
+
#Method to zoom in/out web page until web element displyas
|
36
34
|
def zoom_in_out_till_element_display(access_type, in_out, access_name)
|
37
35
|
|
38
36
|
if get_os=="windows"
|
@@ -52,16 +50,39 @@ def zoom_in_out_till_element_display(access_type, in_out, access_name)
|
|
52
50
|
|
53
51
|
end
|
54
52
|
|
53
|
+
#Method to resize browser
|
55
54
|
def resize_browser(width,heigth)
|
56
55
|
$driver.manage.window.resize_to(width,heigth)
|
57
56
|
end
|
58
57
|
|
58
|
+
#Method to maximize browser
|
59
|
+
def maximize_browser
|
60
|
+
$driver.manage().window().maximize()
|
61
|
+
end
|
62
|
+
|
59
63
|
#Method to hover on element
|
60
64
|
def hover_over_element(access_type,access_name)
|
61
65
|
element = WAIT.until {$driver.find_element(:"#{access_type}" => "#{access_name}")}
|
62
66
|
$driver.action.move_to(element).perform
|
63
67
|
end
|
64
68
|
|
69
|
+
#Method to scroll page to perticular element
|
70
|
+
def scroll_to_element(access_type,access_name)
|
71
|
+
ele_scroll = WAIT.until {$driver.find_element(:"#{access_type}" => "#{access_name}")}
|
72
|
+
ele_scroll.location_once_scrolled_into_view
|
73
|
+
end
|
74
|
+
|
75
|
+
#method to scroll page to top or end
|
76
|
+
def scroll_page(to)
|
77
|
+
if to=="end"
|
78
|
+
$driver.execute_script("window.scrollTo(0,Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight));")
|
79
|
+
elsif to=="top"
|
80
|
+
$driver.execute_script("window.scrollTo(Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight),0);")
|
81
|
+
else
|
82
|
+
raise "Exception : Invalid Direction (only scroll \"top\" or \"end\")"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
65
86
|
def get_os
|
66
87
|
case CONFIG['host_os']
|
67
88
|
when /mingw32|windows/i
|
@@ -17,10 +17,15 @@ Then(/^I close browser$/) do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
#step to resize browser
|
20
|
-
Then(/^I resize browser window size to width (\d+) and
|
20
|
+
Then(/^I resize browser window size to width (\d+) and height (\d+)$/) do |width, heigth|
|
21
21
|
resize_browser(width, heigth)
|
22
22
|
end
|
23
23
|
|
24
|
+
#step to maximize browser
|
25
|
+
Then(/^I maximize browser window$/) do
|
26
|
+
maximize_browser
|
27
|
+
end
|
28
|
+
|
24
29
|
#steps to refresh page
|
25
30
|
Then(/^I refresh page$/) do
|
26
31
|
$driver.navigate.refresh
|
@@ -32,6 +37,11 @@ Then(/^I scroll to element having (.+) "(.*?)"$/) do |type, access_name|
|
|
32
37
|
scroll_to_element(type, access_name)
|
33
38
|
end
|
34
39
|
|
40
|
+
#steps to scroll web page to top or end
|
41
|
+
Then(/^I scroll to (top|end) of page$/) do |to|
|
42
|
+
scroll_page(to)
|
43
|
+
end
|
44
|
+
|
35
45
|
#Step to hover over a element # Not work on windows firefox
|
36
46
|
When(/^I hover over element having (.+) "(.*?)"$/) do |type, access_name|
|
37
47
|
validate_locator type
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selenium-cucumber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-07-
|
12
|
+
date: 2014-07-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cucumber
|
@@ -82,7 +82,6 @@ files:
|
|
82
82
|
- doc/installation.md
|
83
83
|
- doc/selenium-cucumber-API.md
|
84
84
|
- doc/selenium-cucumber-help.md
|
85
|
-
- doc/selenium-cucumber-help.txt
|
86
85
|
- bin/selenium-cucumber
|
87
86
|
homepage: http://seleniumcucumber.wordpress.com/
|
88
87
|
licenses:
|
@@ -1,16 +0,0 @@
|
|
1
|
-
Usage: selenium-cucumber <command-name> [parameters] [options]
|
2
|
-
<command-name> can be one of
|
3
|
-
help
|
4
|
-
gen
|
5
|
-
version
|
6
|
-
|
7
|
-
Commands:
|
8
|
-
help : prints more detailed help information.
|
9
|
-
|
10
|
-
gen : creates a skeleton features dir. This is usually used once when
|
11
|
-
setting up selnium-cucumber to ensure that the features folder contains
|
12
|
-
the right step definitions and environment to run with cucumber.
|
13
|
-
|
14
|
-
version : prints the gem version
|
15
|
-
|
16
|
-
Options: -v, --verbose Turns on verbose logging
|