selenium_fury 0.5.12 → 0.6.0
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/.rvmrc +2 -7
- data/Gemfile +1 -1
- data/VERSION +1 -1
- data/features/custom_generator.feature +1 -1
- data/features/generate_page_object.feature +1 -1
- data/features/step_definitions/custom_generator_steps.rb +81 -125
- data/features/step_definitions/generate_page_object_steps.rb +3 -3
- data/features/step_definitions/validate_page_object_steps.rb +4 -4
- data/features/support/env.rb +10 -4
- data/features/support/hooks.rb +2 -1
- data/features/validate_page_object.feature +3 -3
- data/lib/selenium_fury.rb +3 -4
- data/lib/selenium_fury/common/selenium_api_chooser.rb +19 -7
- data/lib/selenium_fury/selenium_client/locator_finder.rb +15 -0
- data/lib/selenium_fury/selenium_client/page_generator.rb +1 -0
- data/lib/selenium_fury/selenium_client/page_validator.rb +12 -37
- data/lib/selenium_fury/selenium_web_driver/element_finder.rb +16 -1
- data/lib/selenium_fury/selenium_web_driver/page_object.rb +2 -2
- data/lib/selenium_fury/selenium_web_driver/page_object_components.rb +1 -1
- data/spec/common/selenium_api_chooser_spec.rb +11 -11
- data/spec/selenium_client/custom_generators_spec.rb +23 -7
- data/spec/selenium_client/page_generator_spec.rb +3 -3
- data/spec/selenium_client/page_validator_spec.rb +5 -5
- data/spec/selenium_client/test_page_rc_spec.rb +14 -0
- data/spec/selenium_web_driver/element_finder_spec.rb +1 -1
- data/spec/selenium_web_driver/page_generator_spec.rb +10 -10
- data/spec/selenium_web_driver/page_object_spec.rb +69 -40
- data/spec/selenium_web_driver/page_validator_spec.rb +5 -5
- data/spec/spec_helper.rb +13 -12
- data/spec/test_page/test_page.html +70 -0
- data/spec/test_page/test_page.rb +21 -0
- data/spec/test_page/test_page_custom_generator_configuration.rb +16 -0
- data/spec/test_page/test_page_rc.rb +25 -0
- metadata +194 -181
- data/selenium_fury.gemspec +0 -118
- data/spec/selenium_client/advanced_search.rb +0 -55
- data/spec/selenium_client/advanced_search_custom_generator_configuration.rb +0 -16
- data/spec/selenium_client/advanced_search_spec.rb +0 -15
- data/spec/selenium_web_driver/advanced_search.rb +0 -47
- data/spec/selenium_web_driver/inquiry_side_bar.rb +0 -7
- data/spec/selenium_web_driver/property_page.rb +0 -3
data/.rvmrc
CHANGED
@@ -1,8 +1,4 @@
|
|
1
|
-
|
2
|
-
rvm_gemset_create_on_use_flag=1
|
3
|
-
rvm_project_rvmrc_default=1
|
4
|
-
rvm ruby-1.8.7-p334@selenium_fury
|
5
|
-
|
1
|
+
rvm use 1.9.3@selenium_fury --create
|
6
2
|
# Ensure that Bundler is installed, install it if it is not.
|
7
3
|
if ! command -v bundle ; then
|
8
4
|
printf "The rubygem 'bundler' is not installed, installing it now.\n"
|
@@ -10,6 +6,5 @@ if ! command -v bundle ; then
|
|
10
6
|
fi
|
11
7
|
|
12
8
|
# Bundle while redcing excess noise.
|
13
|
-
|
14
|
-
bundle | grep -v 'Using' | grep -v 'complete' | sed '/^$/d'
|
9
|
+
bundle | grep -vP '^Using(?!.*from source)'
|
15
10
|
|
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
@@ -2,7 +2,7 @@ Feature: Custom Generator
|
|
2
2
|
As an automated tester I want to create a page object with variable names that reflect business terms so the our test will reflect ubiquitous language.
|
3
3
|
|
4
4
|
Scenario: Use a custom generator configuration object to specify how to name our variables from another source than the id
|
5
|
-
Given I am on the
|
5
|
+
Given I am on the test page
|
6
6
|
When I have a custom generator configuration class
|
7
7
|
And I run the custom generator
|
8
8
|
Then I will have a ruby class produced that I can use as a page object
|
@@ -3,6 +3,6 @@ Feature: Generator
|
|
3
3
|
|
4
4
|
|
5
5
|
Scenario: The generator produces a ruby class on standard out that reflects the ids of page elements that can be used as a page object.
|
6
|
-
Given I am on the
|
6
|
+
Given I am on the test page
|
7
7
|
When I run the generator
|
8
8
|
Then I will have a ruby class produced that I can use as a page object
|
@@ -1,14 +1,14 @@
|
|
1
1
|
When /^I have a custom generator configuration class$/ do
|
2
|
-
@
|
3
|
-
@
|
2
|
+
@test_page_custom_generator_configuration = TestPageCustomGeneratorConfiguration.new()
|
3
|
+
@test_page_custom_generator_configuration.should_not be_nil
|
4
4
|
end
|
5
5
|
When /^I run the custom generator$/ do
|
6
6
|
@found_element_ids=custom_generator(:browser => browser,
|
7
|
-
:custom_configuration => @
|
7
|
+
:custom_configuration => @test_page_custom_generator_configuration)
|
8
8
|
|
9
9
|
end
|
10
10
|
When /^I specify a selector attribute$/ do
|
11
|
-
@
|
11
|
+
@test_page_custom_generator_configuration.selector.should_not be_nil
|
12
12
|
|
13
13
|
end
|
14
14
|
When /^I create a nokogiri document for the test page$/ do
|
@@ -18,143 +18,99 @@ When /^I create a nokogiri document for the test page$/ do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
Then /^I should get a nokogiri node set that I can iterate over to find a name and value for my page object locators$/ do
|
21
|
-
@check_box_nokogiri_elements = @doc.css(@
|
21
|
+
@check_box_nokogiri_elements = @doc.css(@test_page_custom_generator_configuration.selector)
|
22
22
|
@check_box_nokogiri_elements.class.to_s.should == "Nokogiri::XML::NodeSet"
|
23
23
|
@check_box_nokogiri_elements.each do |nokogiri_element|
|
24
24
|
nokogiri_element.class.to_s.should == "Nokogiri::XML::Element"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
When /^I call the name method on the custom generator configuration class$/ do
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@locator_name = @
|
28
|
+
@test_page_custom_generator_configuration.nokogiri_element=@check_box_nokogiri_elements.last
|
29
|
+
@test_page_custom_generator_configuration.nokogiri_element=@check_box_nokogiri_elements.last
|
30
|
+
@locator_name = @test_page_custom_generator_configuration.name
|
31
31
|
end
|
32
32
|
Then /^I should get the raw string to name my page object attribute$/ do
|
33
33
|
@locator_name.should_not be_nil
|
34
|
-
@locator_name.should == "
|
34
|
+
@locator_name.should == "Link 3"
|
35
35
|
end
|
36
36
|
When /^I call the value method on the custom generator configuration class$/ do
|
37
|
-
@locator_value = @
|
37
|
+
@locator_value = @test_page_custom_generator_configuration.value
|
38
38
|
end
|
39
39
|
Then /^I should get a value that I can use as a selenium locator$/ do
|
40
40
|
@locator_value.should_not be_nil
|
41
|
-
@locator_value.should == "
|
41
|
+
@locator_value.should == "link333333"
|
42
42
|
end
|
43
43
|
|
44
44
|
|
45
45
|
ADVANCED_SEARCH_HTML=<<EOF
|
46
|
-
|
47
|
-
<
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
<
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
<input class="checkbox" type="checkbox" id="location1.0" name="refinements" value="Location Type:near the ocean">
|
117
|
-
<label for="location1.0">near the ocean</label>
|
118
|
-
</div>
|
119
|
-
</div>
|
120
|
-
<div class="column">
|
121
|
-
<div class="cb-box">
|
122
|
-
<input class="checkbox" type="checkbox" id="location1.1" name="refinements" value="Location Type:resort">
|
123
|
-
<label for="location1.1">resort</label>
|
124
|
-
</div>
|
125
|
-
</div>
|
126
|
-
<div class="column">
|
127
|
-
<div class="cb-box">
|
128
|
-
<input class="checkbox" type="checkbox" id="location1.2" name="refinements" value="Location Type:rural">
|
129
|
-
<label for="location1.2">rural</label>
|
130
|
-
</div>
|
131
|
-
</div>
|
132
|
-
<div class="column">
|
133
|
-
<div class="cb-box">
|
134
|
-
<input class="checkbox" type="checkbox" id="location1.3" name="refinements" value="Location Type:town">
|
135
|
-
<label for="location1.3">town</label>
|
136
|
-
</div>
|
137
|
-
</div>
|
138
|
-
<div class="column">
|
139
|
-
<div class="cb-box">
|
140
|
-
<input class="checkbox" type="checkbox" id="location2.0" name="refinements" value="Location Type:village">
|
141
|
-
<label for="location2.0">village</label>
|
142
|
-
</div>
|
143
|
-
</div>
|
144
|
-
<div class="column">
|
145
|
-
<div class="cb-box">
|
146
|
-
<input class="checkbox" type="checkbox" id="location2.1" name="refinements" value="Location Type:river">
|
147
|
-
<label for="location2.1">river</label>
|
148
|
-
</div>
|
149
|
-
</div>
|
150
|
-
<div class="column">
|
151
|
-
<div class="cb-box">
|
152
|
-
<input class="checkbox" type="checkbox" id="location2.2" name="refinements" value="Location Type:downtown">
|
153
|
-
<label for="location2.2">downtown</label>
|
154
|
-
</div>
|
155
|
-
</div>
|
156
|
-
<div class="clear"></div>
|
157
|
-
</div>
|
158
|
-
</div>
|
159
|
-
<form>
|
46
|
+
<!doctype html>
|
47
|
+
<html lang="en">
|
48
|
+
<head>
|
49
|
+
<meta charset="utf-8">
|
50
|
+
<title>SeleniumFury Test Page</title>
|
51
|
+
<script type="text/javascript">
|
52
|
+
function displayMessage() {
|
53
|
+
document.getElementById('message').innerHTML = document.form.msgtext.value
|
54
|
+
}
|
55
|
+
</script>
|
56
|
+
</head>
|
57
|
+
<body>
|
58
|
+
|
59
|
+
<div id="message"></div>
|
60
|
+
|
61
|
+
<form id="form" name="form">
|
62
|
+
<label for="textarea">Textarea</label>
|
63
|
+
<textarea id="textarea">This is a textarea field.
|
64
|
+
</textarea>
|
65
|
+
<br/>
|
66
|
+
<label for="select">Select</label>
|
67
|
+
<select id="select">
|
68
|
+
<option value="volvo">Volvo</option>
|
69
|
+
<option value="saab">Saab</option>
|
70
|
+
<option value="mercedes">Mercedes</option>
|
71
|
+
<option value="audi">Audi</option>
|
72
|
+
</select>
|
73
|
+
<br/>
|
74
|
+
<label for="input_button">Button</label>
|
75
|
+
<input id="input_button" type="button" value="Click me"/>
|
76
|
+
<br/>
|
77
|
+
<label for="input_checkbox">Checkbox</label>
|
78
|
+
<input id="input_checkbox" type="checkbox"/>
|
79
|
+
<br/>
|
80
|
+
<label for="input_file">File</label>
|
81
|
+
<input id="input_file" type="file"/>
|
82
|
+
<br/>
|
83
|
+
<input id="input_hidden" type="hidden"/>
|
84
|
+
<br/>
|
85
|
+
<label for="input_image">Image</label>
|
86
|
+
<input id="input_image" type="image" alt="input image"/>
|
87
|
+
<br/>
|
88
|
+
<label for="input_password">Password</label>
|
89
|
+
<input id="input_password" type="password"/>
|
90
|
+
<br/>
|
91
|
+
<label for="input_radio">Radio</label>
|
92
|
+
<input id="input_radio" type="radio"/>
|
93
|
+
<br/>
|
94
|
+
<label for="input_reset">Reset</label>
|
95
|
+
<input id="input_reset" type="reset"/>
|
96
|
+
<br/>
|
97
|
+
<label for="input_submit">Submit</label>
|
98
|
+
<input id="input_submit" type="submit"/>
|
99
|
+
<br/>
|
100
|
+
<label for="input_text">Text</label>
|
101
|
+
<input id="input_text" type="text"/>
|
102
|
+
<br/>
|
103
|
+
<fieldset>
|
104
|
+
<legend>Input test:</legend>
|
105
|
+
<label for="input_message">Message Text:</label>
|
106
|
+
<input id="input_message" name="msgtext" type="text" />
|
107
|
+
<br/>
|
108
|
+
<input id="input_msg_button" type="button" value="Click me" onClick="displayMessage()"/>
|
109
|
+
</fieldset>
|
110
|
+
</form>
|
111
|
+
<a id="link111111" href="http://news.ycombinator.com/">Link 1</a>
|
112
|
+
<a id="link222222" href="http://yahoo.com">Link 2</a>
|
113
|
+
<a id="link333333" href="http://google.com">Link 3</a>
|
114
|
+
</body>
|
115
|
+
</html>
|
160
116
|
EOF
|
@@ -1,8 +1,8 @@
|
|
1
|
-
Given /^I am on the
|
2
|
-
create_selenium_driver
|
1
|
+
Given /^I am on the test page$/ do
|
2
|
+
create_selenium_driver TEST_PAGE_URL
|
3
3
|
browser.start_new_browser_session
|
4
4
|
puts "Testing #{browser.browser_url} on #{browser.browser_string} "
|
5
|
-
browser.open
|
5
|
+
browser.open TEST_PAGE_URL
|
6
6
|
end
|
7
7
|
|
8
8
|
When /^I run the generator$/ do
|
@@ -1,11 +1,11 @@
|
|
1
1
|
When /^I run the validator$/ do
|
2
|
-
validate(
|
2
|
+
validate(TestPageRc, TEST_PAGE_URL)
|
3
3
|
end
|
4
|
-
Then /^the
|
4
|
+
Then /^the test page object locators will be checked$/ do
|
5
5
|
@found_missing_locators.should have(0).elements
|
6
6
|
end
|
7
7
|
When /^I run the validator with missing locators$/ do
|
8
|
-
class
|
8
|
+
class TestPageRcBroken < TestPageRc
|
9
9
|
def initialize *browser
|
10
10
|
super
|
11
11
|
@missing_locator_attribute="missing_locator"
|
@@ -14,7 +14,7 @@ When /^I run the validator with missing locators$/ do
|
|
14
14
|
attr_reader :missing_locator_attribute
|
15
15
|
end
|
16
16
|
begin
|
17
|
-
check_page_file_class(
|
17
|
+
check_page_file_class(TestPageRcBroken,TEST_PAGE_URL)
|
18
18
|
rescue Exception=>e
|
19
19
|
end
|
20
20
|
end
|
data/features/support/env.rb
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
$:.unshift(File.dirname(__FILE__) + '/../../lib')
|
2
|
-
$:.unshift(File.dirname(__FILE__))
|
3
2
|
require 'rubygems'
|
4
|
-
require 'bundler
|
3
|
+
require 'bundler'
|
4
|
+
|
5
5
|
require 'selenium_fury'
|
6
|
-
|
7
|
-
|
6
|
+
|
7
|
+
|
8
|
+
require_relative "../../spec/test_page/test_page_rc"
|
9
|
+
require_relative "../../spec/test_page/test_page_custom_generator_configuration"
|
10
|
+
|
11
|
+
TEST_PAGE_URL="file://"+ File.expand_path(File.dirname(__FILE__) + "/../../spec/test_page/test_page.html")
|
12
|
+
include SeleniumFury::SeleniumWebDriver::CreateSeleniumWebDriver
|
13
|
+
include SeleniumFury::SeleniumClient::CreateSeleniumClientDriver
|
data/features/support/hooks.rb
CHANGED
@@ -2,11 +2,11 @@ Feature: Validator
|
|
2
2
|
As an automated tester I want a tool to check if my page object locators are correct so that I can update invalid locators.
|
3
3
|
|
4
4
|
Scenario: Use reflection to open a page object and validate that the locators are valid
|
5
|
-
Given I am on the
|
5
|
+
Given I am on the test page
|
6
6
|
When I run the validator
|
7
|
-
Then the
|
7
|
+
Then the test page object locators will be checked
|
8
8
|
|
9
9
|
Scenario: The validator will fail and return a list of missing locators
|
10
|
-
Given I am on the
|
10
|
+
Given I am on the test page
|
11
11
|
When I run the validator with missing locators
|
12
12
|
Then there will be missing locators found
|
data/lib/selenium_fury.rb
CHANGED
@@ -13,13 +13,12 @@
|
|
13
13
|
# * See the License for the specific language governing permissions and
|
14
14
|
# * limitations under the License.
|
15
15
|
# */
|
16
|
-
$:.unshift(File.dirname(__FILE__))
|
17
16
|
|
18
17
|
require 'rubygems'
|
19
18
|
require 'bundler'
|
20
|
-
|
21
|
-
require "selenium
|
22
|
-
require "selenium
|
19
|
+
|
20
|
+
require "selenium-webdriver"
|
21
|
+
require "selenium-client"
|
23
22
|
require 'nokogiri'
|
24
23
|
|
25
24
|
require "selenium_fury/selenium_client/page_generator"
|
@@ -1,3 +1,18 @@
|
|
1
|
+
#/* Copyright (c) 2010 HomeAway, Inc.
|
2
|
+
# * All rights reserved. http://www.homeaway.com
|
3
|
+
# *
|
4
|
+
# * Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# * you may not use this file except in compliance with the License.
|
6
|
+
# * You may obtain a copy of the License at
|
7
|
+
# *
|
8
|
+
# * http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
# *
|
10
|
+
# * Unless required by applicable law or agreed to in writing, software
|
11
|
+
# * distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# * See the License for the specific language governing permissions and
|
14
|
+
# * limitations under the License.
|
15
|
+
# */
|
1
16
|
module SeleniumFury
|
2
17
|
module SeleniumApiChooser
|
3
18
|
def generate(selenium_api_object)
|
@@ -9,13 +24,10 @@ module SeleniumFury
|
|
9
24
|
end
|
10
25
|
end
|
11
26
|
|
12
|
-
def validate(page_object,
|
13
|
-
if
|
14
|
-
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
18
|
-
unless driver.nil?
|
27
|
+
def validate(page_object, live_url = nil)
|
28
|
+
if browser
|
29
|
+
return check_page_file_class(page_object, live_url)
|
30
|
+
else
|
19
31
|
return web_driver_validate(page_object)
|
20
32
|
end
|
21
33
|
end
|
@@ -1,3 +1,18 @@
|
|
1
|
+
#/* Copyright (c) 2010 HomeAway, Inc.
|
2
|
+
# * All rights reserved. http://www.homeaway.com
|
3
|
+
# *
|
4
|
+
# * Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# * you may not use this file except in compliance with the License.
|
6
|
+
# * You may obtain a copy of the License at
|
7
|
+
# *
|
8
|
+
# * http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
# *
|
10
|
+
# * Unless required by applicable law or agreed to in writing, software
|
11
|
+
# * distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# * See the License for the specific language governing permissions and
|
14
|
+
# * limitations under the License.
|
15
|
+
# */
|
1
16
|
module SeleniumFury
|
2
17
|
module SeleniumClient
|
3
18
|
class LocatorFinder
|