simplexframe 0.0.01

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/.document +5 -0
  2. data/Gemfile +21 -0
  3. data/Gemfile.lock +64 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +94 -0
  6. data/README.rdoc +38 -0
  7. data/Rakefile +1 -0
  8. data/VERSION +1 -0
  9. data/bin/simplexframe +7 -0
  10. data/lib/simplexframe.rb +9 -0
  11. data/lib/simplexframe/cli.rb +38 -0
  12. data/lib/simplexframe/errors.rb +6 -0
  13. data/lib/simplexframe/ext/string.rb +12 -0
  14. data/lib/simplexframe/generators/simplexframe/.rspec +3 -0
  15. data/lib/simplexframe/generators/simplexframe/app/cases/baidu_and_google/baidu_example_spec.rb +24 -0
  16. data/lib/simplexframe/generators/simplexframe/app/cases/baidu_and_google/google_example_spec.rb +16 -0
  17. data/lib/simplexframe/generators/simplexframe/app/cases/mantis/report_issue_spec.rb +27 -0
  18. data/lib/simplexframe/generators/simplexframe/app/cases/shared/login.rb +11 -0
  19. data/lib/simplexframe/generators/simplexframe/app/cases/spec_helper.rb.tt +49 -0
  20. data/lib/simplexframe/generators/simplexframe/app/matchers/.empty_directory +5 -0
  21. data/lib/simplexframe/generators/simplexframe/app/pages/%app_name%_navigator.rb.tt +4 -0
  22. data/lib/simplexframe/generators/simplexframe/app/pages/%app_name%_page.rb.tt +4 -0
  23. data/lib/simplexframe/generators/simplexframe/app/pages/baidu/baidu_page.rb.tt +14 -0
  24. data/lib/simplexframe/generators/simplexframe/app/pages/baidu/search_result_page.rb.tt +4 -0
  25. data/lib/simplexframe/generators/simplexframe/app/pages/components/.empty_directory +5 -0
  26. data/lib/simplexframe/generators/simplexframe/app/pages/components/menu.rb +6 -0
  27. data/lib/simplexframe/generators/simplexframe/app/pages/google/google_page.rb.tt +16 -0
  28. data/lib/simplexframe/generators/simplexframe/app/pages/google/google_search_result_page.rb.tt +4 -0
  29. data/lib/simplexframe/generators/simplexframe/app/pages/mantis/login_page.rb.tt +17 -0
  30. data/lib/simplexframe/generators/simplexframe/app/pages/mantis/my_view_page.rb.tt +8 -0
  31. data/lib/simplexframe/generators/simplexframe/app/pages/mantis/report_issue_page.rb.tt +26 -0
  32. data/lib/simplexframe/generators/simplexframe/app/pages/mantis/view_all_bug_page.rb.tt +22 -0
  33. data/lib/simplexframe/generators/simplexframe/app/reports/.empty_directory +5 -0
  34. data/lib/simplexframe/generators/simplexframe/app/test_data/baidu.yml +4 -0
  35. data/lib/simplexframe/generators/simplexframe/app/test_data/login_user.yml +4 -0
  36. data/lib/simplexframe/generators/simplexframe/bin/console +7 -0
  37. data/lib/simplexframe/generators/simplexframe/bin/console.bat +6 -0
  38. data/lib/simplexframe/generators/simplexframe/bin/setup.rb.tt +12 -0
  39. data/lib/simplexframe/generators/simplexframe/config/config.yml +4 -0
  40. data/lib/simplexframe/generators/simplexframe/config/simplexframe_formatter.rb +24 -0
  41. data/lib/simplexframe/simple_config.rb +21 -0
  42. data/lib/simplexframe/simple_initializer.rb +48 -0
  43. data/lib/simplexframe/simple_navigator.rb +56 -0
  44. data/lib/simplexframe/simple_page.rb +35 -0
  45. data/simplexframe.gemspec +132 -0
  46. data/spec/app/pages/components/footer.rb +3 -0
  47. data/spec/app/pages/components/sub/sub_footer.rb +3 -0
  48. data/spec/app/pages/module1/module1_page.rb +6 -0
  49. data/spec/app/pages/module1/sub_test_page.rb +4 -0
  50. data/spec/app/pages/test_navigator.rb +4 -0
  51. data/spec/app/pages/test_page.rb +4 -0
  52. data/spec/config/config.yml +3 -0
  53. data/spec/config/wrong_config.yml +5 -0
  54. data/spec/pages/components/footer.rb +2 -0
  55. data/spec/pages/test_page.rb +5 -0
  56. data/spec/simple_config_spec.rb +28 -0
  57. data/spec/simple_initializer_spec.rb +28 -0
  58. data/spec/simple_navigator_spec.rb +36 -0
  59. data/spec/simple_page_spec.rb +44 -0
  60. data/spec/spec_helper.rb +20 -0
  61. data/spec/string_spec.rb +10 -0
  62. metadata +278 -0
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ source 'https://rubygems.org'
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ gem "rspec", ">= 2.13.0"
9
+ gem "page-object", ">= 0.8.6.1"
10
+ gem "thor", ">= 0.14.6"
11
+ gem "active_support", "~> 3.0.0"
12
+
13
+ group :development do
14
+ gem "rdoc", "~> 3.12"
15
+ gem "bundler", "~> 1.3.5"
16
+ gem "jeweler", "~> 1.8.4"
17
+ gem "rspec", ">= 2.13.0"
18
+ gem "page-object", ">= 0.8.6.1"
19
+ gem "thor", ">= 0.14.6"
20
+ gem "active_support", "~> 3.0.0"
21
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,64 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ active_support (3.0.0)
5
+ activesupport (= 3.0.0)
6
+ activesupport (3.0.0)
7
+ childprocess (0.3.9)
8
+ ffi (~> 1.0, >= 1.0.11)
9
+ data_magic (0.14)
10
+ faker (>= 1.1.2)
11
+ yml_reader (>= 0.2)
12
+ diff-lcs (1.2.4)
13
+ faker (1.1.2)
14
+ i18n (~> 0.5)
15
+ ffi (1.6.0-x86-mingw32)
16
+ git (1.2.5)
17
+ i18n (0.6.4)
18
+ jeweler (1.8.4)
19
+ bundler (~> 1.0)
20
+ git (>= 1.2.5)
21
+ rake
22
+ rdoc
23
+ json (1.7.7)
24
+ multi_json (1.7.2)
25
+ page-object (0.8.6.1)
26
+ page_navigation (>= 0.7)
27
+ selenium-webdriver (>= 2.31.0)
28
+ watir-webdriver (>= 0.6.2)
29
+ page_navigation (0.7)
30
+ data_magic (>= 0.14)
31
+ rake (10.0.4)
32
+ rdoc (3.12.2)
33
+ json (~> 1.4)
34
+ rspec (2.14.1)
35
+ rspec-core (~> 2.14.0)
36
+ rspec-expectations (~> 2.14.0)
37
+ rspec-mocks (~> 2.14.0)
38
+ rspec-core (2.14.5)
39
+ rspec-expectations (2.14.0)
40
+ diff-lcs (>= 1.1.3, < 2.0)
41
+ rspec-mocks (2.14.1)
42
+ rubyzip (0.9.9)
43
+ selenium-webdriver (2.31.0)
44
+ childprocess (>= 0.2.5)
45
+ multi_json (~> 1.0)
46
+ rubyzip
47
+ websocket (~> 1.0.4)
48
+ thor (0.14.6)
49
+ watir-webdriver (0.6.2)
50
+ selenium-webdriver (>= 2.18.0)
51
+ websocket (1.0.7)
52
+ yml_reader (0.2)
53
+
54
+ PLATFORMS
55
+ x86-mingw32
56
+
57
+ DEPENDENCIES
58
+ active_support (~> 3.0.0)
59
+ bundler (~> 1.3.5)
60
+ jeweler (~> 1.8.4)
61
+ page-object (>= 0.8.6.1)
62
+ rdoc (~> 3.12)
63
+ rspec (>= 2.13.0)
64
+ thor (>= 0.14.6)
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 theSimplex
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,94 @@
1
+ simplexframe
2
+ =====================
3
+
4
+ A simple web automation test framework using [selenium-webdriver](http://docs.seleniumhq.org/projects/webdriver/),[watir-webdriver](https://github.com/watir/watir-webdriver),[page-object](https://github.com/cheezy/page-object) and [rspec](https://github.com/rspec/rspec).
5
+
6
+
7
+ Install simplexframe
8
+ ---------------
9
+ Install simplexframe from rubygems
10
+
11
+ gem install simplexframe
12
+
13
+ Or clone from github, build the gem and install
14
+
15
+ If you have any issue when install simplexframe, install the gems below:
16
+
17
+ gem install thor
18
+
19
+
20
+ Create a simplexframe project
21
+ ------------------------
22
+ In windows, open command console and type just like below:
23
+
24
+ simplexframe new your_project_name
25
+
26
+ Run Examples
27
+ ------------
28
+
29
+ Simplexframe contains some examples that explain how to use simplexframe writing your own test cases.
30
+
31
+ By default, simplexframe runs examples using chrome browser, so make sure you installed google chrome and according [chrome driver](http://code.google.com/p/chromedriver/downloads/list)
32
+
33
+ Using following command to make everything running.
34
+
35
+ cd your_project_name
36
+ simplexframe go
37
+
38
+ Simplexframe go command supports all the rspec options and it is the recommend way.
39
+
40
+ You can find test report in app/reports folder. It is a html file with current time stamp.
41
+
42
+ Using Console
43
+ -------------
44
+ You can use eat console to debug your test in irb.
45
+
46
+ cd your_project_name
47
+ simplexframe c
48
+
49
+ Simplexframe will load all your pages, start irb and open browser which was defined in your config.yml.
50
+
51
+ Then you can use $navi variable the same way in your test file.
52
+
53
+ p = $navi.goto_baidu_page
54
+ p.keyword="watir-webdriver"
55
+ p.search_element.click
56
+
57
+ You can type everything just like you are write a text case.
58
+
59
+ Understand project structure
60
+ ------------------------------------
61
+
62
+ Simplexframe project has a clean and simple structure.
63
+
64
+ * app: holds your test codes;
65
+ * config: where your config file placed;
66
+
67
+ * app->pages: puts all your pages files here;
68
+ * app->pages->components: sometimes,there are some html element that could be reused more than once, define a component, place the file here and you can include your components in your pages.
69
+
70
+ * app->cases: holds your testcase files;
71
+ * app->cases->shared: Image that, you are testing a system which need to login before any actions, so you want to define a login function which can be called from your cases. Define reused cases here.
72
+
73
+ * app->reports: the fold holds your test reports.
74
+
75
+ * app->matchers: defind your owner rspec matchers here.
76
+
77
+
78
+ Contributing to simplexframe
79
+ -----------------------
80
+
81
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
82
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
83
+ * Fork the project.
84
+ * Start a feature/bugfix branch.
85
+ * Commit and push until you are happy with your contribution.
86
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
87
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
88
+
89
+ Copyright
90
+ ---------
91
+
92
+ Copyright (c) 2013 easonhan. See LICENSE.txt for
93
+ further details.
94
+
data/README.rdoc ADDED
@@ -0,0 +1,38 @@
1
+ simplexframe
2
+ =====================
3
+
4
+ A simple web automation test framework using [selenium-webdriver](http://docs.seleniumhq.org/projects/webdriver/),[watir-webdriver](https://github.com/watir/watir-webdriver),[page-object](https://github.com/cheezy/page-object) and rspec(https://github.com/rspec/rspec).
5
+
6
+ Now simplexframe only tested in windows, other platformes are going to be tested soon.
7
+
8
+ Install simplexframe
9
+ ---------------
10
+ Install simplexframe from rubygems
11
+
12
+ gem install simplexframe
13
+
14
+ Or clone from github
15
+
16
+ Create a simplexframe project
17
+ ------------------------
18
+ In windows, open command console and type just like below:
19
+
20
+ simplexframe new your_project_name
21
+
22
+
23
+
24
+ == Contributing to simplexframe
25
+
26
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
27
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
28
+ * Fork the project.
29
+ * Start a feature/bugfix branch.
30
+ * Commit and push until you are happy with your contribution.
31
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
32
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
33
+
34
+ == Copyright
35
+
36
+ Copyright (c) 2013 easonhan. See LICENSE.txt for
37
+ further details.
38
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.14
data/bin/simplexframe ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ simplexframe_path = File.expand_path('../../lib', __FILE__)
4
+ #puts simplexframe_path
5
+ $:.unshift(simplexframe_path)
6
+
7
+ require 'simplexframe/cli'
@@ -0,0 +1,9 @@
1
+ require 'active_support/all' # need be replaced, only required string of active support
2
+ require 'watir-webdriver'
3
+ require 'page-object'
4
+ require 'simplexframe/ext/string'
5
+ require 'simplexframe/errors'
6
+ require 'simplexframe/simple_config'
7
+ require 'simplexframe/simple_page'
8
+ require 'simplexframe/simple_navigator'
9
+ require 'simplexframe/simple_initializer'
@@ -0,0 +1,38 @@
1
+ require 'thor'
2
+
3
+ module Simplexframe
4
+ class CLI < Thor
5
+ include Thor::Actions
6
+
7
+ argument :app_name, required: false
8
+
9
+ def self.source_root
10
+ File.join File.dirname(__FILE__), 'generators'
11
+ end
12
+
13
+ desc 'new', 'create a simplexframe project'
14
+ def new
15
+ if app_name
16
+ directory 'simplexframe', app_name
17
+ else
18
+ say 'no app name'
19
+ end
20
+ end
21
+
22
+ desc 'go ', 'run test case with rspec'
23
+ def go
24
+ ARGV.shift
25
+ puts "rspec #{ARGV.join('')}" if $debug
26
+ run "rspec #{ARGV.join('')}"
27
+ end
28
+
29
+ desc 'c ', 'open simplexframe console'
30
+ def c
31
+ run 'bin/console'
32
+ end
33
+
34
+ end
35
+ CLI.start
36
+
37
+ end #Simplexframe
38
+
@@ -0,0 +1,6 @@
1
+ module Simplexframe
2
+ class SimpleError < StandardError; end
3
+ class ConfigFileMissingError < SimpleError; end
4
+ class IncorrectConfigFileError < SimpleError; end
5
+ class InvalidSimplexframePageError < SimpleError; end
6
+ end #Simplex
@@ -0,0 +1,12 @@
1
+ class String
2
+ def simple_to_hash
3
+ hash = { }
4
+ return hash if self.empty?
5
+ arr = self.split(',').map { |i| i.strip }
6
+ arr.each do |key|
7
+ hash[key.to_sym] = true
8
+ end #each
9
+ hash
10
+ end
11
+
12
+ end
@@ -0,0 +1,3 @@
1
+ --default-path=./app/cases
2
+ --format Simplexframe::SimplexframeFormatter
3
+ -r ./config/simplexframe_formatter.rb
@@ -0,0 +1,24 @@
1
+ #encoding: utf-8
2
+ require File.expand_path 'app/cases/spec_helper'
3
+
4
+ describe 'Baidu example show you how to use simplexframe', :baidu do
5
+
6
+ before :all do
7
+ @keyword = 'watir-webdriver'
8
+ end
9
+
10
+ it 'should search baidu using key word' do
11
+ baidu_page = $navi.goto_baidu_page
12
+ baidu_page.keyword = @keyword
13
+ baidu_page.search_element.click
14
+ result_page = SearchResultPage.new baidu_page.browser
15
+ result_page.first_result.should eq 'watir-webdriver_百度百科'
16
+ end
17
+
18
+ it 'should have correct search result' do
19
+ baidu_page = $navi.goto_baidu_page
20
+ result_page = baidu_page.search_for @keyword
21
+ result_page.first_result.should eq 'watir-webdriver_百度百科'
22
+ end
23
+
24
+ end
@@ -0,0 +1,16 @@
1
+ #encoding: utf-8
2
+ require File.expand_path 'app/cases/spec_helper'
3
+
4
+ describe 'Google example show you how to use simplexframe', :google do
5
+
6
+ before :all do
7
+ @keyword = 'watir-webdriver'
8
+ end
9
+
10
+ it 'should have correct search result' do
11
+ google_page = $navi.goto_google_page
12
+ result_page = google_page.search_for @keyword
13
+ result_page.first_result.should eq 'Watir WebDriver | the most elegant way to use webdriver with ruby'
14
+ end
15
+
16
+ end
@@ -0,0 +1,27 @@
1
+ #encoding: utf-8
2
+ require File.expand_path 'app/cases/spec_helper'
3
+ require File.expand_path 'app/cases/shared/login'
4
+
5
+ describe 'report issue', :mantis do
6
+ context 'login' do
7
+ include_shared 'login'
8
+ end
9
+
10
+ context 'report issue' do
11
+
12
+ it 'should create report' do
13
+ report_issue_page = $navi.goto_report_issue_page
14
+ summary = "simplexframe test #{Time.now.to_s}"
15
+ desc = "description #{Time.now.to_s}"
16
+ category = 'GUI'
17
+
18
+ report_issue_page.create_issue category, summary, desc do |page|
19
+ page.check_report_stay
20
+ end
21
+
22
+ view_page = $navi.goto_view_all_bug_page
23
+ view_page.first_row[view_page.summary_column].text.should eq(summary)
24
+ end
25
+
26
+ end #context
27
+ end
@@ -0,0 +1,11 @@
1
+ shared_examples 'login' do
2
+ it 'should login' do
3
+ data = test_data('login_user')
4
+ user = data['demo']['name']
5
+ password = data['demo']['password']
6
+
7
+ login_page = $navi.goto_login_page
8
+ my_view_page = login_page.login user, password
9
+ my_view_page.report_issue?.should be_true
10
+ end
11
+ end
@@ -0,0 +1,49 @@
1
+ ENV.delete 'HTTP_PROXY' if ENV['HTTP_PROXY']
2
+ require 'rubygems' #for ruby187
3
+ require 'erb'
4
+ require 'psych'
5
+
6
+ begin
7
+ require 'simplexframe'
8
+ rescue LoadError
9
+ puts 'you need using "gem install simplexframe" to install simplexframe first'
10
+ end
11
+
12
+ <% require 'active_support/all' %>
13
+ Simplexframe::Initializer.new(File.expand_path(File.join('.')), '<%= app_name %>')
14
+ $:.unshift(File.expand_path File.join('.'))
15
+
16
+ RSpec.configure do |c|
17
+ c.treat_symbols_as_metadata_keys_with_true_values = true
18
+ c.run_all_when_everything_filtered = true
19
+ c.alias_example_to :test_case
20
+ c.alias_it_should_behave_like_to :include_shared
21
+
22
+ unless($config.tags.empty?)
23
+ tags = case
24
+ when String
25
+ $config.tags.simple_to_hash
26
+ when Hash
27
+ $config.tags
28
+ end #case
29
+ c.filter_run tags
30
+ end
31
+
32
+ def test_data file
33
+ content = ''
34
+ file_path = File.expand_path(File.join('.', 'app', 'test_data', "#{file}.yml"))
35
+ raise "Can not find #{file}.yml" unless File.exists?(file_path)
36
+ File.open(file_path, 'r') do |handle|
37
+ content = handle.read
38
+ end
39
+ Psych.load ERB.new(content).result(binding)
40
+ end
41
+
42
+ c.before(:suite) do
43
+ $navi = <%= app_name.camelize %>Navigator.new $config
44
+ end
45
+
46
+ c.after(:suite) do
47
+ $navi.close
48
+ end
49
+ end