cello 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/.gitignore +3 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +8 -0
  4. data/LICENCE +12 -0
  5. data/README.md +98 -0
  6. data/Rakefile +9 -0
  7. data/cello.gemspec +29 -0
  8. data/examples/bugbang/flows/search.feature +19 -0
  9. data/examples/bugbang/flows/step_definitions/search.rb +43 -0
  10. data/examples/bugbang/flows/support/env.rb +1 -0
  11. data/examples/bugbang/pages/home.rb +27 -0
  12. data/features/access_element.feature +22 -0
  13. data/features/checkbox.feature +21 -0
  14. data/features/choose_browser.feature +14 -0
  15. data/features/element.feature +71 -0
  16. data/features/fire_event.feature +12 -0
  17. data/features/get_html_atributes.feature +6 -0
  18. data/features/pages/input_fields.rb +18 -0
  19. data/features/site/inputs.html +21 -0
  20. data/features/step_definitions/access_element.rb +24 -0
  21. data/features/step_definitions/checkbox.rb +24 -0
  22. data/features/step_definitions/common_steps.rb +27 -0
  23. data/features/step_definitions/element.rb +49 -0
  24. data/features/step_definitions/textarea.rb +43 -0
  25. data/features/step_definitions/textfield.rb +43 -0
  26. data/features/support/env.rb +1 -0
  27. data/features/textarea.feature +48 -0
  28. data/features/textfield.feature +49 -0
  29. data/lib/cello/Checkbox_helper.rb +20 -0
  30. data/lib/cello/button_helper.rb +8 -0
  31. data/lib/cello/config/cucumber_config.rb +13 -0
  32. data/lib/cello/div_helper.rb +8 -0
  33. data/lib/cello/element_helper.rb +54 -0
  34. data/lib/cello/hidden_helper.rb +8 -0
  35. data/lib/cello/link_helper.rb +8 -0
  36. data/lib/cello/page.rb +44 -0
  37. data/lib/cello/radio_helper.rb +11 -0
  38. data/lib/cello/select_helper.rb +14 -0
  39. data/lib/cello/span_helper.rb +8 -0
  40. data/lib/cello/textarea_helper.rb +35 -0
  41. data/lib/cello/textfield_helper.rb +32 -0
  42. data/lib/cello/version.rb +3 -0
  43. data/lib/cello.rb +11 -0
  44. data/spec/checkbox_spec.rb +0 -0
  45. metadata +182 -0
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ *.sw*
2
+ *.lock
3
+ screenshot.png
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'selenium-webdriver'
4
+ gem 'cucumber'
5
+ gem 'rake'
6
+
7
+
8
+ gemspec
data/LICENCE ADDED
@@ -0,0 +1,12 @@
1
+ LICENCE
2
+ =======
3
+
4
+ Copyright 2012 Camilo Ribeiro cribeiro@thoughtworks.com
5
+
6
+ This file is part of Cello.
7
+
8
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
data/README.md ADDED
@@ -0,0 +1,98 @@
1
+ CELLO
2
+ =====
3
+
4
+ What?
5
+ -----
6
+ Cello is a Framework for automated UI tests based on Watir-Webdriver and Selenium-Webdriver in ruby, extended by metaprogramming and magic to implement something based on page object model and describe the behaviour with cucumber.
7
+
8
+ This framework isn't realeased or stable yet, but the concept is already done. The concept consists in a way to implement tests faster like when we record using tools like seleium IDE, but using magic and metaprogramming instead all that terrible bullshit code generated by those tools.
9
+
10
+ What a funny name :-p
11
+ ----------------------
12
+ The name is cello, not just because I love it, but because as a music composition are steps that, when syncronized guide the musician to play wonderful songs, the acceptance automated tests are steps that when syncronized guide the developer to keep coding wonderfull peaces of business value.
13
+
14
+ What is the idea?
15
+ -----------------
16
+ The core idea is based on two tecniques and a lots of ideas:
17
+ *The first one is the Page-Object Model that provide a way to make tests more maintainable
18
+ *The second one is the record but not replay that allows people without programming skills generate automated regression tests in a easier and faster way
19
+
20
+ No one technique is required, but the first one is really recommended
21
+
22
+ We still have to much work to do ( as you can see in right bellow in this document), but, if you want, you can fork it and have fun!
23
+
24
+ It's STRONGLY recommended do not use it for comercial projects, because it will change too much and we never tested it in a real project. We recomend you use it to emulate a project and, if possible, return us you example to be added on our library.
25
+
26
+
27
+ The way we choose to test our framework was . . . writing tests with it! This way we keep a stable version of it, we can overcome the limitations writing new features to cover the tests that wasn't working and build a library of examples to future users.
28
+
29
+ So, that way, if you are not a developer but a awesome QA with a little experience with code, you can help us practicing this tool in a little bit in your free time, and we will try make you happy fixing the bugs and implementing the new features you find during the time you'll spend writing tests. This examples will be storage on our repository with your name, mail, blog link or what you want.
30
+
31
+
32
+
33
+ Instructions
34
+ ==========
35
+
36
+ Developing
37
+ ----------
38
+ To develop `cello`, you are going to need [Bundler][1]
39
+
40
+ $ git clone git@github.com:camiloribeiro/cello.git
41
+ $ cd cello
42
+ $ bundle install
43
+ $ rake run
44
+
45
+ The last step launch the regression tests and it should be everything green
46
+ If you have any problems, please let us know.
47
+
48
+ [1]: http://gembundler.com
49
+
50
+ Using
51
+ -----
52
+
53
+ To use it you will need the developing env described in this document
54
+ Then you can follow the example bugbang inside the directory cello/example
55
+
56
+ Soon I will provide a new use description :)
57
+
58
+ ROADMAP
59
+ =======
60
+
61
+ 0.5 Partitura
62
+ -------------
63
+ -DSL: Based framework that consists on a metaprogramming way to create customized test methods to each single project using a new DSL to provide test methods in execution time using only one line description for each element.
64
+ -Selenium: Change watir-webdriver to selenium
65
+ -Cukes: Cucumber by nature
66
+
67
+ 1.0 Tabulatura
68
+ --------------
69
+ -Gem: Creat the cello gem that will:
70
+ *Create project
71
+ *Get a page and write the elements in the page
72
+ -No Browser: Headless browser execution
73
+
74
+ 1.5 Ocarine
75
+ -----------
76
+ -DDT: Data driven testing by nature
77
+ -No Cukes: Provide a way to work with other BDD tools
78
+ -XTest: X-browser Testing by nature
79
+
80
+ 2.0 Orquestra
81
+ -------------
82
+ -No Selenium: Provide a way to choose at least Watir or selenium
83
+ -Scala: Create a copu for scala and java users
84
+
85
+
86
+ LICENCE
87
+ =======
88
+
89
+ Copyright 2012 Camilo Ribeiro cribeiro@thoughtworks.com
90
+
91
+ This file is part of Cello.
92
+
93
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
94
+
95
+ http://www.apache.org/licenses/LICENSE-2.0
96
+
97
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
98
+
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "cucumber/rake/task"
2
+
3
+ Cucumber::Rake::Task.new(:run) do |task|
4
+ task.cucumber_opts = ["-t","~@pending","features --format pretty"]
5
+ end
6
+
7
+ Cucumber::Rake::Task.new(:wip) do |task|
8
+ task.cucumber_opts = ["-t","@wip","features"]
9
+ end
data/cello.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "cello/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "cello"
7
+ s.version = Cello::VERSION
8
+ s.authors = ["Camilo Ribeiro"]
9
+ s.email = ["cribeiro@thoughtworks.com"]
10
+ s.homepage = "http://github.com/camiloribeiro/cello"
11
+ s.summary = %q{Fast and simple Page-Object with BDD}
12
+ s.description = %q{Cello is a framework that allows automate acceptance tests using page-object}
13
+
14
+ s.rubyforge_project = "cello"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.default_executable = 'cello'
20
+
21
+ s.require_paths = ["lib"]
22
+
23
+ s.add_development_dependency 'cucumber'
24
+ s.add_development_dependency 'rake'
25
+
26
+ s.add_dependency 'cucumber'
27
+ s.add_dependency 'watir-webdriver'
28
+ s.add_dependency 'selenium-webdriver'
29
+ end
@@ -0,0 +1,19 @@
1
+ Feature: Search
2
+ As a Bug Bang reader
3
+ I want to navigate on the basic scenarios
4
+
5
+ Scenario: Basic search for common users
6
+ Given I am on The Bug Bang Theory home page
7
+ When I write "Camilo Ribeiro" on search field
8
+ And ask to search
9
+ Then I should see the follow results:
10
+ | BugBang Responde I: Horas x Qualidade (A eterna briga das empresas) |
11
+ | The Bugbang Theory |
12
+ | Penso, logo automatizo |
13
+ | The Bug Bang Theory 2.0 – Agile and Technical Testing Rocks! |
14
+
15
+ Scenario: Going to about page
16
+ Given I am on The Bug Bang Theory home page
17
+ When I go to about page
18
+ Then I should see the text "Camilo Ribeiro"
19
+
@@ -0,0 +1,43 @@
1
+ Dir[File.dirname(__FILE__) + "/../../pages/*.rb"].each do |file|
2
+ require file
3
+ end
4
+
5
+ Given /^I am on The Bug Bang Theory home page$/ do
6
+ @home = BugBang::HomePage.new
7
+ end
8
+
9
+ When /^I write "(.*?)" on search field$/ do |search_text|
10
+ @home.search_field_fill_with(search_text)
11
+ end
12
+
13
+ When /^ask to search$/ do
14
+ @home.search_button_click
15
+ end
16
+
17
+ Then /^I should see the follow results:$/ do |results|
18
+ results.hashes.each do |text|
19
+ @home.search text.to_s
20
+ end
21
+ @home.get_picture
22
+ embed 'screenshot.png', 'image/png'
23
+ @home.close
24
+ end
25
+
26
+ When /^I go to about page$/ do
27
+ @home.about_page_button_click
28
+ end
29
+
30
+ Then /^I should see the text "(.*?)"$/ do |text|
31
+ @home.search text.to_s
32
+ @home.get_picture
33
+ embed 'screenshot.png', 'image/png'
34
+ @home.close
35
+ end
36
+
37
+ Then /^I want see the the last twelve postblog session$/ do
38
+ pending # express the regexp above with the code you wish you had
39
+ end
40
+
41
+ Then /^It should be twelve links$/ do
42
+ pending # express the regexp above with the code you wish you had
43
+ end
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,27 @@
1
+ require File.join(File.dirname(__FILE__), '../../../lib/cello/page')
2
+
3
+ module BugBang
4
+ class HomePage < Cello::Structure::Page
5
+ element :search_field, :text_field, :id => 's'
6
+ element :search_button, :button, :id => 'go'
7
+ element :about_page_button, :span, :text => 'Sobre o Autor'
8
+ element :last_twelve_Posts, :div, :text => 'Ultimos 20 posts'
9
+
10
+ @@url = 'http://bugbang.com.br/'
11
+ def initialize
12
+ super(@@url)
13
+ end
14
+ end
15
+
16
+ class SearchResultPage < Cello::Structure::Page
17
+ def initialize
18
+ super(@@url)
19
+ end
20
+ end
21
+
22
+ class AboutPage < Cello::Structure::Page
23
+ def initialize
24
+ super(@@url)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,22 @@
1
+ Feature: Access elements
2
+ As developer
3
+ I want access elements in diferent ways
4
+
5
+ Scenario: Write in a element text field sing id
6
+ Given I am on a page that has a textfield
7
+ Then I should be able to write "Test" in a element using id
8
+
9
+ Scenario: Write in a element text field sing name
10
+ Given I am on a page that has a textfield
11
+ Then I should be able to write "Test" in a element using name
12
+
13
+ @pending
14
+ Scenario: Write in a element text field sing xpath
15
+ Given I am on a page that has a textfield
16
+ Then I should be able to write "Test" in a element using xpath
17
+
18
+ @pending
19
+ Scenario: Write in a element text field sing label related
20
+ Given I am on a page that has a textfield
21
+ Then I should be able to write "Test" in a element using label
22
+
@@ -0,0 +1,21 @@
1
+ Feature: Checkbox
2
+ As a developer
3
+ I want to use the element checkbox in my tests
4
+
5
+ Scenario: Checking if it is checked
6
+ Given I am on a page that has a checkbox
7
+ And There is a checkbox checked
8
+ Then I should be able to verify if it is checked
9
+
10
+ Scenario: Checking if it is uncheked
11
+ Given I am on a page that has a checkbox
12
+ Then I should be able to verify if it is unchecked
13
+
14
+ Scenario: Checking the checkbox
15
+ Given I am on a page that has a checkbox
16
+ Then I should be able to check it
17
+
18
+ Scenario: Unchekning the checkbox
19
+ Given I am on a page that has a checkbox
20
+ And There is a checkbox checked
21
+ Then I should be able to uncheck it
@@ -0,0 +1,14 @@
1
+ Feature: Choose browser
2
+ As a Developer
3
+ I want to choose the browser where I will run my tests
4
+
5
+ @pending
6
+ Scenario: Running tests on firefox
7
+ @pending
8
+ Scenario: Running tests on chrome
9
+ @pending
10
+ Scenario: Running tests on safari
11
+ @pending
12
+ Scenario: Running tests on opera
13
+ @pending
14
+ Scenario: Running tests on internet explorer
@@ -0,0 +1,71 @@
1
+ Feature: Element
2
+ As a developer
3
+ I want use element to run my tests
4
+
5
+ @pending
6
+ Scenario: Use as element and send a native watir/selenium method
7
+
8
+ Scenario: Click at the element
9
+ Given I am on a page that has a element
10
+ And that element is named as:
11
+ | checkbox |
12
+ | text_field |
13
+ | textarea |
14
+ Then I want click on this element
15
+
16
+ Scenario: Know if the element is visible
17
+ Given I am on a page that has a element
18
+ And that element is named as:
19
+ | checkbox |
20
+ | text_field |
21
+ | textarea |
22
+ Then I want know if this element is visible
23
+
24
+ Scenario: Know if the element is enable
25
+ Given I am on a page that has a element
26
+ And that element is named as:
27
+ | checkbox |
28
+ | text_field |
29
+ | textarea |
30
+ Then I want know if this element is enable
31
+
32
+ Scenario: Know if the element exists
33
+ Given I am on a page that has a element
34
+ And that element is named as:
35
+ | checkbox |
36
+ | text_field |
37
+ | textarea |
38
+ Then I want know if this element exists
39
+
40
+ Scenario: Riht click at the element
41
+ Given I am on a page that has a element
42
+ And that element is named as:
43
+ | checkbox |
44
+ | text_field |
45
+ | textarea |
46
+ Then I shoud be able to click with the right button in this element
47
+
48
+ @pending
49
+ Scenario: Wait until the element is gone
50
+ Given I am on a page that has a element
51
+ And that element is named as:
52
+ | checkbox |
53
+ | text_field |
54
+ | textarea |
55
+
56
+ @pending
57
+ Scenario: Wait until the element is present
58
+ Given I am on a page that has a element
59
+ And that element is named as:
60
+ | checkbox |
61
+ | text_field |
62
+ | textarea |
63
+
64
+ @pending
65
+ Scenario: get the location of it
66
+ Given I am on a page that has a element
67
+ And that element is named as:
68
+ | checkbox |
69
+ | text_field |
70
+ | textarea |
71
+ Then I should be able to get the location of it
@@ -0,0 +1,12 @@
1
+ Feature: Fire event
2
+ As a developer
3
+ I want to fire different events on elements
4
+
5
+ @pending
6
+ Scenario: Event mouse over
7
+ @pending
8
+ Scenario: Event mouse out
9
+ @pending
10
+ Scenario: Event mouse down
11
+ @pending
12
+ Scenario: Event mouse up
@@ -0,0 +1,6 @@
1
+ Feature: Getting HTML Atributes
2
+ As Developer
3
+ I want to get HTML atributs from elements
4
+
5
+ @pending
6
+ Scenario: Get value
@@ -0,0 +1,18 @@
1
+ require File.join(File.dirname(__FILE__), '../../lib/cello/page')
2
+
3
+ module StaticPages
4
+ module Site
5
+ class InputPage < Cello::Structure::Page
6
+ element :text_field, :text_field, :id => 'text1'
7
+ element :text_fieldname, :text_field, :name => 'text1'
8
+ element :text_fieldxpath, :text_field, :xpah, '//*[@id="text1"]'
9
+ element :checkbox, :checkbox, :id => 'check1'
10
+ element :textarea, :textarea, :id => 'area1'
11
+
12
+ @@url = 'file://' + File.dirname(__FILE__) + '/../site/inputs.html'
13
+ def initialize
14
+ super(@@url)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ <html>
2
+ <div>
3
+ This page is used to test Cello Framwork
4
+ </div>
5
+ <div>
6
+ <div> <p><b>Textfield:</b></p>
7
+ <div>Textfield with id text1</div><div> <input id='text1' type='text'></div>
8
+ <div>Textfield with name text1</div><div> <input name='text1' type='text'></div>
9
+ </div>
10
+ </div>
11
+ <div>
12
+ <div> <p><b>Simple Checkbox:</b></p>
13
+ <div>Checkbox with id check1</div><div> <input id='check1' type='checkbox'></div>
14
+ </div>
15
+ </div>
16
+ <div>
17
+ <div> <p><b>TextArea:</b></p>
18
+ <div>Textarea with id area1</div><div> <textarea id='area1'></textarea></div>
19
+ </div>
20
+ </div>
21
+ </html>
@@ -0,0 +1,24 @@
1
+ Dir[File.dirname(__FILE__) + "/../../pages/*.rb"].each do |file|
2
+ require file
3
+ end
4
+
5
+ Then /^I should be able to write "(.*?)" in a element using id$/ do |text|
6
+ @page.text_field_fill_with(text)
7
+ @page.close
8
+ end
9
+
10
+ Then /^I should be able to write "(.*?)" in a element using name$/ do |text|
11
+ @page.text_fieldname_fill_with(text)
12
+ @page.close
13
+ end
14
+
15
+ Then /^I should be able to write "(.*?)" in a element using label$/ do |text|
16
+ #pending
17
+ end
18
+
19
+ Then /^I should be able to write "(.*?)" in a element using xpath$/ do |text|
20
+ #pending
21
+ @page.text_fieldxpath_fill_with(text)
22
+ end
23
+
24
+
@@ -0,0 +1,24 @@
1
+ Dir[File.dirname(__FILE__) + "/../../pages/*.rb"].each do |file|
2
+ require file
3
+ end
4
+
5
+ Then /^I should be able to verify if it is checked$/ do
6
+ @page.checkbox_is_checked?
7
+ @page.close
8
+ end
9
+
10
+ Then /^I should be able to verify if it is unchecked$/ do
11
+ @page.checkbox_is_unchecked?
12
+ @page.close
13
+ end
14
+
15
+ Then /^I should be able to check it$/ do
16
+ @page.checkbox_check
17
+ @page.close
18
+ end
19
+
20
+ Then /^I should be able to uncheck it$/ do
21
+ @page.checkbox_uncheck
22
+ @page.close
23
+ end
24
+
@@ -0,0 +1,27 @@
1
+ Dir[File.dirname(__FILE__) + "/../../pages/*.rb"].each do |file|
2
+ require file
3
+ end
4
+
5
+ Given /^I am on a page that has a textfield$/ do
6
+ @page = StaticPages::Site::InputPage.new
7
+ end
8
+
9
+ Given /^I am on a page that has a textarea$/ do
10
+ @page = StaticPages::Site::InputPage.new
11
+ end
12
+
13
+ Given /^I am on a page that has a checkbox$/ do
14
+ @page = StaticPages::Site::InputPage.new
15
+ end
16
+
17
+ And /^There is a textfield with the text "(.*?)"$/ do |text|
18
+ @page.text_field_fill_with(text)
19
+ end
20
+
21
+ And /^There is a textarea with the text "(.*?)"$/ do |text|
22
+ @page.textarea_fill_with(text)
23
+ end
24
+
25
+ And /^There is a checkbox checked$/ do
26
+ @page.checkbox_check
27
+ end
@@ -0,0 +1,49 @@
1
+ Dir[File.dirname(__FILE__) + "/../../pages/*.rb"].each do |file|
2
+ require file
3
+ end
4
+
5
+ Given /^I am on a page that has a element$/ do
6
+ @page = StaticPages::Site::InputPage.new
7
+ end
8
+
9
+ Given /^that element is named as:$/ do |elements|
10
+ elements.raw.each do |name|
11
+ @page.send("#{name}_is_real?")
12
+ end
13
+ @elements = elements
14
+ end
15
+
16
+ Then /^I want click on this element$/ do
17
+ @elements.raw.each do |name|
18
+ @page.send("#{name}_click")
19
+ end
20
+ @page.close
21
+ end
22
+
23
+ Then /^I want know if this element is visible$/ do
24
+ @elements.raw.each do |name|
25
+ @page.send("#{name}_is_visible?")
26
+ end
27
+ @page.close
28
+ end
29
+
30
+ Then /^I want know if this element is enable$/ do
31
+ @elements.raw.each do |name|
32
+ @page.send("#{name}_is_enable?")
33
+ end
34
+ @page.close
35
+ end
36
+
37
+ Then /^I want know if this element exists$/ do
38
+ @elements.raw.each do |name|
39
+ @page.send("#{name}_is_real?")
40
+ end
41
+ @page.close
42
+ end
43
+
44
+ Then /^I shoud be able to click with the right button in this element$/ do
45
+ @elements.raw.each do |name|
46
+ @page.send("#{name}_right_click")
47
+ end
48
+ @page.close
49
+ end
@@ -0,0 +1,43 @@
1
+ Dir[File.dirname(__FILE__) + "/../../pages/*.rb"].each do |file|
2
+ require file
3
+ end
4
+
5
+ Then /^I should can knows if this page has a textarea$/ do
6
+ @page.textarea_is_real?
7
+ @page.close
8
+ end
9
+
10
+ Then /^I should be able to write a text like "(.*?)" in the textarea$/ do |text|
11
+ @page.textarea_fill_with(text)
12
+ @page.close
13
+ end
14
+
15
+ Then /^I shoud be able to get the text "(.*?)" from this textarea$/ do |text|
16
+ @page.textarea_get_text == text
17
+ @page.close
18
+ end
19
+
20
+ Then /^I should be able to know if the text on the textarea does not contais the text "(.*?)"$/ do |text|
21
+ @page.textarea_dont_contain(text)
22
+ @page.close
23
+ end
24
+
25
+ Then /^I should be able to know if the text on the textarea contais the text "(.*?)"$/ do |text|
26
+ @page.textarea_contains(text)
27
+ @page.close
28
+ end
29
+
30
+ Then /^I should be able to know if the text on the textarea is the text "(.*?)"$/ do |text|
31
+ @page.textarea_text_is(text)
32
+ @page.close
33
+ end
34
+
35
+ Then /^I should be able to know if the textarea is empty$/ do
36
+ @page.textarea_is_empty?
37
+ @page.close
38
+ end
39
+
40
+ Then /^I should be able to know if the size of the textarea text is "(.*?)"$/ do |size|
41
+ @page.textarea_text_size == size
42
+ @page.close
43
+ end
@@ -0,0 +1,43 @@
1
+ Dir[File.dirname(__FILE__) + "/../../pages/*.rb"].each do |file|
2
+ require file
3
+ end
4
+
5
+ Then /^I should can knows if this page has a textfield$/ do
6
+ @page.text_field_is_real?
7
+ @page.close
8
+ end
9
+
10
+ Then /^I should be able to write a text like "(.*?)" in the textfield$/ do |text|
11
+ @page.text_field_fill_with(text)
12
+ @page.close
13
+ end
14
+
15
+ Then /^I shoud be able to get the text "(.*?)" from this textfield$/ do |text|
16
+ @page.text_field_get_text == text
17
+ @page.close
18
+ end
19
+
20
+ Then /^I should be able to know if the text on the textfield does not contais the text "(.*?)"$/ do |text|
21
+ @page.text_field_dont_contain(text)
22
+ @page.close
23
+ end
24
+
25
+ Then /^I should be able to know if the text on the textfield contais the text "(.*?)"$/ do |text|
26
+ @page.text_field_contains(text)
27
+ @page.close
28
+ end
29
+
30
+ Then /^I should be able to know if the text on the textfield is the text "(.*?)"$/ do |text|
31
+ @page.text_field_text_is(text)
32
+ @page.close
33
+ end
34
+
35
+ Then /^I should be able to know if the textfield is empty$/ do
36
+ @page.text_field_is_empty?
37
+ @page.close
38
+ end
39
+
40
+ Then /^I should be able to know if the size of the textfield text is "(.*?)"$/ do |size|
41
+ @page.text_field_text_size == size
42
+ @page.close
43
+ end
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,48 @@
1
+ Feature: Textarea
2
+ As developer
3
+ I want to interact with textarea elements in many ways
4
+
5
+ Scenario: Finding a textarea
6
+ Given I am on a page that has a textarea
7
+ Then I should can knows if this page has a textarea
8
+
9
+ Scenario: Setting a text on a textarea
10
+ Given I am on a page that has a textarea
11
+ Then I should be able to write a text like "Testing automation Rockst" in the textarea
12
+
13
+ Scenario: Getting the text from a textarea
14
+ Given I am on a page that has a textarea
15
+ And There is a textarea with the text "Testing automation rocks"
16
+ Then I shoud be able to get the text "Testing automation rocks" from this textarea
17
+
18
+ Scenario: The textarea does not contais the text
19
+ Given I am on a page that has a textarea
20
+ And There is a textarea with the text "Testing automation rocks"
21
+ Then I should be able to know if the text on the textarea does not contais the text "Fooooooo"
22
+
23
+ Scenario: The textarea does not contais the text (counter proof)
24
+ Given I am on a page that has a textarea
25
+ And There is a textarea with the text "Testing automation rocks"
26
+ Then I should be able to know if the text on the textarea does not contais the text "rocks"
27
+
28
+ Scenario: The textarea contains a text
29
+ Given I am on a page that has a textarea
30
+ And There is a textarea with the text "Testing automation rocks"
31
+ Then I should be able to know if the text on the textarea contais the text "rocks"
32
+
33
+ Scenario: The text on a textarea is exactly some text
34
+ Given I am on a page that has a textarea
35
+ And There is a textarea with the text "Testing automation rocks"
36
+ Then I should be able to know if the text on the textarea is the text "Testing automation rocks"
37
+
38
+ Scenario: The textarea is empty
39
+ Given I am on a page that has a textarea
40
+ Then I should be able to know if the textarea is empty
41
+
42
+ @pending
43
+ Scenario: Textfield max lenght
44
+
45
+ Scenario: The lenght of a Textfield text
46
+ Given I am on a page that has a textarea
47
+ And There is a textarea with the text "Testing automation rocks"
48
+ Then I should be able to know if the size of the textarea text is "24"
@@ -0,0 +1,49 @@
1
+ Feature: Textfield
2
+ As a developer
3
+ I want to use textfield in different ways
4
+
5
+ Scenario: Finding a textfield
6
+ Given I am on a page that has a textfield
7
+ Then I should can knows if this page has a textfield
8
+
9
+ Scenario: Setting a text on a textfield
10
+ Given I am on a page that has a textfield
11
+ Then I should be able to write a text like "Testing automation Rockst" in the textfield
12
+
13
+ Scenario: Getting the text from a textfield
14
+ Given I am on a page that has a textfield
15
+ And There is a textfield with the text "Testing automation rocks"
16
+ Then I shoud be able to get the text "Testing automation rocks" from this textfield
17
+
18
+ Scenario: The textfield does not contais the text
19
+ Given I am on a page that has a textfield
20
+ And There is a textfield with the text "Testing automation rocks"
21
+ Then I should be able to know if the text on the textfield does not contais the text "Fooooooo"
22
+
23
+ Scenario: The textfield does not contais the text (counter proof)
24
+ Given I am on a page that has a textfield
25
+ And There is a textfield with the text "Testing automation rocks"
26
+ Then I should be able to know if the text on the textfield does not contais the text "rocks"
27
+
28
+ Scenario: The textfield contains a text
29
+ Given I am on a page that has a textfield
30
+ And There is a textfield with the text "Testing automation rocks"
31
+ Then I should be able to know if the text on the textfield contais the text "rocks"
32
+
33
+ Scenario: The text on a textfield is exactly some text
34
+ Given I am on a page that has a textfield
35
+ And There is a textfield with the text "Testing automation rocks"
36
+ Then I should be able to know if the text on the textfield is the text "Testing automation rocks"
37
+
38
+ Scenario: The textfield is empty
39
+ Given I am on a page that has a textfield
40
+ Then I should be able to know if the textfield is empty
41
+
42
+ @pending
43
+ Scenario: Textfield max lenght
44
+
45
+ Scenario: The lenght of a Textfield text
46
+ Given I am on a page that has a textfield
47
+ And There is a textfield with the text "Testing automation rocks"
48
+ Then I should be able to know if the size of the textfield text is "24"
49
+
@@ -0,0 +1,20 @@
1
+ module Cello
2
+ module Structure
3
+ module CheckboxHelper
4
+ def define_extras_for_checkbox(name)
5
+ define_method "#{name}_check" do
6
+ send(name).set
7
+ end
8
+ define_method "#{name}_uncheck" do
9
+ send(name).clear
10
+ end
11
+ define_method "#{name}_is_checked?" do
12
+ send(name).set?
13
+ end
14
+ define_method "#{name}_is_unchecked?" do
15
+ !(send(name).set?)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,8 @@
1
+ module Cello
2
+ module Structure
3
+ module ButtonHelper
4
+ def define_extras_for_button(name)
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ module Cello
2
+ module Config
3
+ module CucumberConfig
4
+ screen_pictures_path = ''
5
+
6
+ After do |scenario|
7
+ browser.driver.save_screenshot 'screenshot.png'
8
+ embed 'screenshot.png', 'image/png'
9
+ browser.close
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ module Cello
2
+ module Structure
3
+ module DivHelper
4
+ def define_extras_for_div(name)
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,54 @@
1
+ Dir[File.dirname(__FILE__) + "/*.rb"].each do |file|
2
+ require file
3
+ end
4
+
5
+ module Cello
6
+ module Structure
7
+ module ElementHelper
8
+
9
+ def element(name, type, *args)
10
+ class_eval do
11
+ define_method name do
12
+ browser.send(type, *args)
13
+ end
14
+
15
+ define_extras(name, type)
16
+ end
17
+ end
18
+
19
+ protected
20
+
21
+ def define_extras(name, type)
22
+ define_method "#{name}_is_real?" do
23
+ send(name).exists?
24
+ end
25
+ define_method "#{name}_click" do
26
+ send(name).click
27
+ end
28
+ define_method "#{name}_is_visible?" do
29
+ send(name).visible?
30
+ end
31
+ define_method "#{name}_is_enable?" do
32
+ send(name).enabled?
33
+ end
34
+ define_method "#{name}_right_click" do
35
+ send(name).right_click
36
+ end
37
+
38
+ method_name = "define_extras_for_#{type}"
39
+ send(method_name, name) if respond_to? method_name
40
+ end
41
+
42
+ include CheckboxHelper
43
+ include TextfieldHelper
44
+ include SelectHelper
45
+ include DivHelper
46
+ include RadioHelper
47
+ include LinkHelper
48
+ include ButtonHelper
49
+ include SpanHelper
50
+ include HiddenHelper
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,8 @@
1
+ module Cello
2
+ module Structure
3
+ module HiddenHelper
4
+ def define_extras_for_hidden(name)
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Cello
2
+ module Structure
3
+ module LinkHelper
4
+ def define_extras_for_link(name)
5
+ end
6
+ end
7
+ end
8
+ end
data/lib/cello/page.rb ADDED
@@ -0,0 +1,44 @@
1
+ require File.join(File.dirname(__FILE__), "element_helper")
2
+ require "rubygems"
3
+ require "selenium-webdriver"
4
+ require "watir-webdriver"
5
+
6
+ module Cello
7
+ module Structure
8
+ class Page
9
+ extend Cello::Structure::ElementHelper
10
+
11
+ attr_reader :browser
12
+ def initialize(url)
13
+ @browser = Watir::Browser.new :firefox
14
+ @browser.goto url
15
+ end
16
+
17
+ def visit
18
+ end
19
+
20
+ def search(text)
21
+ @browser.text.include? text
22
+ end
23
+
24
+ def close
25
+ @browser.close
26
+ end
27
+
28
+ def browser
29
+ @browser
30
+ end
31
+
32
+ def get_picture
33
+ @browser.driver.save_screenshot 'screenshot.png'
34
+ end
35
+ def get_title
36
+ @browser.titles
37
+ end
38
+ def get_response_time
39
+ #pending
40
+ end
41
+ end
42
+ end
43
+ end
44
+
@@ -0,0 +1,11 @@
1
+ module Cello
2
+ module Structure
3
+ module RadioHelper
4
+ def define_extras_for_radio(name)
5
+ define_method "set_#{name}" do
6
+ send(name).set
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ module Cello
2
+ module Structure
3
+ module SelectHelper
4
+ def define_extras_for_select(name)
5
+ define_method "select_#{name}" do |value|
6
+ send(name).select(value)
7
+ end
8
+ define_method "clear_#{name}" do
9
+ send(name).select("Selecione...")
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,8 @@
1
+ module Cello
2
+ module Structure
3
+ module SpanHelper
4
+ def define_extras_for_span(name)
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,35 @@
1
+ module Cello
2
+ module Structure
3
+ module TextfieldHelper
4
+ def define_extras_for_textarea(name)
5
+ define_method "#{name}_is_enable?" do
6
+ !(send(name).disabled?)
7
+ end
8
+ define_method "#{name}_clear" do
9
+ send(name).clear
10
+ end
11
+ define_method "#{name}_get_text" do
12
+ send(name).text
13
+ end
14
+ define_method "#{name}_fill_with" do |text|
15
+ send(name).set text
16
+ end
17
+ define_method "#{name}_dont_contain" do |text|
18
+ !(send(name).text.include? text)
19
+ end
20
+ define_method "#{name}_contains" do |text|
21
+ send(name).text.include? text
22
+ end
23
+ define_method "#{name}_text_is" do |text|
24
+ send(name).text == text
25
+ end
26
+ define_method "#{name}_is_empty?" do
27
+ send(name).text.empty?
28
+ end
29
+ define_method "#{name}_text_size" do
30
+ send(name).text.size
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,32 @@
1
+ module Cello
2
+ module Structure
3
+ module TextfieldHelper
4
+ def define_extras_for_text_field(name)
5
+ define_method "#{name}_clear" do
6
+ send(name).clear
7
+ end
8
+ define_method "#{name}_get_text" do
9
+ send(name).text
10
+ end
11
+ define_method "#{name}_fill_with" do |text|
12
+ send(name).set text
13
+ end
14
+ define_method "#{name}_dont_contain" do |text|
15
+ !(send(name).text.include? text)
16
+ end
17
+ define_method "#{name}_contains" do |text|
18
+ send(name).text.include? text
19
+ end
20
+ define_method "#{name}_text_is" do |text|
21
+ send(name).text == text
22
+ end
23
+ define_method "#{name}_is_empty?" do
24
+ send(name).text.empty?
25
+ end
26
+ define_method "#{name}_text_size" do
27
+ send(name).text.size
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module Cello
2
+ VERSION = "0.0.12"
3
+ end
data/lib/cello.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'cello/version'
2
+ require 'rubygems'
3
+ require 'bundler/setup'
4
+
5
+ #common dependencies
6
+ require 'selenium-webdriver'
7
+ require 'watir-webdriver'
8
+ require 'cucumber'
9
+
10
+ module Cello
11
+ end
File without changes
metadata ADDED
@@ -0,0 +1,182 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cello
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 12
9
+ version: 0.0.12
10
+ platform: ruby
11
+ authors:
12
+ - Camilo Ribeiro
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2012-05-29 00:00:00 -03:00
18
+ default_executable: cello
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: cucumber
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :development
31
+ version_requirements: *id001
32
+ - !ruby/object:Gem::Dependency
33
+ name: rake
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
41
+ version: "0"
42
+ type: :development
43
+ version_requirements: *id002
44
+ - !ruby/object:Gem::Dependency
45
+ name: cucumber
46
+ prerelease: false
47
+ requirement: &id003 !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ segments:
52
+ - 0
53
+ version: "0"
54
+ type: :runtime
55
+ version_requirements: *id003
56
+ - !ruby/object:Gem::Dependency
57
+ name: watir-webdriver
58
+ prerelease: false
59
+ requirement: &id004 !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ type: :runtime
67
+ version_requirements: *id004
68
+ - !ruby/object:Gem::Dependency
69
+ name: selenium-webdriver
70
+ prerelease: false
71
+ requirement: &id005 !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ type: :runtime
79
+ version_requirements: *id005
80
+ description: Cello is a framework that allows automate acceptance tests using page-object
81
+ email:
82
+ - cribeiro@thoughtworks.com
83
+ executables: []
84
+
85
+ extensions: []
86
+
87
+ extra_rdoc_files: []
88
+
89
+ files:
90
+ - .gitignore
91
+ - .rspec
92
+ - Gemfile
93
+ - LICENCE
94
+ - README.md
95
+ - Rakefile
96
+ - cello.gemspec
97
+ - examples/bugbang/flows/search.feature
98
+ - examples/bugbang/flows/step_definitions/search.rb
99
+ - examples/bugbang/flows/support/env.rb
100
+ - examples/bugbang/pages/home.rb
101
+ - features/access_element.feature
102
+ - features/checkbox.feature
103
+ - features/choose_browser.feature
104
+ - features/element.feature
105
+ - features/fire_event.feature
106
+ - features/get_html_atributes.feature
107
+ - features/pages/input_fields.rb
108
+ - features/site/inputs.html
109
+ - features/step_definitions/access_element.rb
110
+ - features/step_definitions/checkbox.rb
111
+ - features/step_definitions/common_steps.rb
112
+ - features/step_definitions/element.rb
113
+ - features/step_definitions/textarea.rb
114
+ - features/step_definitions/textfield.rb
115
+ - features/support/env.rb
116
+ - features/textarea.feature
117
+ - features/textfield.feature
118
+ - lib/cello.rb
119
+ - lib/cello/Checkbox_helper.rb
120
+ - lib/cello/button_helper.rb
121
+ - lib/cello/config/cucumber_config.rb
122
+ - lib/cello/div_helper.rb
123
+ - lib/cello/element_helper.rb
124
+ - lib/cello/hidden_helper.rb
125
+ - lib/cello/link_helper.rb
126
+ - lib/cello/page.rb
127
+ - lib/cello/radio_helper.rb
128
+ - lib/cello/select_helper.rb
129
+ - lib/cello/span_helper.rb
130
+ - lib/cello/textarea_helper.rb
131
+ - lib/cello/textfield_helper.rb
132
+ - lib/cello/version.rb
133
+ - spec/checkbox_spec.rb
134
+ has_rdoc: true
135
+ homepage: http://github.com/camiloribeiro/cello
136
+ licenses: []
137
+
138
+ post_install_message:
139
+ rdoc_options: []
140
+
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ segments:
148
+ - 0
149
+ version: "0"
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ segments:
155
+ - 0
156
+ version: "0"
157
+ requirements: []
158
+
159
+ rubyforge_project: cello
160
+ rubygems_version: 1.3.6
161
+ signing_key:
162
+ specification_version: 3
163
+ summary: Fast and simple Page-Object with BDD
164
+ test_files:
165
+ - features/access_element.feature
166
+ - features/checkbox.feature
167
+ - features/choose_browser.feature
168
+ - features/element.feature
169
+ - features/fire_event.feature
170
+ - features/get_html_atributes.feature
171
+ - features/pages/input_fields.rb
172
+ - features/site/inputs.html
173
+ - features/step_definitions/access_element.rb
174
+ - features/step_definitions/checkbox.rb
175
+ - features/step_definitions/common_steps.rb
176
+ - features/step_definitions/element.rb
177
+ - features/step_definitions/textarea.rb
178
+ - features/step_definitions/textfield.rb
179
+ - features/support/env.rb
180
+ - features/textarea.feature
181
+ - features/textfield.feature
182
+ - spec/checkbox_spec.rb