selenium_fury 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog.md +29 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +31 -18
- data/Rakefile +2 -2
- data/features/custom_generator.feature +2 -1
- data/features/generate_page_object.feature +2 -1
- data/features/step_definitions/validate_page_object_steps.rb +4 -4
- data/features/validate_page_object.feature +2 -1
- data/lib/selenium_fury/common/page_parser.rb +49 -0
- data/lib/selenium_fury/common/selenium_api_chooser.rb +22 -0
- data/lib/selenium_fury/selenium_client/create_selenium_client_driver.rb +38 -0
- data/lib/selenium_fury/selenium_client/custom_generator.rb +65 -0
- data/lib/selenium_fury/selenium_client/locator_finder.rb +54 -0
- data/lib/selenium_fury/selenium_client/page_generator.rb +63 -0
- data/lib/selenium_fury/selenium_client/page_validator.rb +117 -0
- data/lib/selenium_fury/selenium_web_driver/create_selenium_web_driver.rb +35 -0
- data/lib/selenium_fury/selenium_web_driver/element_finder.rb +54 -0
- data/lib/selenium_fury/selenium_web_driver/page_generator.rb +47 -0
- data/lib/selenium_fury/selenium_web_driver/page_object.rb +26 -0
- data/lib/selenium_fury/selenium_web_driver/page_object_components.rb +67 -0
- data/lib/selenium_fury/selenium_web_driver/page_validator.rb +44 -0
- data/lib/selenium_fury.rb +24 -8
- data/selenium_fury.gemspec +46 -24
- data/spec/common/page_parser_spec.rb +9 -0
- data/spec/common/selenium_api_chooser_spec.rb +44 -0
- data/spec/{advanced_search.rb → selenium_client/advanced_search.rb} +1 -1
- data/spec/{advanced_search_custom_generator_configuration.rb → selenium_client/advanced_search_custom_generator_configuration.rb} +0 -0
- data/spec/{advanced_search_spec.rb → selenium_client/advanced_search_spec.rb} +0 -0
- data/spec/{custom_generators_spec.rb → selenium_client/custom_generators_spec.rb} +2 -1
- data/spec/selenium_client/locator_finder_spec.rb +20 -0
- data/spec/{page_generator_spec.rb → selenium_client/page_generator_spec.rb} +3 -2
- data/spec/selenium_client/page_validator_spec.rb +31 -0
- data/spec/selenium_web_driver/advanced_search.rb +47 -0
- data/spec/selenium_web_driver/element_finder_spec.rb +23 -0
- data/spec/selenium_web_driver/inquiry_side_bar.rb +7 -0
- data/spec/selenium_web_driver/page_generator_spec.rb +9 -0
- data/spec/selenium_web_driver/page_object_spec.rb +60 -0
- data/spec/selenium_web_driver/page_validator_spec.rb +21 -0
- data/spec/selenium_web_driver/property_page.rb +3 -0
- data/spec/spec_helper.rb +8 -4
- metadata +93 -59
- data/CHANGELOG +0 -5
- data/lib/selenium_fury/create_browser_driver.rb +0 -19
- data/lib/selenium_fury/custom_generator.rb +0 -62
- data/lib/selenium_fury/page_generator.rb +0 -130
- data/lib/selenium_fury/page_validator.rb +0 -113
- data/spec/page_validator_spec.rb +0 -9
@@ -0,0 +1,54 @@
|
|
1
|
+
module SeleniumFury
|
2
|
+
module SeleniumWebDriver
|
3
|
+
class ElementFinder
|
4
|
+
def initialize (nokogiri_elements)
|
5
|
+
@nokogiri_elements=nokogiri_elements
|
6
|
+
@valid_locators=["id", "class", "name"]
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :nokogiri_elements, :valid_locators
|
10
|
+
|
11
|
+
def find_elements
|
12
|
+
locators=[]
|
13
|
+
nokogiri_elements.each do |nokogiri_element|
|
14
|
+
valid_locators.each do |valid_locator|
|
15
|
+
if nokogiri_element.get_attribute(valid_locator) != nil
|
16
|
+
locators.push({valid_locator.to_sym, nokogiri_element.get_attribute(valid_locator)})
|
17
|
+
break
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
return locators
|
22
|
+
end
|
23
|
+
|
24
|
+
def web_driver_page_object_attributes
|
25
|
+
locators=find_elements
|
26
|
+
generated_attributes ={}
|
27
|
+
locators.each do |locator|
|
28
|
+
cleaned_name=clean_attribute_name(locator.values[0])
|
29
|
+
generated_attributes[cleaned_name] = locator
|
30
|
+
end
|
31
|
+
return generated_attributes
|
32
|
+
end
|
33
|
+
|
34
|
+
def clean_attribute_name name
|
35
|
+
if !name.nil?
|
36
|
+
find_and_replace_patterns = [[/([A-Z]+)/, '_\1'],
|
37
|
+
['input-', ''],
|
38
|
+
['select-', ''],
|
39
|
+
['\\', ''],
|
40
|
+
[' ', '_'],
|
41
|
+
['.', '_'],
|
42
|
+
['-', '_'],
|
43
|
+
['__', '_']
|
44
|
+
]
|
45
|
+
find_and_replace_patterns.each do |pattern|
|
46
|
+
name=name.gsub(pattern[0], pattern[1])
|
47
|
+
end
|
48
|
+
name=name.to_s.downcase
|
49
|
+
end
|
50
|
+
return name
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,47 @@
|
|
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
|
+
# */
|
16
|
+
module SeleniumFury
|
17
|
+
module SeleniumWebDriver
|
18
|
+
module PageGenerator
|
19
|
+
|
20
|
+
# @return [String]
|
21
|
+
# @param page_object_attributes [Hash]
|
22
|
+
def print_selenium_web_driver_page_object(page_object_attributes)
|
23
|
+
result = ""
|
24
|
+
result += "found (#{page_object_attributes.length} elements)\n"
|
25
|
+
result += "class YourPageFile < PageObject\n"
|
26
|
+
page_object_attributes.keys.sort.each do |attribute_name|
|
27
|
+
result += "\t\telement :#{attribute_name}, {:#{page_object_attributes[attribute_name].keys[0]} => \"#{page_object_attributes[attribute_name].values[0]}\"}\n"
|
28
|
+
end
|
29
|
+
result += "\n\nend"
|
30
|
+
$stdout.puts result
|
31
|
+
return result
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
# @param browser [Selenium::WebDriver::Driver]
|
36
|
+
def web_driver_generate(driver)
|
37
|
+
html =driver.page_source
|
38
|
+
nokogiri_elements = SeleniumFury::PageParser.new(html).nokogiri_elements
|
39
|
+
raise "The generator did not find nokogiri elements" unless nokogiri_elements
|
40
|
+
page_object_attributes = SeleniumFury::SeleniumWebDriver::ElementFinder.new(nokogiri_elements).web_driver_page_object_attributes
|
41
|
+
raise "The generator did not find page object attributes" if page_object_attributes.empty?
|
42
|
+
print_selenium_web_driver_page_object page_object_attributes
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,26 @@
|
|
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
|
+
# */
|
16
|
+
|
17
|
+
class PageObject
|
18
|
+
include SeleniumFury::SeleniumWebDriver::PageObjectComponents
|
19
|
+
include SeleniumFury::SeleniumWebDriver::CreateSeleniumWebDriver
|
20
|
+
|
21
|
+
def initialize *driver
|
22
|
+
@driver = *driver
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,67 @@
|
|
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
|
+
# */
|
16
|
+
module SeleniumFury
|
17
|
+
module SeleniumWebDriver
|
18
|
+
module PageObjectComponents
|
19
|
+
# when this module is loaded, add on the ClassMethods module
|
20
|
+
def self.included(base)
|
21
|
+
base.extend ClassMethods
|
22
|
+
end
|
23
|
+
|
24
|
+
module ClassMethods
|
25
|
+
# this is a method on the class now
|
26
|
+
#@method element(element_sym, element_hash, opts={})
|
27
|
+
# @param element_sym [:Symbol]
|
28
|
+
# @param element_hash [Hash]
|
29
|
+
# @param opts [Hash]
|
30
|
+
# @return [Selenium::WebDriver::Element]
|
31
|
+
def elements
|
32
|
+
@elements ||= []
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def element(element_sym, element_hash, opts={})
|
37
|
+
#@transient_elements ||= []
|
38
|
+
# define a new method with the name of the symbol after locator that returns the value
|
39
|
+
send :define_method, element_sym do
|
40
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 10) # seconds
|
41
|
+
begin
|
42
|
+
wait.until { driver.find_element element_hash }
|
43
|
+
rescue Selenium::WebDriver::Error::TimeOutError
|
44
|
+
raise "Could not find element #{element_sym}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# keep a running track of all elements and transient elements
|
49
|
+
elements << element_sym
|
50
|
+
#@transient_elements << element_hash if opts[:transient]
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
# @method page(page_sym, page_class)
|
55
|
+
# @param page_sym [:Symbol]
|
56
|
+
# @param page_class [Class]
|
57
|
+
# @return [PageObject]
|
58
|
+
def page(page_sym, page_class)
|
59
|
+
send :define_method, page_sym do
|
60
|
+
raise "#{page_class} does not inherit from PageObject" unless page_class.superclass == PageObject
|
61
|
+
page_class.new(driver)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,44 @@
|
|
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
|
+
# */
|
16
|
+
module SeleniumFury
|
17
|
+
module SeleniumWebDriver
|
18
|
+
module PageValidator
|
19
|
+
def web_driver_validate(page_class)
|
20
|
+
missing_elements=[]
|
21
|
+
puts "class #{page_class}"
|
22
|
+
page_object=page_class.new(driver)
|
23
|
+
raise "Could not find web driver elements in #{page_class}" if page_class.elements.nil?
|
24
|
+
page_class.elements.each do |web_drive_element_name|
|
25
|
+
puts "\tValidating #{web_drive_element_name}"
|
26
|
+
begin
|
27
|
+
page_object.method(web_drive_element_name).call
|
28
|
+
rescue
|
29
|
+
puts "\t\t\tCould not find #{web_drive_element_name}"
|
30
|
+
missing_elements.push(web_drive_element_name)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
if missing_elements.length > 0
|
34
|
+
puts "Missing Elements:"
|
35
|
+
missing_elements.each do |element|
|
36
|
+
puts element
|
37
|
+
end
|
38
|
+
end
|
39
|
+
raise "Found Missing Elements" if missing_elements.length > 0
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/selenium_fury.rb
CHANGED
@@ -17,15 +17,31 @@
|
|
17
17
|
require 'rubygems'
|
18
18
|
require 'bundler'
|
19
19
|
Bundler.setup
|
20
|
+
require "selenium/webdriver"
|
20
21
|
require "selenium/client"
|
21
22
|
require 'nokogiri'
|
22
23
|
|
23
|
-
require "selenium_fury/page_generator"
|
24
|
-
require "selenium_fury/custom_generator"
|
25
|
-
require "selenium_fury/page_validator"
|
26
|
-
require "selenium_fury/
|
24
|
+
require "selenium_fury/selenium_client/page_generator"
|
25
|
+
require "selenium_fury/selenium_client/custom_generator"
|
26
|
+
require "selenium_fury/selenium_client/page_validator"
|
27
|
+
require "selenium_fury/selenium_client/create_selenium_client_driver"
|
28
|
+
require "selenium_fury/selenium_client/locator_finder"
|
29
|
+
require "selenium_fury/common/page_parser"
|
30
|
+
require "selenium_fury/common/selenium_api_chooser"
|
31
|
+
require "selenium_fury/selenium_web_driver/create_selenium_web_driver"
|
32
|
+
require "selenium_fury/selenium_web_driver/element_finder"
|
33
|
+
require "selenium_fury/selenium_web_driver/page_object_components"
|
34
|
+
require "selenium_fury/selenium_web_driver/page_object"
|
35
|
+
require "selenium_fury/selenium_web_driver/page_generator"
|
36
|
+
require "selenium_fury/selenium_web_driver/page_validator"
|
27
37
|
|
28
|
-
include
|
29
|
-
include
|
30
|
-
include
|
31
|
-
include
|
38
|
+
include SeleniumFury::SeleniumClient::CreateSeleniumClientDriver
|
39
|
+
include SeleniumFury::SeleniumClient::CustomGenerator
|
40
|
+
include SeleniumFury::SeleniumClient::PageGenerator
|
41
|
+
include SeleniumFury::SeleniumClient::PageValidator
|
42
|
+
|
43
|
+
include SeleniumFury::SeleniumWebDriver::CreateSeleniumWebDriver
|
44
|
+
include SeleniumFury::SeleniumWebDriver::PageGenerator
|
45
|
+
include SeleniumFury::SeleniumWebDriver::PageValidator
|
46
|
+
|
47
|
+
include SeleniumFury::SeleniumApiChooser
|
data/selenium_fury.gemspec
CHANGED
@@ -4,21 +4,21 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.5.
|
7
|
+
s.name = "selenium_fury"
|
8
|
+
s.version = "0.5.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
11
|
+
s.authors = ["Scott Sims", "Tim Tischler"]
|
12
|
+
s.date = "2011-10-27"
|
13
|
+
s.description = "Generate and validate page objects with this page object factory for Selenium."
|
14
|
+
s.email = "ssims98@gmail.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
17
|
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".rvmrc",
|
21
|
-
"
|
21
|
+
"Changelog.md",
|
22
22
|
"Gemfile",
|
23
23
|
"Gemfile.lock",
|
24
24
|
"LICENSE",
|
@@ -33,29 +33,48 @@ Gem::Specification.new do |s|
|
|
33
33
|
"features/support/hooks.rb",
|
34
34
|
"features/validate_page_object.feature",
|
35
35
|
"lib/selenium_fury.rb",
|
36
|
-
"lib/selenium_fury/
|
37
|
-
"lib/selenium_fury/
|
38
|
-
"lib/selenium_fury/
|
39
|
-
"lib/selenium_fury/
|
36
|
+
"lib/selenium_fury/common/page_parser.rb",
|
37
|
+
"lib/selenium_fury/common/selenium_api_chooser.rb",
|
38
|
+
"lib/selenium_fury/selenium_client/create_selenium_client_driver.rb",
|
39
|
+
"lib/selenium_fury/selenium_client/custom_generator.rb",
|
40
|
+
"lib/selenium_fury/selenium_client/locator_finder.rb",
|
41
|
+
"lib/selenium_fury/selenium_client/page_generator.rb",
|
42
|
+
"lib/selenium_fury/selenium_client/page_validator.rb",
|
43
|
+
"lib/selenium_fury/selenium_web_driver/create_selenium_web_driver.rb",
|
44
|
+
"lib/selenium_fury/selenium_web_driver/element_finder.rb",
|
45
|
+
"lib/selenium_fury/selenium_web_driver/page_generator.rb",
|
46
|
+
"lib/selenium_fury/selenium_web_driver/page_object.rb",
|
47
|
+
"lib/selenium_fury/selenium_web_driver/page_object_components.rb",
|
48
|
+
"lib/selenium_fury/selenium_web_driver/page_validator.rb",
|
40
49
|
"selenium_fury.gemspec",
|
41
|
-
"spec/
|
42
|
-
"spec/
|
43
|
-
"spec/
|
44
|
-
"spec/
|
45
|
-
"spec/
|
46
|
-
"spec/
|
50
|
+
"spec/common/page_parser_spec.rb",
|
51
|
+
"spec/common/selenium_api_chooser_spec.rb",
|
52
|
+
"spec/selenium_client/advanced_search.rb",
|
53
|
+
"spec/selenium_client/advanced_search_custom_generator_configuration.rb",
|
54
|
+
"spec/selenium_client/advanced_search_spec.rb",
|
55
|
+
"spec/selenium_client/custom_generators_spec.rb",
|
56
|
+
"spec/selenium_client/locator_finder_spec.rb",
|
57
|
+
"spec/selenium_client/page_generator_spec.rb",
|
58
|
+
"spec/selenium_client/page_validator_spec.rb",
|
59
|
+
"spec/selenium_web_driver/advanced_search.rb",
|
60
|
+
"spec/selenium_web_driver/element_finder_spec.rb",
|
61
|
+
"spec/selenium_web_driver/inquiry_side_bar.rb",
|
62
|
+
"spec/selenium_web_driver/page_generator_spec.rb",
|
63
|
+
"spec/selenium_web_driver/page_object_spec.rb",
|
64
|
+
"spec/selenium_web_driver/page_validator_spec.rb",
|
65
|
+
"spec/selenium_web_driver/property_page.rb",
|
47
66
|
"spec/spec_helper.rb"
|
48
67
|
]
|
49
|
-
s.homepage =
|
50
|
-
s.require_paths = [
|
51
|
-
s.rubygems_version =
|
52
|
-
s.summary =
|
68
|
+
s.homepage = "https://github.com/scottcsims/SeleniumFury"
|
69
|
+
s.require_paths = ["lib"]
|
70
|
+
s.rubygems_version = "1.8.10"
|
71
|
+
s.summary = "Selenium Fury allows an automated tester to quickly build page files to use in the page object pattern. Each page file represents a page under test with attributes of all the locators selenium needs to run tests on the page and methods that represent actions that can be performed on the page. You use the generator to build the page files. After the page has been updated you can use the validator to go through all of the selenium locators you are using in your page file and return a list of the locators that it could not find. If there are missing locators you can then rerun the generator to generate new selenium locators for your page. http://www.scottcsims.com"
|
53
72
|
|
54
73
|
if s.respond_to? :specification_version then
|
55
74
|
s.specification_version = 3
|
56
75
|
|
57
76
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
58
|
-
s.add_runtime_dependency(%q<selenium-
|
77
|
+
s.add_runtime_dependency(%q<selenium-webdriver>, [">= 0"])
|
59
78
|
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
60
79
|
s.add_development_dependency(%q<yard>, [">= 0"])
|
61
80
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
@@ -65,9 +84,10 @@ Gem::Specification.new do |s|
|
|
65
84
|
s.add_development_dependency(%q<bundler>, [">= 0"])
|
66
85
|
s.add_development_dependency(%q<builder>, [">= 0"])
|
67
86
|
s.add_development_dependency(%q<rake>, [">= 0"])
|
87
|
+
s.add_development_dependency(%q<faker>, [">= 0"])
|
68
88
|
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
69
89
|
else
|
70
|
-
s.add_dependency(%q<selenium-
|
90
|
+
s.add_dependency(%q<selenium-webdriver>, [">= 0"])
|
71
91
|
s.add_dependency(%q<nokogiri>, [">= 0"])
|
72
92
|
s.add_dependency(%q<yard>, [">= 0"])
|
73
93
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
@@ -77,10 +97,11 @@ Gem::Specification.new do |s|
|
|
77
97
|
s.add_dependency(%q<bundler>, [">= 0"])
|
78
98
|
s.add_dependency(%q<builder>, [">= 0"])
|
79
99
|
s.add_dependency(%q<rake>, [">= 0"])
|
100
|
+
s.add_dependency(%q<faker>, [">= 0"])
|
80
101
|
s.add_dependency(%q<nokogiri>, [">= 0"])
|
81
102
|
end
|
82
103
|
else
|
83
|
-
s.add_dependency(%q<selenium-
|
104
|
+
s.add_dependency(%q<selenium-webdriver>, [">= 0"])
|
84
105
|
s.add_dependency(%q<nokogiri>, [">= 0"])
|
85
106
|
s.add_dependency(%q<yard>, [">= 0"])
|
86
107
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
@@ -90,6 +111,7 @@ Gem::Specification.new do |s|
|
|
90
111
|
s.add_dependency(%q<bundler>, [">= 0"])
|
91
112
|
s.add_dependency(%q<builder>, [">= 0"])
|
92
113
|
s.add_dependency(%q<rake>, [">= 0"])
|
114
|
+
s.add_dependency(%q<faker>, [">= 0"])
|
93
115
|
s.add_dependency(%q<nokogiri>, [">= 0"])
|
94
116
|
end
|
95
117
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
describe SeleniumFury::PageParser do
|
3
|
+
it "should have nokogiri_elements" do
|
4
|
+
html="<input id='myTestId'>"
|
5
|
+
page_parser=SeleniumFury::PageParser.new(html)
|
6
|
+
page_parser.nokogiri_elements.should have(1).nokogiri_element
|
7
|
+
page_parser.nokogiri_elements[0].get_attribute("id").should == "myTestId"
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe SeleniumFury::SeleniumApiChooser do
|
3
|
+
context "Finding generate/validate methods" do
|
4
|
+
it "should find the generator for selenium client tests" do
|
5
|
+
create_selenium_client_driver "http://www.scottcsims.com"
|
6
|
+
SeleniumFury::SeleniumClient::PageGenerator.should_receive(:get_source_and_print_elements)
|
7
|
+
generate(browser)
|
8
|
+
end
|
9
|
+
it "should find the generator for selenium web_driver tests" do
|
10
|
+
launch_web_driver "http://www.scottcsims.com"
|
11
|
+
SeleniumFury::SeleniumWebDriver::PageGenerator.should_receive(:web_driver_generate)
|
12
|
+
generate(driver)
|
13
|
+
end
|
14
|
+
it "should find the validator for selenium client tests" do
|
15
|
+
create_selenium_client_driver "http://www.scottcsims.com"
|
16
|
+
should_receive(:check_page_file_class).with(NilClass)
|
17
|
+
validate(NilClass)
|
18
|
+
end
|
19
|
+
it "should find the validator for selenium web driver tests" do
|
20
|
+
launch_web_driver "http://www.scottcsims.com"
|
21
|
+
SeleniumFury::SeleniumWebDriver::PageValidator.should_receive(:web_driver_validate).with(NilClass)
|
22
|
+
validate(NilClass)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
context "Integrating with generator/validator methods" do
|
26
|
+
it "should find generate elements for selenium client tests" do
|
27
|
+
create_selenium_client_driver "http://www.scottcsims.com"
|
28
|
+
browser.start_new_browser_session
|
29
|
+
browser.open "/"
|
30
|
+
generate(browser).should include("found (8 elements)")
|
31
|
+
|
32
|
+
end
|
33
|
+
it "should find validate elements for selenium client tests" do
|
34
|
+
create_selenium_driver("http://www.homeaway.com")
|
35
|
+
browser.start_new_browser_session
|
36
|
+
puts "Testing #{browser.browser_url} on #{browser.browser_string} "
|
37
|
+
validate(AdvancedSearch, "/searchForm")
|
38
|
+
end
|
39
|
+
it "should have found missing locators in module", SeleniumFury::SeleniumApiChooser do
|
40
|
+
SeleniumFury::SeleniumClient::PageValidator.respond_to?(:found_missing_locators).should be_true
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -43,7 +43,7 @@ class AdvancedSearch
|
|
43
43
|
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
attr_reader :browser, :adv_search_form, :bathrooms, :bedrooms, :end_date_input, :start_date_input, :price_from, :price_to,
|
47
47
|
:property_type, :sleeps, :special_offers, :start_date_input, :themes,
|
48
48
|
:air_conditioning, :beach, :children_welcome, :dishwasher,
|
49
49
|
:downtown, :fishing, :golf, :internet_access, :lake,
|
File without changes
|
File without changes
|
@@ -6,7 +6,8 @@ describe AdvancedSearchCustomGeneratorConfiguration do
|
|
6
6
|
puts "Testing #{browser.browser_url} on #{browser.browser_string} "
|
7
7
|
browser.open "/searchForm"
|
8
8
|
advanced_search_custom_generator_configuration = AdvancedSearchCustomGeneratorConfiguration.new
|
9
|
-
custom_generator(:browser => browser,
|
9
|
+
result = custom_generator(:browser => browser,
|
10
10
|
:custom_configuration => advanced_search_custom_generator_configuration)
|
11
|
+
result.should include("found (26 elements)")
|
11
12
|
end
|
12
13
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe SeleniumFury::SeleniumClient::LocatorFinder do
|
3
|
+
it "should find locators" do
|
4
|
+
html="<input id='myTestId1'><input name='myTestId2'>"
|
5
|
+
nokogiri_elements = SeleniumFury::PageParser.new(html).nokogiri_elements
|
6
|
+
nokogiri_elements.should have(2).elementS
|
7
|
+
SeleniumFury::SeleniumClient::LocatorFinder.new(nokogiri_elements).find_locators[0].should == "myTestId1"
|
8
|
+
SeleniumFury::SeleniumClient::LocatorFinder.new(nokogiri_elements).find_locators[1].should == "myTestId2"
|
9
|
+
end
|
10
|
+
it "should find get an attribute name" do
|
11
|
+
SeleniumFury::SeleniumClient::LocatorFinder.new(nil).attribute_name("myTestId1").should == "my_test_id1"
|
12
|
+
end
|
13
|
+
it "should have page object attributes" do
|
14
|
+
html="<input id='myTestId1'><input name='myTestId2'>"
|
15
|
+
nokogiri_elements = SeleniumFury::PageParser.new(html).nokogiri_elements
|
16
|
+
nokogiri_elements.should have(2).elementS
|
17
|
+
page_object_attributes = SeleniumFury::SeleniumClient::LocatorFinder.new(nokogiri_elements).page_object_attributes
|
18
|
+
page_object_attributes.should_not be_nil
|
19
|
+
end
|
20
|
+
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require "spec_helper"
|
2
|
-
describe PageGenerator do
|
2
|
+
describe SeleniumFury::SeleniumClient::PageGenerator do
|
3
3
|
it "should find elements on the HomeAway advanced search page" do
|
4
4
|
create_selenium_driver("http://www.homeaway.com")
|
5
5
|
browser.start_new_browser_session
|
6
6
|
puts "Testing #{browser.browser_url} on #{browser.browser_string} "
|
7
7
|
browser.open "/searchForm"
|
8
|
-
|
8
|
+
result = generate(browser)
|
9
|
+
result.should include("found (39 elements)")
|
9
10
|
end
|
10
11
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
describe SeleniumFury::SeleniumClient::PageValidator do
|
3
|
+
it "should validate the elements contained on the AdvancedSearch page object" do
|
4
|
+
create_selenium_driver("http://www.homeaway.com")
|
5
|
+
browser.start_new_browser_session
|
6
|
+
check_page_file_class(AdvancedSearch, "/searchForm")
|
7
|
+
@found_missing_locators.should_not be_nil
|
8
|
+
@found_missing_locators.should have(0).missing_locators
|
9
|
+
end
|
10
|
+
it "should fail if there are missing locators" do
|
11
|
+
create_selenium_driver("http://www.homeaway.com")
|
12
|
+
class MissingLocators
|
13
|
+
def initialize *browser
|
14
|
+
@browser=browser
|
15
|
+
@missing = "missing_id"
|
16
|
+
end
|
17
|
+
|
18
|
+
attr_reader :missing
|
19
|
+
end
|
20
|
+
browser.start_new_browser_session
|
21
|
+
begin
|
22
|
+
check_page_file_class(MissingLocators, browser, "/searchForm")
|
23
|
+
rescue Exception => e
|
24
|
+
puts e.message.should include("found missing locators")
|
25
|
+
@found_missing_locators["missing"].should =="missing_id"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
it "should have found missing locators in module",SeleniumFury::SeleniumClient::PageValidator do
|
29
|
+
SeleniumFury::SeleniumClient::PageValidator.respond_to?(:found_missing_locators).should be_true
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
class AdvancedSearchWebDriver < PageObject
|
2
|
+
element :adv_search_form, {:id => "adv-search-form"}
|
3
|
+
element :amenity0_0, {:id => "amenity0.0"}
|
4
|
+
element :amenity0_1, {:id => "amenity0.1"}
|
5
|
+
element :amenity1_0, {:id => "amenity1.0"}
|
6
|
+
element :amenity1_1, {:id => "amenity1.1"}
|
7
|
+
element :amenity2_0, {:id => "amenity2.0"}
|
8
|
+
element :amenity2_1, {:id => "amenity2.1"}
|
9
|
+
element :bathrooms, {:id => "bathrooms"}
|
10
|
+
element :bedrooms, {:id => "bedrooms"}
|
11
|
+
element :end_date_input, {:id => "endDateInput"}
|
12
|
+
element :leisure0_0, {:id => "leisure0.0"}
|
13
|
+
element :leisure1_0, {:id => "leisure1.0"}
|
14
|
+
element :leisure2_0, {:id => "leisure2.0"}
|
15
|
+
element :location0_0, {:id => "location0.0"}
|
16
|
+
element :location0_1, {:id => "location0.1"}
|
17
|
+
element :location0_2, {:id => "location0.2"}
|
18
|
+
element :location0_3, {:id => "location0.3"}
|
19
|
+
element :location1_0, {:id => "location1.0"}
|
20
|
+
element :location1_1, {:id => "location1.1"}
|
21
|
+
element :location1_2, {:id => "location1.2"}
|
22
|
+
element :location1_3, {:id => "location1.3"}
|
23
|
+
element :location2_0, {:id => "location2.0"}
|
24
|
+
element :location2_1, {:id => "location2.1"}
|
25
|
+
element :location2_2, {:id => "location2.2"}
|
26
|
+
element :price_from, {:id => "priceFrom"}
|
27
|
+
element :price_to, {:id => "priceTo"}
|
28
|
+
element :property_type, {:id => "propertyType"}
|
29
|
+
element :region, {:id => "region"}
|
30
|
+
element :search_keywords, {:id => "searchKeywords"}
|
31
|
+
element :sleeps, {:id => "sleeps"}
|
32
|
+
element :special_offers, {:id => "specialOffers"}
|
33
|
+
element :start_date_input, {:id => "startDateInput"}
|
34
|
+
element :suitability0_0, {:id => "suitability0.0"}
|
35
|
+
element :suitability0_1, {:id => "suitability0.1"}
|
36
|
+
element :suitability1_0, {:id => "suitability1.0"}
|
37
|
+
element :suitability1_1, {:id => "suitability1.1"}
|
38
|
+
element :suitability2_0, {:id => "suitability2.0"}
|
39
|
+
element :suitability2_1, {:id => "suitability2.1"}
|
40
|
+
element :themes, {:id => "themes"}
|
41
|
+
|
42
|
+
def click_one_item
|
43
|
+
amenity0_0.click
|
44
|
+
adv_search_form.submit
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
describe SeleniumFury::SeleniumWebDriver::ElementFinder do
|
3
|
+
it "should find elements" do
|
4
|
+
html="<input id='myTestId1'><input name='myTestId2'>"
|
5
|
+
nokogiri_elements = SeleniumFury::PageParser.new(html).nokogiri_elements
|
6
|
+
nokogiri_elements.should have(2).elementS
|
7
|
+
SeleniumFury::SeleniumWebDriver::ElementFinder.new(nokogiri_elements).find_elements[0].should == {:id=>"myTestId1"}
|
8
|
+
SeleniumFury::SeleniumWebDriver::ElementFinder.new(nokogiri_elements).find_elements[1].should == {:name=>"myTestId2"}
|
9
|
+
end
|
10
|
+
it "should clean an attribute name" do
|
11
|
+
SeleniumFury::SeleniumWebDriver::ElementFinder.new(nil).clean_attribute_name("myTestId1").should == "my_test_id1"
|
12
|
+
end
|
13
|
+
it "should have page object attributes with a locator type and locator" do
|
14
|
+
html="<input id='myTestId1'><input name='myTestId2'>"
|
15
|
+
expected_hash ={"my_test_id1"=>{:id =>'myTestId1'}, "my_test_id2"=>{:name =>'myTestId2'}}
|
16
|
+
nokogiri_elements = SeleniumFury::PageParser.new(html).nokogiri_elements
|
17
|
+
nokogiri_elements.should have(2).elements
|
18
|
+
page_object_attributes = SeleniumFury::SeleniumWebDriver::ElementFinder.new(nokogiri_elements).web_driver_page_object_attributes
|
19
|
+
page_object_attributes.should_not be_nil
|
20
|
+
page_object_attributes.should == expected_hash
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class InquirySideBar < PageObject
|
2
|
+
element :first_name, {:id=>"sidebar-inquirerFirstName"}
|
3
|
+
element :last_name, {:id=>"sidebar-inquirerLastName"}
|
4
|
+
element :email_address, {:id=>"sidebar-inquirerEmailAddress"}
|
5
|
+
element :phone_number, {:id=>"sidebar-inquirerPhoneNumber"}
|
6
|
+
element :confirmation_message, {:class=>"confirmation-message"}
|
7
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
describe SeleniumFury::SeleniumWebDriver::PageGenerator do
|
3
|
+
it "should find elements on the HomeAway advanced search page" do
|
4
|
+
launch_web_driver("http://www.homeaway.com/searchForm")
|
5
|
+
result = generate(driver)
|
6
|
+
result.should include("found (39 elements)")
|
7
|
+
result.should include("element :adv_search_form, {:id => \"adv-search-form\"}")
|
8
|
+
end
|
9
|
+
end
|