selenium_fury 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -8,27 +8,47 @@ require 'rspec/core/rake_task'
8
8
  require 'yard'
9
9
  require 'yard/rake/yardoc_task'
10
10
 
11
+ require 'cucumber'
12
+ require 'cucumber/rake/task'
13
+
14
+
11
15
  RSpec::Core::RakeTask.new(:spec)
12
16
 
13
- task :default => :spec
17
+ Cucumber::Rake::Task.new(:feature) do |task|
18
+ task.cucumber_opts = ["features"]
19
+ end
14
20
 
15
- Jeweler::Tasks.new do |gem|
16
- gem.name = "selenium_fury"
17
- gem.description = %q{Generate and validate page objects with this page object factory for Selenium.}
18
- 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
21
+ task :default do
22
+ system "rake -T"
23
+ end
24
+
25
+ YARD::Rake::YardocTask.new do |t|
26
+ t.files = ['lib/**/*.rb']
27
+ end
28
+
29
+ namespace :gem do
30
+ Jeweler::Tasks.new do |gem|
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
19
34
  a page under test with attributes of all the locators selenium needs to run tests on the page and methods that represent
20
35
  actions that can be performed on the page.
21
36
 
22
37
  You use the generator to build the page files. After the page has been updated you can use the validator to go through
23
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.
24
39
  If there are missing locators you can then rerun the generator to generate new selenium locators for your page. http://www.scottcsims.com}
25
- gem.email = "ssims98@gmail.com"
26
- gem.authors = ["Scott Sims","Tim Tischler"]
27
- gem.homepage = "https://github.com/scottcsims/SeleniumFury"
28
- gem.version = '0.5.7'
29
- gem.add_dependency 'nokogiri'
30
- end
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
31
45
 
32
- YARD::Rake::YardocTask.new do |t|
33
- t.files = ['lib/**/*.rb']
34
- end
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
54
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.5.8
@@ -19,10 +19,10 @@ module SeleniumFury
19
19
 
20
20
  # @return [String]
21
21
  # @param page_object_attributes [Hash]
22
- def print_selenium_web_driver_page_object(page_object_attributes)
22
+ def print_selenium_web_driver_page_object(page_object_attributes,class_name='YourPageFile')
23
23
  result = ""
24
24
  result += "found (#{page_object_attributes.length} elements)\n"
25
- result += "class YourPageFile < PageObject\n"
25
+ result += "class #{class_name} < PageObject\n"
26
26
  page_object_attributes.keys.sort.each do |attribute_name|
27
27
  result += "\t\telement :#{attribute_name}, {:#{page_object_attributes[attribute_name].keys[0]} => \"#{page_object_attributes[attribute_name].values[0]}\"}\n"
28
28
  end
@@ -31,8 +31,22 @@ module SeleniumFury
31
31
  return result
32
32
  end
33
33
 
34
+ # @param page_object_attributes [Hash]
35
+ # @param class_name [String]
36
+ # @return [PageObject]
37
+ def selenium_web_driver_page_object(page_object_attributes, class_name)
38
+ klass = Class.new(PageObject) {
39
+ page_object_attributes.keys.sort.each do |attribute_name|
40
+ element attribute_name.to_sym, {page_object_attributes[attribute_name].keys[0] => page_object_attributes[attribute_name].values[0]}
41
+ end
42
+ }
43
+ print_selenium_web_driver_page_object page_object_attributes,class_name
44
+ return Object.const_set(class_name, klass).new(driver)
34
45
 
35
- # @param browser [Selenium::WebDriver::Driver]
46
+ end
47
+
48
+ # @param driver [Selenium::WebDriver::Driver]
49
+ # @return [String]
36
50
  def web_driver_generate(driver)
37
51
  html =driver.page_source
38
52
  nokogiri_elements = SeleniumFury::PageParser.new(html).nokogiri_elements
@@ -42,6 +56,17 @@ module SeleniumFury
42
56
  print_selenium_web_driver_page_object page_object_attributes
43
57
  end
44
58
 
59
+ # @param driver [Selenium::WebDriver::Driver]
60
+ # @param class_name [string]
61
+ # @return [PageObject]
62
+ def get_page_object(driver, class_name)
63
+ html =driver.page_source
64
+ nokogiri_elements = SeleniumFury::PageParser.new(html).nokogiri_elements
65
+ raise "The generator did not find nokogiri elements" unless nokogiri_elements
66
+ page_object_attributes = SeleniumFury::SeleniumWebDriver::ElementFinder.new(nokogiri_elements).web_driver_page_object_attributes
67
+ raise "The generator did not find page object attributes" if page_object_attributes.empty?
68
+ selenium_web_driver_page_object(page_object_attributes, class_name)
69
+ end
45
70
  end
46
71
  end
47
72
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "selenium_fury"
8
- s.version = "0.5.6"
8
+ s.version = "0.5.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Scott Sims", "Tim Tischler"]
12
- s.date = "2011-10-27"
12
+ s.date = "2012-01-26"
13
13
  s.description = "Generate and validate page objects with this page object factory for Selenium."
14
14
  s.email = "ssims98@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -20,10 +20,10 @@ Gem::Specification.new do |s|
20
20
  ".rvmrc",
21
21
  "Changelog.md",
22
22
  "Gemfile",
23
- "Gemfile.lock",
24
23
  "LICENSE",
25
24
  "README.md",
26
25
  "Rakefile",
26
+ "VERSION",
27
27
  "features/custom_generator.feature",
28
28
  "features/generate_page_object.feature",
29
29
  "features/step_definitions/custom_generator_steps.rb",
@@ -67,7 +67,7 @@ Gem::Specification.new do |s|
67
67
  ]
68
68
  s.homepage = "https://github.com/scottcsims/SeleniumFury"
69
69
  s.require_paths = ["lib"]
70
- s.rubygems_version = "1.8.10"
70
+ s.rubygems_version = "1.8.11"
71
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"
72
72
 
73
73
  if s.respond_to? :specification_version then
@@ -6,4 +6,10 @@ describe SeleniumFury::SeleniumWebDriver::PageGenerator do
6
6
  result.should include("found (43 elements)")
7
7
  result.should include("element :adv_search_form, {:id => \"adv-search-form\"}")
8
8
  end
9
+ it "should return a page object" do
10
+ launch_web_driver("http://www.homeaway.com/searchForm")
11
+ search_form = get_page_object(driver,"SearchForm")
12
+ search_form.should be_instance_of SearchForm
13
+ search_form.special_offers.should be_instance_of Selenium::WebDriver::Element
14
+ end
9
15
  end
@@ -7,24 +7,25 @@ describe PageObject do
7
7
  driver.navigate.to "http://www.scottcsims"
8
8
  driver.title.should == "Scott Sims"
9
9
  end
10
-
10
+ it "should have elements" do
11
+ launch_web_driver "http://www.homeaway.com"
12
+ search=get_page_object(driver, 'Search')
13
+ search.class.elements.should_not be_nil
14
+ search.class.elements.should have(8).elements
15
+ search.method(search.class.elements[0]).call.class.should == Selenium::WebDriver::Element
16
+ end
11
17
  it 'should return a web_driver element when an attribute is accessed' do
12
- launch_web_driver "http://www.homeaway.com/vacation-rental/p254680"
13
- inquiry_side_bar = InquirySideBar.new(driver)
14
- inquiry_side_bar.first_name.class.should == Selenium::WebDriver::Element
15
- inquiry_side_bar.first_name.send_keys Faker::Name.first_name
18
+ launch_web_driver "http://www.homeaway.com"
19
+ search=get_page_object(driver, 'Search')
20
+ search.start_date_input.class.should == Selenium::WebDriver::Element
21
+ search.search_keywords Faker::Lorem.words
16
22
  end
17
23
 
18
24
  it "should raise an exception when the element can't be found'" do
19
- launch_web_driver "http://www.homeaway.com/vacation-rental/p254680"
20
- inquiry_side_bar = InquirySideBar.new(driver)
21
- InquirySideBar.element(:not_a_element, {:id =>"not a element"})
22
- begin
23
- inquiry_side_bar.not_a_element
24
- rescue Exception => e
25
- e.message.should == "Could not find element not_a_element"
26
- end
27
- e.should_not be_nil, "we were expecting an exception"
25
+ launch_web_driver "http://www.homeaway.com"
26
+ search=get_page_object(driver, 'Search')
27
+ Search.element(:not_a_element, {:id =>"not a element"})
28
+ lambda{search.not_a_element}.should(raise_exception(RuntimeError,"Could not find element not_a_element"))
28
29
  end
29
30
 
30
31
  it "should have a property page that contains a inquiry sidebar" do
@@ -32,18 +33,12 @@ describe PageObject do
32
33
  property_page = PropertyPage.new(driver)
33
34
  property_page.should_not be_nil
34
35
  property_page.inquiry_side_bar.should_not be_nil
35
- property_page.inquiry_side_bar.first_name.class.should == Selenium::WebDriver::Element
36
36
  end
37
37
 
38
38
  it "should have an error if a non page object class is passed to page method" do
39
39
  property_page = PropertyPage.new()
40
40
  PropertyPage.page(:not_a_page, String)
41
- begin
42
- property_page.not_a_page
43
- rescue Exception => e
44
- e.message.should == "String does not inherit from PageObject"
45
- end
46
- e.should_not be_nil, "we were expecting and exception"
41
+ lambda{property_page.not_a_page}.should raise_exception(RuntimeError,"String does not inherit from PageObject")
47
42
  end
48
43
  it "should use elements on the HomeAway advanced search page" do
49
44
  launch_web_driver("http://www.homeaway.com/searchForm")
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selenium_fury
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 7
10
- version: 0.5.7
9
+ - 8
10
+ version: 0.5.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Scott Sims
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-12-09 00:00:00 Z
19
+ date: 2012-01-26 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -199,10 +199,10 @@ files:
199
199
  - .rvmrc
200
200
  - Changelog.md
201
201
  - Gemfile
202
- - Gemfile.lock
203
202
  - LICENSE
204
203
  - README.md
205
204
  - Rakefile
205
+ - VERSION
206
206
  - features/custom_generator.feature
207
207
  - features/generate_page_object.feature
208
208
  - features/step_definitions/custom_generator_steps.rb
data/Gemfile.lock DELETED
@@ -1,61 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- builder (3.0.0)
5
- childprocess (0.2.3)
6
- ffi (~> 1.0.6)
7
- cucumber (1.1.3)
8
- builder (>= 2.1.2)
9
- diff-lcs (>= 1.1.2)
10
- gherkin (~> 2.6.7)
11
- json (>= 1.4.6)
12
- term-ansicolor (>= 1.0.6)
13
- diff-lcs (1.1.3)
14
- faker (1.0.1)
15
- i18n (~> 0.4)
16
- ffi (1.0.11)
17
- gherkin (2.6.9)
18
- json (>= 1.4.6)
19
- git (1.2.5)
20
- i18n (0.6.0)
21
- jeweler (1.6.4)
22
- bundler (~> 1.0)
23
- git (>= 1.2.5)
24
- rake
25
- json (1.6.3)
26
- multi_json (1.0.4)
27
- nokogiri (1.5.0)
28
- rake (0.9.2.2)
29
- rdiscount (1.6.8)
30
- rspec (2.7.0)
31
- rspec-core (~> 2.7.0)
32
- rspec-expectations (~> 2.7.0)
33
- rspec-mocks (~> 2.7.0)
34
- rspec-core (2.7.1)
35
- rspec-expectations (2.7.0)
36
- diff-lcs (~> 1.1.2)
37
- rspec-mocks (2.7.0)
38
- rubyzip (0.9.5)
39
- selenium-webdriver (2.15.0)
40
- childprocess (>= 0.2.1)
41
- ffi (~> 1.0.9)
42
- multi_json (~> 1.0.4)
43
- rubyzip
44
- term-ansicolor (1.0.7)
45
- yard (0.7.4)
46
-
47
- PLATFORMS
48
- ruby
49
-
50
- DEPENDENCIES
51
- builder
52
- bundler
53
- cucumber
54
- faker
55
- jeweler
56
- nokogiri
57
- rake
58
- rdiscount
59
- rspec
60
- selenium-webdriver
61
- yard