selenium_fury 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +16 -0
- data/.rvmrc +1 -2
- data/Gemfile +2 -17
- data/Rakefile +18 -42
- data/features/step_definitions/custom_generator_steps.rb +1 -3
- data/features/step_definitions/generate_page_object_steps.rb +3 -6
- data/features/step_definitions/validate_page_object_steps.rb +3 -16
- data/features/support/env.rb +2 -2
- data/features/support/hooks.rb +0 -1
- data/lib/selenium_fury/common/selenium_api_chooser.rb +3 -0
- data/lib/selenium_fury/selenium_web_driver/create_selenium_web_driver.rb +1 -1
- data/lib/selenium_fury/selenium_web_driver/page_object_components.rb +0 -3
- data/lib/selenium_fury/selenium_web_driver/page_validator.rb +2 -1
- data/lib/selenium_fury/version.rb +3 -0
- data/lib/selenium_fury.rb +1 -9
- data/selenium_fury.gemspec +19 -114
- data/spec/common/selenium_api_chooser_spec.rb +0 -28
- data/spec/selenium_web_driver/page_object_spec.rb +9 -8
- data/spec/selenium_web_driver/page_validator_spec.rb +4 -4
- data/spec/spec_helper.rb +0 -3
- metadata +30 -129
- data/VERSION +0 -1
- data/lib/selenium_fury/selenium_client/create_selenium_client_driver.rb +0 -38
- data/lib/selenium_fury/selenium_client/custom_generator.rb +0 -65
- data/lib/selenium_fury/selenium_client/locator_finder.rb +0 -69
- data/lib/selenium_fury/selenium_client/page_generator.rb +0 -64
- data/lib/selenium_fury/selenium_client/page_validator.rb +0 -92
- data/spec/selenium_client/custom_generators_spec.rb +0 -29
- data/spec/selenium_client/locator_finder_spec.rb +0 -20
- data/spec/selenium_client/page_generator_spec.rb +0 -11
- data/spec/selenium_client/page_validator_spec.rb +0 -31
- data/spec/selenium_client/test_page_rc_spec.rb +0 -14
- data/spec/test_page/test_page_rc.rb +0 -25
data/.gitignore
ADDED
data/.rvmrc
CHANGED
data/Gemfile
CHANGED
@@ -1,20 +1,5 @@
|
|
1
1
|
source :rubygems
|
2
2
|
|
3
|
-
gem
|
4
|
-
|
5
|
-
|
6
|
-
group :development do
|
7
|
-
gem 'yard'
|
8
|
-
gem 'jeweler'
|
9
|
-
gem 'rdiscount'
|
10
|
-
gem "rspec"
|
11
|
-
gem "cucumber"
|
12
|
-
gem "bundler"
|
13
|
-
gem "builder"
|
14
|
-
gem "rake"
|
15
|
-
gem "faker"
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
|
3
|
+
# Specify your gem's dependencies in selenium_fury.gemspec
|
4
|
+
gemspec
|
20
5
|
|
data/Rakefile
CHANGED
@@ -1,54 +1,30 @@
|
|
1
|
-
|
2
|
-
require '
|
3
|
-
require '
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
#require 'rubygems'
|
3
|
+
#require 'bundler/setup'
|
4
4
|
|
5
5
|
require 'rspec'
|
6
6
|
require 'rspec/core/rake_task'
|
7
|
-
|
8
|
-
require 'yard'
|
9
|
-
require 'yard/rake/yardoc_task'
|
10
|
-
|
11
7
|
require 'cucumber'
|
12
8
|
require 'cucumber/rake/task'
|
13
|
-
|
9
|
+
require 'yard'
|
10
|
+
require 'yard/rake/yardoc_task'
|
11
|
+
require "bundler/gem_tasks"
|
14
12
|
|
15
13
|
RSpec::Core::RakeTask.new(:spec)
|
16
|
-
|
17
|
-
Cucumber::Rake::Task.new(:feature) do |task|
|
18
|
-
task.cucumber_opts = ["features"]
|
19
|
-
end
|
20
|
-
|
21
|
-
task :default do
|
22
|
-
system "rake -T"
|
23
|
-
end
|
24
|
-
|
14
|
+
Cucumber::Rake::Task.new(:feature)
|
25
15
|
YARD::Rake::YardocTask.new do |t|
|
26
16
|
t.files = ['lib/**/*.rb']
|
27
17
|
end
|
28
18
|
|
29
|
-
|
30
|
-
|
31
|
-
gem.name = "selenium_fury"
|
32
|
-
gem.description = %q{Generate and validate page objects with this page object factory for Selenium.}
|
33
|
-
gem.summary = %q{ Selenium Fury allows an automated tester to quickly build page files to use in the page object pattern. Each page file represents
|
34
|
-
a page under test with attributes of all the locators selenium needs to run tests on the page and methods that represent
|
35
|
-
actions that can be performed on the page.
|
36
|
-
|
37
|
-
You use the generator to build the page files. After the page has been updated you can use the validator to go through
|
38
|
-
all of the selenium locators you are using in your page file and return a list of the locators that it could not find.
|
39
|
-
If there are missing locators you can then rerun the generator to generate new selenium locators for your page. http://www.scottcsims.com}
|
40
|
-
gem.email = "ssims98@gmail.com"
|
41
|
-
gem.authors = ["Scott Sims", "Tim Tischler"]
|
42
|
-
gem.homepage = "https://github.com/scottcsims/SeleniumFury"
|
43
|
-
gem.add_dependency 'nokogiri'
|
44
|
-
end
|
45
|
-
|
46
|
-
desc 'Push gem to gem server'
|
47
|
-
task 'release' => ['gem:build', 'gem:git:release'] do
|
48
|
-
jeweler = Rake.application.jeweler
|
49
|
-
gemspec = jeweler.gemspec
|
50
|
-
command = "gem push pkg/#{gemspec.name}-#{jeweler.version}.gem"
|
51
|
-
puts "Executing #{command.inspect}:"
|
52
|
-
system command
|
53
|
-
end
|
19
|
+
task :default do
|
20
|
+
system "rake spec"
|
54
21
|
end
|
22
|
+
|
23
|
+
#desc 'Push gem to gem server'
|
24
|
+
# task 'release' => ['gem:build', 'gem:git:release'] do
|
25
|
+
# jeweler = Rake.application.jeweler
|
26
|
+
# gemspec = jeweler.gemspec
|
27
|
+
# command = "gem push pkg/#{gemspec.name}-#{jeweler.version}.gem"
|
28
|
+
# puts "Executing #{command.inspect}:"
|
29
|
+
# system command
|
30
|
+
# end
|
@@ -3,9 +3,7 @@ When /^I have a custom generator configuration class$/ do
|
|
3
3
|
@test_page_custom_generator_configuration.should_not be_nil
|
4
4
|
end
|
5
5
|
When /^I run the custom generator$/ do
|
6
|
-
|
7
|
-
:custom_configuration => @test_page_custom_generator_configuration)
|
8
|
-
|
6
|
+
pending
|
9
7
|
end
|
10
8
|
When /^I specify a selector attribute$/ do
|
11
9
|
@test_page_custom_generator_configuration.selector.should_not be_nil
|
@@ -1,14 +1,11 @@
|
|
1
1
|
Given /^I am on the test page$/ do
|
2
|
-
|
3
|
-
browser.start_new_browser_session
|
4
|
-
puts "Testing #{browser.browser_url} on #{browser.browser_string} "
|
5
|
-
browser.open TEST_PAGE_URL
|
2
|
+
launch_web_driver TEST_PAGE_URL
|
6
3
|
end
|
7
4
|
|
8
5
|
When /^I run the generator$/ do
|
9
|
-
@found_element_ids=
|
6
|
+
@found_element_ids=generate(driver)
|
10
7
|
end
|
11
8
|
|
12
9
|
Then /^I will have a ruby class produced that I can use as a page object$/ do
|
13
|
-
@found_element_ids.
|
10
|
+
@found_element_ids.should include('found (15 elements)')
|
14
11
|
end
|
@@ -1,24 +1,11 @@
|
|
1
1
|
When /^I run the validator$/ do
|
2
|
-
validate(
|
2
|
+
validate(TestPage)
|
3
3
|
end
|
4
4
|
Then /^the test page object locators will be checked$/ do
|
5
|
-
@found_missing_locators.should have(0).elements
|
6
5
|
end
|
7
6
|
When /^I run the validator with missing locators$/ do
|
8
|
-
|
9
|
-
def initialize *browser
|
10
|
-
super
|
11
|
-
@missing_locator_attribute="missing_locator"
|
12
|
-
end
|
13
|
-
|
14
|
-
attr_reader :missing_locator_attribute
|
15
|
-
end
|
16
|
-
begin
|
17
|
-
check_page_file_class(TestPageRcBroken,TEST_PAGE_URL)
|
18
|
-
rescue Exception=>e
|
19
|
-
end
|
7
|
+
pending
|
20
8
|
end
|
21
9
|
Then /^there will be missing locators found$/ do
|
22
|
-
|
23
|
-
@found_missing_locators["missing_locator_attribute"].should == "missing_locator"
|
10
|
+
pending
|
24
11
|
end
|
data/features/support/env.rb
CHANGED
@@ -5,9 +5,9 @@ require 'bundler'
|
|
5
5
|
require 'selenium_fury'
|
6
6
|
|
7
7
|
|
8
|
-
require_relative "../../spec/test_page/test_page_rc"
|
9
8
|
require_relative "../../spec/test_page/test_page_custom_generator_configuration"
|
9
|
+
require_relative "../../spec/test_page/test_page"
|
10
10
|
|
11
11
|
TEST_PAGE_URL="file://"+ File.expand_path(File.dirname(__FILE__) + "/../../spec/test_page/test_page.html")
|
12
|
+
|
12
13
|
include SeleniumFury::SeleniumWebDriver::CreateSeleniumWebDriver
|
13
|
-
include SeleniumFury::SeleniumClient::CreateSeleniumClientDriver
|
data/features/support/hooks.rb
CHANGED
@@ -17,8 +17,9 @@ module SeleniumFury
|
|
17
17
|
module SeleniumWebDriver
|
18
18
|
module PageValidator
|
19
19
|
def web_driver_validate(page_class)
|
20
|
-
raise("Cannot find driver")
|
20
|
+
raise("Cannot find driver") if driver.nil?
|
21
21
|
missing_elements=[]
|
22
|
+
validated_elements=[]
|
22
23
|
puts "class #{page_class}"
|
23
24
|
page_object=page_class.new(driver)
|
24
25
|
raise "Could not find web driver elements in #{page_class}" if page_class.elements.nil?
|
data/lib/selenium_fury.rb
CHANGED
@@ -14,6 +14,7 @@
|
|
14
14
|
# * limitations under the License.
|
15
15
|
# */
|
16
16
|
|
17
|
+
require "selenium_fury/version"
|
17
18
|
require 'rubygems'
|
18
19
|
require 'bundler'
|
19
20
|
|
@@ -21,11 +22,6 @@ require "selenium-webdriver"
|
|
21
22
|
require "selenium-client"
|
22
23
|
require 'nokogiri'
|
23
24
|
|
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
25
|
require "selenium_fury/common/page_parser"
|
30
26
|
require "selenium_fury/common/selenium_api_chooser"
|
31
27
|
require "selenium_fury/selenium_web_driver/create_selenium_web_driver"
|
@@ -35,10 +31,6 @@ require "selenium_fury/selenium_web_driver/page_object"
|
|
35
31
|
require "selenium_fury/selenium_web_driver/page_generator"
|
36
32
|
require "selenium_fury/selenium_web_driver/page_validator"
|
37
33
|
|
38
|
-
include SeleniumFury::SeleniumClient::CustomGenerator
|
39
|
-
include SeleniumFury::SeleniumClient::PageGenerator
|
40
|
-
include SeleniumFury::SeleniumClient::PageValidator
|
41
|
-
|
42
34
|
include SeleniumFury::SeleniumWebDriver::PageGenerator
|
43
35
|
include SeleniumFury::SeleniumWebDriver::PageValidator
|
44
36
|
|
data/selenium_fury.gemspec
CHANGED
@@ -1,117 +1,22 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/selenium_fury/version', __FILE__)
|
5
3
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
"README.md",
|
25
|
-
"Rakefile",
|
26
|
-
"VERSION",
|
27
|
-
"features/custom_generator.feature",
|
28
|
-
"features/generate_page_object.feature",
|
29
|
-
"features/step_definitions/custom_generator_steps.rb",
|
30
|
-
"features/step_definitions/generate_page_object_steps.rb",
|
31
|
-
"features/step_definitions/validate_page_object_steps.rb",
|
32
|
-
"features/support/env.rb",
|
33
|
-
"features/support/hooks.rb",
|
34
|
-
"features/validate_page_object.feature",
|
35
|
-
"lib/selenium_fury.rb",
|
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",
|
49
|
-
"selenium_fury.gemspec",
|
50
|
-
"spec/common/page_parser_spec.rb",
|
51
|
-
"spec/common/selenium_api_chooser_spec.rb",
|
52
|
-
"spec/selenium_client/custom_generators_spec.rb",
|
53
|
-
"spec/selenium_client/locator_finder_spec.rb",
|
54
|
-
"spec/selenium_client/page_generator_spec.rb",
|
55
|
-
"spec/selenium_client/page_validator_spec.rb",
|
56
|
-
"spec/selenium_client/test_page_rc_spec.rb",
|
57
|
-
"spec/selenium_web_driver/element_finder_spec.rb",
|
58
|
-
"spec/selenium_web_driver/page_generator_spec.rb",
|
59
|
-
"spec/selenium_web_driver/page_object_spec.rb",
|
60
|
-
"spec/selenium_web_driver/page_validator_spec.rb",
|
61
|
-
"spec/spec_helper.rb",
|
62
|
-
"spec/test_page/test_page.html",
|
63
|
-
"spec/test_page/test_page.rb",
|
64
|
-
"spec/test_page/test_page_custom_generator_configuration.rb",
|
65
|
-
"spec/test_page/test_page_rc.rb"
|
66
|
-
]
|
67
|
-
s.homepage = "https://github.com/scottcsims/SeleniumFury"
|
68
|
-
s.require_paths = ["lib"]
|
69
|
-
s.rubygems_version = "1.8.24"
|
70
|
-
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"
|
71
|
-
|
72
|
-
if s.respond_to? :specification_version then
|
73
|
-
s.specification_version = 3
|
74
|
-
|
75
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
76
|
-
s.add_runtime_dependency(%q<selenium-webdriver>, [">= 0"])
|
77
|
-
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
78
|
-
s.add_development_dependency(%q<yard>, [">= 0"])
|
79
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
80
|
-
s.add_development_dependency(%q<rdiscount>, [">= 0"])
|
81
|
-
s.add_development_dependency(%q<rspec>, [">= 0"])
|
82
|
-
s.add_development_dependency(%q<cucumber>, [">= 0"])
|
83
|
-
s.add_development_dependency(%q<bundler>, [">= 0"])
|
84
|
-
s.add_development_dependency(%q<builder>, [">= 0"])
|
85
|
-
s.add_development_dependency(%q<rake>, [">= 0"])
|
86
|
-
s.add_development_dependency(%q<faker>, [">= 0"])
|
87
|
-
s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
|
88
|
-
else
|
89
|
-
s.add_dependency(%q<selenium-webdriver>, [">= 0"])
|
90
|
-
s.add_dependency(%q<nokogiri>, [">= 0"])
|
91
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
92
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
93
|
-
s.add_dependency(%q<rdiscount>, [">= 0"])
|
94
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
95
|
-
s.add_dependency(%q<cucumber>, [">= 0"])
|
96
|
-
s.add_dependency(%q<bundler>, [">= 0"])
|
97
|
-
s.add_dependency(%q<builder>, [">= 0"])
|
98
|
-
s.add_dependency(%q<rake>, [">= 0"])
|
99
|
-
s.add_dependency(%q<faker>, [">= 0"])
|
100
|
-
s.add_dependency(%q<nokogiri>, [">= 0"])
|
101
|
-
end
|
102
|
-
else
|
103
|
-
s.add_dependency(%q<selenium-webdriver>, [">= 0"])
|
104
|
-
s.add_dependency(%q<nokogiri>, [">= 0"])
|
105
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
106
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
107
|
-
s.add_dependency(%q<rdiscount>, [">= 0"])
|
108
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
109
|
-
s.add_dependency(%q<cucumber>, [">= 0"])
|
110
|
-
s.add_dependency(%q<bundler>, [">= 0"])
|
111
|
-
s.add_dependency(%q<builder>, [">= 0"])
|
112
|
-
s.add_dependency(%q<rake>, [">= 0"])
|
113
|
-
s.add_dependency(%q<faker>, [">= 0"])
|
114
|
-
s.add_dependency(%q<nokogiri>, [">= 0"])
|
115
|
-
end
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Scott Sims"]
|
6
|
+
gem.email = ["ssims98@gmail.com"]
|
7
|
+
gem.description = %q{Generate and validate page objects with this page object factory for Selenium.}
|
8
|
+
gem.summary = %q{Generate Selenium Page Objects}
|
9
|
+
gem.homepage = "https://github.com/scottcsims/SeleniumFury"
|
10
|
+
gem.files = `git ls-files`.split($\)
|
11
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
12
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
|
+
gem.name = "selenium_fury"
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.version = SeleniumFury::VERSION
|
16
|
+
gem.add_dependency('selenium-webdriver')
|
17
|
+
gem.add_dependency('nokogiri')
|
18
|
+
gem.add_development_dependency('rspec')
|
19
|
+
gem.add_development_dependency('cucumber')
|
20
|
+
gem.add_development_dependency('yard')
|
21
|
+
gem.add_development_dependency('redcarpet')
|
116
22
|
end
|
117
|
-
|
@@ -1,43 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
describe SeleniumFury::SeleniumApiChooser do
|
3
3
|
context "Finding generate/validate methods" do
|
4
|
-
it "should find the generator for selenium client tests" do
|
5
|
-
create_selenium_client_driver TEST_PAGE_URL
|
6
|
-
should_receive(:get_source_and_print_elements)
|
7
|
-
generate(browser)
|
8
|
-
end
|
9
4
|
it "should find the generator for selenium web_driver tests" do
|
10
5
|
launch_web_driver TEST_PAGE_URL
|
11
6
|
should_receive(:web_driver_generate)
|
12
7
|
generate(driver)
|
13
8
|
end
|
14
|
-
it "should find the validator for selenium client tests" do
|
15
|
-
create_selenium_client_driver TEST_PAGE_URL
|
16
|
-
should_receive(:check_page_file_class).with(NilClass)
|
17
|
-
validate(NilClass)
|
18
|
-
end
|
19
9
|
it "should find the validator for selenium web driver tests" do
|
20
10
|
launch_web_driver TEST_PAGE_URL
|
21
11
|
should_receive(:web_driver_validate).with(NilClass)
|
22
12
|
validate(NilClass)
|
23
13
|
end
|
24
14
|
end
|
25
|
-
context "Integrating with generator/validator methods" do
|
26
|
-
it "should find generate method for selenium client tests" do
|
27
|
-
create_selenium_driver TEST_PAGE_URL
|
28
|
-
browser.start_new_browser_session
|
29
|
-
browser.open TEST_PAGE_URL
|
30
|
-
generate(browser).should include("found (15 elements)")
|
31
|
-
end
|
32
|
-
it "should find validate method for selenium client tests" do
|
33
|
-
create_selenium_driver TEST_PAGE_URL
|
34
|
-
browser.start_new_browser_session
|
35
|
-
puts "Testing #{browser.browser_url} on #{browser.browser_string} "
|
36
|
-
validate(TestPageRc, TEST_PAGE_URL)
|
37
|
-
end
|
38
|
-
it "should have found missing locators in module", SeleniumFury::SeleniumApiChooser do
|
39
|
-
SeleniumFury::SeleniumClient::PageValidator.respond_to?(:found_missing_locators).should be_true
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
15
|
end
|
@@ -8,6 +8,7 @@ describe SeleniumFury::SeleniumWebDriver::CreateSeleniumWebDriver do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
describe PageObject do
|
11
|
+
|
11
12
|
it "should have a text area method on the test page" do
|
12
13
|
launch_web_driver TEST_PAGE_URL
|
13
14
|
test_page = TestPage.new(driver)
|
@@ -41,7 +42,7 @@ describe PageObject do
|
|
41
42
|
test_page.click_check_box
|
42
43
|
driver.find_element(:id => "input_checkbox").selected?.should be_true
|
43
44
|
end
|
44
|
-
|
45
|
+
end
|
45
46
|
# OK, so here's some great info about the "magic" behind ruby.
|
46
47
|
# When ruby spins up, an Object class is created, and everything runs "inside" it
|
47
48
|
# When you do code like this: TestPage.new() an instance of TestPage is added as a constant
|
@@ -55,30 +56,30 @@ describe PageObject do
|
|
55
56
|
# It should also be noted that get_page_object only adds page elements to the class
|
56
57
|
# and currently doesn't look for a pre-defined page object in the project
|
57
58
|
|
59
|
+
describe "PageObjectElements" do
|
60
|
+
before(:each) do
|
61
|
+
Object.instance_eval { remove_const :TestPage } if Object.const_defined? :TestPage
|
62
|
+
end
|
63
|
+
after(:each) do
|
64
|
+
Object.instance_eval { remove_const :TestPage }
|
65
|
+
end
|
58
66
|
it "should have elements" do
|
59
|
-
Object.instance_eval { remove_const :TestPage } if Object.const_defined? :TestPage
|
60
67
|
launch_web_driver TEST_PAGE_URL
|
61
68
|
test_page = get_page_object(driver, 'TestPage')
|
62
69
|
test_page.class.elements.should_not be_nil
|
63
70
|
test_page.class.elements.should have(15).elements
|
64
71
|
test_page.method(test_page.class.elements[0]).call.class.should == Selenium::WebDriver::Element
|
65
|
-
Object.instance_eval { remove_const :TestPage }
|
66
72
|
end
|
67
73
|
it "should return a web_driver element when an attribute is accessed" do
|
68
|
-
Object.instance_eval { remove_const :TestPage } if Object.const_defined? :TestPage
|
69
74
|
launch_web_driver TEST_PAGE_URL
|
70
75
|
test_page = get_page_object(driver, 'TestPage')
|
71
76
|
test_page.textarea.class.should == Selenium::WebDriver::Element
|
72
|
-
Object.instance_eval { remove_const :TestPage }
|
73
77
|
end
|
74
78
|
|
75
79
|
it "should raise an exception when the element can't be found'" do
|
76
|
-
Object.instance_eval { remove_const :TestPage } if Object.const_defined? :TestPage
|
77
80
|
launch_web_driver TEST_PAGE_URL
|
78
81
|
test_page = get_page_object(driver, 'TestPage')
|
79
82
|
TestPage.element :not_a_element, {:id => "not a element"}
|
80
83
|
expect { test_page.not_a_element }.to raise_exception RuntimeError, "Could not find element not_a_element"
|
81
|
-
Object.instance_eval { remove_const :TestPage }
|
82
84
|
end
|
83
|
-
|
84
85
|
end
|
@@ -3,16 +3,16 @@ describe SeleniumFury::SeleniumWebDriver::PageValidator do
|
|
3
3
|
|
4
4
|
it "should have a missing element exception" do
|
5
5
|
class MissingElement < PageObject
|
6
|
-
element :not_a_element1, {:id=>"not a element1"}
|
7
|
-
element :not_a_element2, {:id=>"not a element2"}
|
6
|
+
element :not_a_element1, {:id => "not a element1"}
|
7
|
+
element :not_a_element2, {:id => "not a element2"}
|
8
8
|
end
|
9
9
|
launch_web_driver TEST_PAGE_URL
|
10
|
-
expect{web_driver_validate(MissingElement)}.to raise_exception RuntimeError,"Found Missing Elements: [:not_a_element1, :not_a_element2]"
|
10
|
+
expect { web_driver_validate(MissingElement) }.to raise_exception RuntimeError, "Found Missing Elements: [:not_a_element1, :not_a_element2]"
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should validate elements" do
|
14
14
|
launch_web_driver TEST_PAGE_URL
|
15
|
-
validate
|
15
|
+
validate(TestPage)
|
16
16
|
end
|
17
17
|
|
18
18
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,11 +4,9 @@ require 'bundler'
|
|
4
4
|
require 'selenium_fury'
|
5
5
|
|
6
6
|
require "test_page/test_page_custom_generator_configuration"
|
7
|
-
require "test_page/test_page_rc"
|
8
7
|
|
9
8
|
TEST_PAGE_URL="file://"+File.dirname(__FILE__) + "/test_page/test_page.html"
|
10
9
|
include SeleniumFury::SeleniumWebDriver::CreateSeleniumWebDriver
|
11
|
-
include SeleniumFury::SeleniumClient::CreateSeleniumClientDriver
|
12
10
|
|
13
11
|
RSpec.configure do |config|
|
14
12
|
config.before(:each) do
|
@@ -17,7 +15,6 @@ RSpec.configure do |config|
|
|
17
15
|
load "test_page/test_page.rb"
|
18
16
|
end
|
19
17
|
config.after(:each) do
|
20
|
-
browser.close_current_browser_session unless(browser.nil? || browser.session_id.nil?)
|
21
18
|
driver.quit unless driver.nil?
|
22
19
|
end
|
23
20
|
end
|
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selenium_fury
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Scott Sims
|
9
|
-
- Tim Tischler
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2012-09
|
12
|
+
date: 2012-11-09 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: selenium-webdriver
|
@@ -44,54 +43,6 @@ dependencies:
|
|
44
43
|
- - ! '>='
|
45
44
|
- !ruby/object:Gem::Version
|
46
45
|
version: '0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: yard
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
|
-
requirements:
|
52
|
-
- - ! '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
type: :development
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
|
-
requirements:
|
60
|
-
- - ! '>='
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '0'
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
|
-
name: jeweler
|
65
|
-
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
|
-
requirements:
|
68
|
-
- - ! '>='
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: '0'
|
71
|
-
type: :development
|
72
|
-
prerelease: false
|
73
|
-
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
|
-
requirements:
|
76
|
-
- - ! '>='
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
version: '0'
|
79
|
-
- !ruby/object:Gem::Dependency
|
80
|
-
name: rdiscount
|
81
|
-
requirement: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
|
-
requirements:
|
84
|
-
- - ! '>='
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
version: '0'
|
87
|
-
type: :development
|
88
|
-
prerelease: false
|
89
|
-
version_requirements: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
|
-
requirements:
|
92
|
-
- - ! '>='
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
version: '0'
|
95
46
|
- !ruby/object:Gem::Dependency
|
96
47
|
name: rspec
|
97
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -125,39 +76,7 @@ dependencies:
|
|
125
76
|
- !ruby/object:Gem::Version
|
126
77
|
version: '0'
|
127
78
|
- !ruby/object:Gem::Dependency
|
128
|
-
name:
|
129
|
-
requirement: !ruby/object:Gem::Requirement
|
130
|
-
none: false
|
131
|
-
requirements:
|
132
|
-
- - ! '>='
|
133
|
-
- !ruby/object:Gem::Version
|
134
|
-
version: '0'
|
135
|
-
type: :development
|
136
|
-
prerelease: false
|
137
|
-
version_requirements: !ruby/object:Gem::Requirement
|
138
|
-
none: false
|
139
|
-
requirements:
|
140
|
-
- - ! '>='
|
141
|
-
- !ruby/object:Gem::Version
|
142
|
-
version: '0'
|
143
|
-
- !ruby/object:Gem::Dependency
|
144
|
-
name: builder
|
145
|
-
requirement: !ruby/object:Gem::Requirement
|
146
|
-
none: false
|
147
|
-
requirements:
|
148
|
-
- - ! '>='
|
149
|
-
- !ruby/object:Gem::Version
|
150
|
-
version: '0'
|
151
|
-
type: :development
|
152
|
-
prerelease: false
|
153
|
-
version_requirements: !ruby/object:Gem::Requirement
|
154
|
-
none: false
|
155
|
-
requirements:
|
156
|
-
- - ! '>='
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
version: '0'
|
159
|
-
- !ruby/object:Gem::Dependency
|
160
|
-
name: rake
|
79
|
+
name: yard
|
161
80
|
requirement: !ruby/object:Gem::Requirement
|
162
81
|
none: false
|
163
82
|
requirements:
|
@@ -173,7 +92,7 @@ dependencies:
|
|
173
92
|
- !ruby/object:Gem::Version
|
174
93
|
version: '0'
|
175
94
|
- !ruby/object:Gem::Dependency
|
176
|
-
name:
|
95
|
+
name: redcarpet
|
177
96
|
requirement: !ruby/object:Gem::Requirement
|
178
97
|
none: false
|
179
98
|
requirements:
|
@@ -188,38 +107,21 @@ dependencies:
|
|
188
107
|
- - ! '>='
|
189
108
|
- !ruby/object:Gem::Version
|
190
109
|
version: '0'
|
191
|
-
- !ruby/object:Gem::Dependency
|
192
|
-
name: nokogiri
|
193
|
-
requirement: !ruby/object:Gem::Requirement
|
194
|
-
none: false
|
195
|
-
requirements:
|
196
|
-
- - ! '>='
|
197
|
-
- !ruby/object:Gem::Version
|
198
|
-
version: '0'
|
199
|
-
type: :runtime
|
200
|
-
prerelease: false
|
201
|
-
version_requirements: !ruby/object:Gem::Requirement
|
202
|
-
none: false
|
203
|
-
requirements:
|
204
|
-
- - ! '>='
|
205
|
-
- !ruby/object:Gem::Version
|
206
|
-
version: '0'
|
207
110
|
description: Generate and validate page objects with this page object factory for
|
208
111
|
Selenium.
|
209
|
-
email:
|
112
|
+
email:
|
113
|
+
- ssims98@gmail.com
|
210
114
|
executables: []
|
211
115
|
extensions: []
|
212
|
-
extra_rdoc_files:
|
213
|
-
- LICENSE
|
214
|
-
- README.md
|
116
|
+
extra_rdoc_files: []
|
215
117
|
files:
|
118
|
+
- .gitignore
|
216
119
|
- .rvmrc
|
217
120
|
- Changelog.md
|
218
121
|
- Gemfile
|
219
122
|
- LICENSE
|
220
123
|
- README.md
|
221
124
|
- Rakefile
|
222
|
-
- VERSION
|
223
125
|
- features/custom_generator.feature
|
224
126
|
- features/generate_page_object.feature
|
225
127
|
- features/step_definitions/custom_generator_steps.rb
|
@@ -231,25 +133,16 @@ files:
|
|
231
133
|
- lib/selenium_fury.rb
|
232
134
|
- lib/selenium_fury/common/page_parser.rb
|
233
135
|
- lib/selenium_fury/common/selenium_api_chooser.rb
|
234
|
-
- lib/selenium_fury/selenium_client/create_selenium_client_driver.rb
|
235
|
-
- lib/selenium_fury/selenium_client/custom_generator.rb
|
236
|
-
- lib/selenium_fury/selenium_client/locator_finder.rb
|
237
|
-
- lib/selenium_fury/selenium_client/page_generator.rb
|
238
|
-
- lib/selenium_fury/selenium_client/page_validator.rb
|
239
136
|
- lib/selenium_fury/selenium_web_driver/create_selenium_web_driver.rb
|
240
137
|
- lib/selenium_fury/selenium_web_driver/element_finder.rb
|
241
138
|
- lib/selenium_fury/selenium_web_driver/page_generator.rb
|
242
139
|
- lib/selenium_fury/selenium_web_driver/page_object.rb
|
243
140
|
- lib/selenium_fury/selenium_web_driver/page_object_components.rb
|
244
141
|
- lib/selenium_fury/selenium_web_driver/page_validator.rb
|
142
|
+
- lib/selenium_fury/version.rb
|
245
143
|
- selenium_fury.gemspec
|
246
144
|
- spec/common/page_parser_spec.rb
|
247
145
|
- spec/common/selenium_api_chooser_spec.rb
|
248
|
-
- spec/selenium_client/custom_generators_spec.rb
|
249
|
-
- spec/selenium_client/locator_finder_spec.rb
|
250
|
-
- spec/selenium_client/page_generator_spec.rb
|
251
|
-
- spec/selenium_client/page_validator_spec.rb
|
252
|
-
- spec/selenium_client/test_page_rc_spec.rb
|
253
146
|
- spec/selenium_web_driver/element_finder_spec.rb
|
254
147
|
- spec/selenium_web_driver/page_generator_spec.rb
|
255
148
|
- spec/selenium_web_driver/page_object_spec.rb
|
@@ -258,7 +151,6 @@ files:
|
|
258
151
|
- spec/test_page/test_page.html
|
259
152
|
- spec/test_page/test_page.rb
|
260
153
|
- spec/test_page/test_page_custom_generator_configuration.rb
|
261
|
-
- spec/test_page/test_page_rc.rb
|
262
154
|
homepage: https://github.com/scottcsims/SeleniumFury
|
263
155
|
licenses: []
|
264
156
|
post_install_message:
|
@@ -271,9 +163,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
271
163
|
- - ! '>='
|
272
164
|
- !ruby/object:Gem::Version
|
273
165
|
version: '0'
|
274
|
-
segments:
|
275
|
-
- 0
|
276
|
-
hash: -4400658377398298336
|
277
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
278
167
|
none: false
|
279
168
|
requirements:
|
@@ -285,12 +174,24 @@ rubyforge_project:
|
|
285
174
|
rubygems_version: 1.8.24
|
286
175
|
signing_key:
|
287
176
|
specification_version: 3
|
288
|
-
summary: Selenium
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
177
|
+
summary: Generate Selenium Page Objects
|
178
|
+
test_files:
|
179
|
+
- features/custom_generator.feature
|
180
|
+
- features/generate_page_object.feature
|
181
|
+
- features/step_definitions/custom_generator_steps.rb
|
182
|
+
- features/step_definitions/generate_page_object_steps.rb
|
183
|
+
- features/step_definitions/validate_page_object_steps.rb
|
184
|
+
- features/support/env.rb
|
185
|
+
- features/support/hooks.rb
|
186
|
+
- features/validate_page_object.feature
|
187
|
+
- spec/common/page_parser_spec.rb
|
188
|
+
- spec/common/selenium_api_chooser_spec.rb
|
189
|
+
- spec/selenium_web_driver/element_finder_spec.rb
|
190
|
+
- spec/selenium_web_driver/page_generator_spec.rb
|
191
|
+
- spec/selenium_web_driver/page_object_spec.rb
|
192
|
+
- spec/selenium_web_driver/page_validator_spec.rb
|
193
|
+
- spec/spec_helper.rb
|
194
|
+
- spec/test_page/test_page.html
|
195
|
+
- spec/test_page/test_page.rb
|
196
|
+
- spec/test_page/test_page_custom_generator_configuration.rb
|
197
|
+
has_rdoc:
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.6.1
|
@@ -1,38 +0,0 @@
|
|
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 SeleniumClient
|
18
|
-
module CreateSeleniumClientDriver
|
19
|
-
# @return [Selenium::Client::Driver]
|
20
|
-
def browser
|
21
|
-
return @browser
|
22
|
-
end
|
23
|
-
|
24
|
-
# @param url [string]
|
25
|
-
# @return [Selenium::Client::Driver]
|
26
|
-
def create_selenium_driver(url)
|
27
|
-
|
28
|
-
@browser = Selenium::Client::Driver.new(
|
29
|
-
:host => ENV['HOST'] || "localhost",
|
30
|
-
:port => 4444,
|
31
|
-
:browser => ENV['SELENIUM_RC_BROWSER'] || "*firefox",
|
32
|
-
:url => url,
|
33
|
-
:timeout_in_second => 60)
|
34
|
-
end
|
35
|
-
alias_method :create_selenium_client_driver, :create_selenium_driver
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,65 +0,0 @@
|
|
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 SeleniumClient
|
18
|
-
module CustomGenerator
|
19
|
-
# Use a custom configuration object to define a location strategy for a locators name and value
|
20
|
-
# @param [Hash] options the options to use with a custom generator.
|
21
|
-
# @option opts [CustomConfiguration] :custom_configuration a class that explains how to parse the page
|
22
|
-
# @option opts [String] :browser the selenium driver
|
23
|
-
# @option opts [String] :html html from the page under test
|
24
|
-
def custom_generator(options)
|
25
|
-
custom_configuration = options[:custom_configuration]
|
26
|
-
browser = options[:browser]
|
27
|
-
if !browser.nil?
|
28
|
-
html = browser.get_html_source
|
29
|
-
else
|
30
|
-
html = options[:html]
|
31
|
-
end
|
32
|
-
doc = Nokogiri::HTML(html)
|
33
|
-
html_menu_elements ={}
|
34
|
-
doc.css(custom_configuration.selector).each do |nokogiri_element|
|
35
|
-
custom_configuration.nokogiri_element = nokogiri_element
|
36
|
-
puts "Html element is #{nokogiri_element}" if $DEBUG
|
37
|
-
generated_name = clean_attribute_name(custom_configuration.name)
|
38
|
-
puts "generated name is #{generated_name}" if $DEBUG
|
39
|
-
generated_value = custom_configuration.value
|
40
|
-
puts "generated value is #{generated_value}" if $DEBUG
|
41
|
-
puts "@#{generated_name} = \"#{generated_value}\"" if $DEBUG
|
42
|
-
html_menu_elements[generated_name]= generated_value
|
43
|
-
end
|
44
|
-
return print_selenium_client_page_object(html_menu_elements)
|
45
|
-
end
|
46
|
-
|
47
|
-
# Parse the html attribute to a ruby variable
|
48
|
-
# @return [String]
|
49
|
-
# @param attribute_name [String] the html id,name, or title of an element
|
50
|
-
def clean_attribute_name(attribute_name)
|
51
|
-
attribute_name.gsub!('input-', '')
|
52
|
-
attribute_name.gsub!('select-', '')
|
53
|
-
attribute_name.gsub!(/([A-Z]+)/, '_\1')
|
54
|
-
attribute_name.gsub!('\\', '')
|
55
|
-
attribute_name.gsub!(' ', '_')
|
56
|
-
attribute_name.gsub!('.', '_')
|
57
|
-
attribute_name.gsub!('-', '_')
|
58
|
-
attribute_name.gsub!('__', '_')
|
59
|
-
attribute_name.gsub!(/^_/, '')
|
60
|
-
attribute_name = attribute_name.to_s.downcase
|
61
|
-
return attribute_name
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,69 +0,0 @@
|
|
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 SeleniumClient
|
18
|
-
class LocatorFinder
|
19
|
-
def initialize (nokogiri_elements)
|
20
|
-
@nokogiri_elements=nokogiri_elements
|
21
|
-
@valid_locators=["id", "name", "title"]
|
22
|
-
end
|
23
|
-
|
24
|
-
attr_reader :nokogiri_elements, :valid_locators
|
25
|
-
|
26
|
-
def find_locators
|
27
|
-
locators=[]
|
28
|
-
nokogiri_elements.each do |nokogiri_element|
|
29
|
-
valid_locators.each do |valid_locator|
|
30
|
-
if nokogiri_element.get_attribute(valid_locator) != nil
|
31
|
-
locators.push(nokogiri_element.get_attribute(valid_locator))
|
32
|
-
break
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
return locators
|
37
|
-
end
|
38
|
-
|
39
|
-
def page_object_attributes
|
40
|
-
locators=find_locators
|
41
|
-
object_attributes ={}
|
42
|
-
locators.each do |locator|
|
43
|
-
name=attribute_name(locator)
|
44
|
-
object_attributes[name] = locator
|
45
|
-
end
|
46
|
-
return object_attributes
|
47
|
-
end
|
48
|
-
|
49
|
-
def attribute_name name
|
50
|
-
if !name.nil?
|
51
|
-
find_and_replace_patterns = [[/([A-Z]+)/, '_\1'],
|
52
|
-
['input-', ''],
|
53
|
-
['select-', ''],
|
54
|
-
['\\', ''],
|
55
|
-
[' ', '_'],
|
56
|
-
['.', '_'],
|
57
|
-
['-', '_'],
|
58
|
-
['__', '_']
|
59
|
-
]
|
60
|
-
find_and_replace_patterns.each do |pattern|
|
61
|
-
name=name.gsub(pattern[0], pattern[1])
|
62
|
-
end
|
63
|
-
name=name.to_s.downcase
|
64
|
-
end
|
65
|
-
return name
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
@@ -1,64 +0,0 @@
|
|
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 SeleniumClient
|
18
|
-
module PageGenerator
|
19
|
-
|
20
|
-
# @return [String]
|
21
|
-
# @param html_elements [Hash]
|
22
|
-
def print_selenium_client_page_object(html_elements)
|
23
|
-
result = ""
|
24
|
-
result += "found (#{html_elements.length} elements)\n"
|
25
|
-
result += "class YourPageFile\n"
|
26
|
-
result += "\tdef initialize *browser\n\t\t@browser = *browser\n"
|
27
|
-
html_elements.keys.sort.each do |key|
|
28
|
-
result += "\t\t@#{key} = \"#{html_elements[key]}\"\n"
|
29
|
-
end
|
30
|
-
result += "\tend\n"
|
31
|
-
count=1
|
32
|
-
html_elements.keys.sort.each do |key|
|
33
|
-
if count == 1
|
34
|
-
result += "\tattr_accessor :browser, "
|
35
|
-
end
|
36
|
-
if count % 5 == 0
|
37
|
-
result += "\n\t"
|
38
|
-
end
|
39
|
-
if count != html_elements.length
|
40
|
-
result += ":#{key}, "
|
41
|
-
else
|
42
|
-
result += ":#{key}"
|
43
|
-
end
|
44
|
-
count = count + 1
|
45
|
-
end
|
46
|
-
result += "\n\nend"
|
47
|
-
result += "\n"
|
48
|
-
$stdout.puts result
|
49
|
-
return result
|
50
|
-
end
|
51
|
-
|
52
|
-
|
53
|
-
# @param browser [Selenium::Client::Driver]
|
54
|
-
def get_source_and_print_elements(browser)
|
55
|
-
html =browser.get_html_source
|
56
|
-
nokogiri_elements = SeleniumFury::PageParser.new(html).nokogiri_elements
|
57
|
-
raise "The generator did not find nokogiri elements" unless nokogiri_elements
|
58
|
-
page_object_attributes = SeleniumFury::SeleniumClient::LocatorFinder.new(nokogiri_elements).page_object_attributes
|
59
|
-
raise "The generator did not find page object attributes" if page_object_attributes.empty?
|
60
|
-
print_selenium_client_page_object page_object_attributes
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
@@ -1,92 +0,0 @@
|
|
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 SeleniumClient
|
18
|
-
module PageValidator
|
19
|
-
@found_missing_locators
|
20
|
-
attr_accessor :found_missing_locators
|
21
|
-
# @param page_file_class [Class] The page object class you want to test
|
22
|
-
# @param live_url [String] the url of the page your testing
|
23
|
-
def check_page_file_class(page_file_class, live_url = nil)
|
24
|
-
raise "cannot access the selenium client driver" if browser.nil?
|
25
|
-
missing_locators={}
|
26
|
-
puts "Validating the #{page_file_class} class"
|
27
|
-
#all initialize methods of page files should have *browser specified as the argument. This is an optional argument
|
28
|
-
test_page = page_file_class.new(browser)
|
29
|
-
raise "The test class is nil" if test_page.nil?
|
30
|
-
#skip the open if we don't need to open the url again
|
31
|
-
if live_url
|
32
|
-
puts "Opening #{browser.browser_url}/#{live_url}" #if $DEBUG
|
33
|
-
browser.open live_url
|
34
|
-
end
|
35
|
-
|
36
|
-
#check for instance methods and execute.
|
37
|
-
verify_instance_variables(test_page, missing_locators) if test_page.instance_variables.length > 0
|
38
|
-
|
39
|
-
@found_missing_locators=missing_locators
|
40
|
-
return print_missing_locators(missing_locators)
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
# @param missing_locators [Hash] locator name and values
|
45
|
-
def print_missing_locators missing_locators
|
46
|
-
puts "Missing locators are " if missing_locators != {}
|
47
|
-
missing_locators.each_pair do |locator_name, locator_value|
|
48
|
-
puts " #{locator_name} => #{locator_value}"
|
49
|
-
end
|
50
|
-
raise "found missing locators" unless missing_locators.empty?
|
51
|
-
end
|
52
|
-
|
53
|
-
def attribute_name_filter locator_name
|
54
|
-
#Add names of attributes to filter
|
55
|
-
skip_words=["browser"]
|
56
|
-
|
57
|
-
skip_words=skip_words+@known_missing_locators if !@known_missing_locators.nil?
|
58
|
-
|
59
|
-
return skip_words.include?(locator_name)
|
60
|
-
end
|
61
|
-
|
62
|
-
# @param test_page [Object] an instantiated page object
|
63
|
-
# @param missing_locators [Hash]
|
64
|
-
def verify_instance_variables(test_page, missing_locators)
|
65
|
-
#test_page.print_properties browser
|
66
|
-
test_page.instance_variables.each do |locator_name|
|
67
|
-
locator_name_string = locator_name.to_s
|
68
|
-
#prepare the locator values
|
69
|
-
locator_name_string.slice!(0)
|
70
|
-
|
71
|
-
if attribute_name_filter(locator_name_string)
|
72
|
-
puts "Skipping validation for #{locator_name}"
|
73
|
-
next
|
74
|
-
end
|
75
|
-
|
76
|
-
# I don't understand where this would ever be true, but I'll leave it I guess?
|
77
|
-
# next if (test_page.method(locator_name_string.to_sym).class.to_s != "String")
|
78
|
-
puts " Validating the #{locator_name} page element locator" #chomp the @ sign off of the method name.
|
79
|
-
locator_value = test_page.method(locator_name_string.to_sym) # Create the reference to the get method of the instance variable
|
80
|
-
begin
|
81
|
-
browser.wait_for_element(locator_value.call, {:timeout_in_seconds => "5"})
|
82
|
-
rescue
|
83
|
-
puts " ----------------------------------- Could not find '#{locator_name}'"
|
84
|
-
missing_locators[locator_name_string]= locator_value.call
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
describe TestPageCustomGeneratorConfiguration do
|
3
|
-
|
4
|
-
it "should generate the test page link locators" do
|
5
|
-
create_selenium_driver TEST_PAGE_URL
|
6
|
-
browser.start_new_browser_session
|
7
|
-
puts "Testing #{browser.browser_url} on #{browser.browser_string} "
|
8
|
-
browser.open TEST_PAGE_URL
|
9
|
-
test_page_custom_generator_configuration = TestPageCustomGeneratorConfiguration.new
|
10
|
-
result = custom_generator(:browser => browser,
|
11
|
-
:custom_configuration => test_page_custom_generator_configuration)
|
12
|
-
result.should == custom_generator_result
|
13
|
-
end
|
14
|
-
let(:custom_generator_result){
|
15
|
-
<<EOF
|
16
|
-
found (3 elements)
|
17
|
-
class YourPageFile
|
18
|
-
def initialize *browser
|
19
|
-
@browser = *browser
|
20
|
-
@link_1 = "link111111"
|
21
|
-
@link_2 = "link222222"
|
22
|
-
@link_3 = "link333333"
|
23
|
-
end
|
24
|
-
attr_accessor :browser, :link_1, :link_2, :link_3
|
25
|
-
|
26
|
-
end
|
27
|
-
EOF
|
28
|
-
}
|
29
|
-
end
|
@@ -1,20 +0,0 @@
|
|
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,11 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
describe SeleniumFury::SeleniumClient::PageGenerator do
|
3
|
-
it "should find elements on the HomeAway advanced search page" do
|
4
|
-
create_selenium_driver TEST_PAGE_URL
|
5
|
-
browser.start_new_browser_session
|
6
|
-
puts "Testing #{browser.browser_url} on #{browser.browser_string} "
|
7
|
-
browser.open TEST_PAGE_URL
|
8
|
-
result = generate(browser)
|
9
|
-
result.should include("found (15 elements)")
|
10
|
-
end
|
11
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
describe SeleniumFury::SeleniumClient::PageValidator do
|
3
|
-
it "should validate the elements contained on the TestPage page object" do
|
4
|
-
create_selenium_driver TEST_PAGE_URL
|
5
|
-
browser.start_new_browser_session
|
6
|
-
validate(TestPageRc, TEST_PAGE_URL)
|
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 TEST_PAGE_URL
|
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
|
-
validate(MissingLocators, TEST_PAGE_URL)
|
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
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
describe TestPageRc do
|
3
|
-
it "should use elements on the TestPageRc" do
|
4
|
-
create_selenium_driver TEST_PAGE_URL
|
5
|
-
browser.start_new_browser_session
|
6
|
-
puts "Testing #{browser.browser_url} on #{browser.browser_string} "
|
7
|
-
browser.open TEST_PAGE_URL
|
8
|
-
test_page = TestPageRc.new(browser)
|
9
|
-
browser.click test_page.input_message
|
10
|
-
browser.type test_page.input_message, "this is awesome"
|
11
|
-
browser.click test_page.input_msg_button
|
12
|
-
browser.text("message").should == "this is awesome"
|
13
|
-
end
|
14
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
class TestPageRc
|
2
|
-
def initialize *browser
|
3
|
-
@browser = *browser
|
4
|
-
@form = "form"
|
5
|
-
@input_button = "input_button"
|
6
|
-
@input_checkbox = "input_checkbox"
|
7
|
-
@input_file = "input_file"
|
8
|
-
@input_hidden = "input_hidden"
|
9
|
-
@input_image = "input_image"
|
10
|
-
@input_message = "input_message"
|
11
|
-
@input_msg_button = "input_msg_button"
|
12
|
-
@input_password = "input_password"
|
13
|
-
@input_radio = "input_radio"
|
14
|
-
@input_reset = "input_reset"
|
15
|
-
@input_submit = "input_submit"
|
16
|
-
@input_text = "input_text"
|
17
|
-
@select = "select"
|
18
|
-
@textarea = "textarea"
|
19
|
-
end
|
20
|
-
attr_accessor :browser, :form, :input_button, :input_checkbox, :input_file,
|
21
|
-
:input_hidden, :input_image, :input_message, :input_msg_button, :input_password,
|
22
|
-
:input_radio, :input_reset, :input_submit, :input_text, :select,
|
23
|
-
:textarea
|
24
|
-
|
25
|
-
end
|