page_magic 1.2.6 → 2.0.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +19 -3
  3. data/.simplecov +5 -3
  4. data/.zsh_config +6 -0
  5. data/Dockerfile +10 -0
  6. data/Gemfile +12 -12
  7. data/Gemfile.lock +133 -126
  8. data/Makefile +13 -0
  9. data/README.md +78 -14
  10. data/Rakefile +12 -2
  11. data/VERSION +1 -1
  12. data/circle.yml +4 -2
  13. data/lib/active_support/core_ext/object/to_query.rb +84 -0
  14. data/lib/page_magic.rb +7 -4
  15. data/lib/page_magic/class_methods.rb +4 -1
  16. data/lib/page_magic/driver.rb +3 -0
  17. data/lib/page_magic/drivers.rb +6 -5
  18. data/lib/page_magic/drivers/poltergeist.rb +2 -0
  19. data/lib/page_magic/drivers/rack_test.rb +3 -1
  20. data/lib/page_magic/drivers/selenium.rb +4 -2
  21. data/lib/page_magic/element.rb +19 -10
  22. data/lib/page_magic/element/locators.rb +4 -1
  23. data/lib/page_magic/element/query.rb +33 -33
  24. data/lib/page_magic/element/query_builder.rb +61 -0
  25. data/lib/page_magic/element/selector.rb +3 -0
  26. data/lib/page_magic/element/selector_methods.rb +3 -0
  27. data/lib/page_magic/element_context.rb +9 -12
  28. data/lib/page_magic/element_definition_builder.rb +10 -4
  29. data/lib/page_magic/elements.rb +51 -8
  30. data/lib/page_magic/exceptions.rb +4 -33
  31. data/lib/page_magic/instance_methods.rb +6 -1
  32. data/lib/page_magic/matcher.rb +12 -3
  33. data/lib/page_magic/session.rb +7 -5
  34. data/lib/page_magic/session_methods.rb +2 -0
  35. data/lib/page_magic/utils/string.rb +14 -0
  36. data/lib/page_magic/wait_methods.rb +3 -0
  37. data/lib/page_magic/watcher.rb +2 -0
  38. data/lib/page_magic/watchers.rb +4 -1
  39. data/page_magic.gemspec +19 -13
  40. data/spec/element_spec.rb +2 -0
  41. data/spec/lib/active_support/core_ext/object/to_query_test.rb +78 -0
  42. data/spec/page_magic/class_methods_spec.rb +2 -0
  43. data/spec/page_magic/driver_spec.rb +2 -0
  44. data/spec/page_magic/drivers/poltergeist_spec.rb +2 -0
  45. data/spec/page_magic/drivers/rack_test_spec.rb +2 -0
  46. data/spec/page_magic/drivers/selenium_spec.rb +2 -0
  47. data/spec/page_magic/drivers_spec.rb +2 -0
  48. data/spec/page_magic/element/locators_spec.rb +2 -0
  49. data/spec/page_magic/element/query_builder_spec.rb +110 -0
  50. data/spec/page_magic/element/query_spec.rb +35 -77
  51. data/spec/page_magic/element/selector_spec.rb +14 -7
  52. data/spec/page_magic/element_context_spec.rb +5 -10
  53. data/spec/page_magic/element_definition_builder_spec.rb +3 -1
  54. data/spec/page_magic/elements_spec.rb +19 -5
  55. data/spec/page_magic/instance_methods_spec.rb +2 -0
  56. data/spec/page_magic/matcher_spec.rb +3 -1
  57. data/spec/page_magic/session_methods_spec.rb +2 -0
  58. data/spec/page_magic/session_spec.rb +3 -4
  59. data/spec/page_magic/utils/string_spec.rb +36 -0
  60. data/spec/page_magic/wait_methods_spec.rb +5 -3
  61. data/spec/page_magic/watchers_spec.rb +2 -0
  62. data/spec/page_magic_spec.rb +5 -7
  63. data/spec/spec_helper.rb +3 -0
  64. data/spec/support/shared_contexts.rb +3 -1
  65. data/spec/support/shared_contexts/files_context.rb +2 -0
  66. data/spec/support/shared_contexts/nested_elements_html_context.rb +2 -0
  67. data/spec/support/shared_contexts/rack_application_context.rb +2 -0
  68. data/spec/support/shared_contexts/webapp_fixture_context.rb +3 -1
  69. data/spec/support/shared_examples.rb +2 -0
  70. data/spec/watcher_spec.rb +3 -0
  71. metadata +62 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5f5e27b2a270ba1333f9ae3b00500892ca2db6ea
4
- data.tar.gz: adb6f8c204b92c581ae8d05198899f1fe54decb9
2
+ SHA256:
3
+ metadata.gz: 4eec3ec93f7cd6ba430ba78860160822632cdc8949da2aea83afddc3366ea3d3
4
+ data.tar.gz: e3b3634979f0499bd0db1012a209a2d12cce94b7c0b870b1e91d3f8048e3f92b
5
5
  SHA512:
6
- metadata.gz: 220f194ecca9dc7ddcb6f912d0ea45caf922dc2704011e4fc5d897382d8af1d0a2a9725db585767d23a9913ad0f387e258dc0d9b73545290a25bb181b9e82578
7
- data.tar.gz: aeefe035655fc201c01d4539026be9162fea73fe7e173314ce0fe7389529d089507af383299727307598b1e0c406a576a55f160f38f5128df201dde38f2fa167
6
+ metadata.gz: afe8591e16f7afaa2e464b48ac9eabff046a140df8558dee5bb51aa3eac0ccb43c43cbb43eb7af9d7a2529f242f1cc87b7f63160c5c70decb3bbc9d2cd8d060a
7
+ data.tar.gz: 95802bd6ab8e1acca9f0d8142452469a743177cdbbf3a44e679016960a23bfe56b453ad53db758bd9ce9edc82f388f90a03c72f76341c24ff517995678e9f2eb
data/.rubocop.yml CHANGED
@@ -2,8 +2,10 @@ Metrics/LineLength:
2
2
  Max: 120
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.1
5
+ TargetRubyVersion: 2.7
6
6
  Exclude:
7
+ - 'lib/active_support/**/*'
8
+ - 'spec/lib/active_support/**/*'
7
9
  - 'pkg/**/*'
8
10
  - 'vendor/**/*'
9
11
  - 'coverage/**/*'
@@ -16,5 +18,19 @@ Metrics/ParameterLists:
16
18
  Metrics/MethodLength:
17
19
  Max: 11
18
20
 
19
- Style/MethodMissing:
20
- Enabled: false
21
+ #Style/MethodMissing:
22
+ # Enabled: false
23
+
24
+ Metrics/BlockLength:
25
+ Enabled: true
26
+ Exclude:
27
+ - 'spec/**/*'
28
+
29
+ Style/PercentLiteralDelimiters:
30
+ PreferredDelimiters:
31
+ default: ()
32
+ '%i': '[]'
33
+ '%I': '[]'
34
+ '%r': '{}'
35
+ '%w': '[]'
36
+ '%W': '[]'
data/.simplecov CHANGED
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pullreview/coverage'
2
- require "codeclimate-test-reporter"
3
4
 
4
- SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter,PullReview::Coverage::Formatter,CodeClimate::TestReporter::Formatter]
5
+ SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, PullReview::Coverage::Formatter]
5
6
 
6
7
  SimpleCov.start do
7
8
  add_filter '/spec/'
8
- end
9
+ add_filter '/lib/active_support/core_ext/object/to_query.rb'
10
+ end
data/.zsh_config ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ #alias bundle="docker run -v ${HOME}/.gitconfig:/root/.gitconfig -v $(pwd):/page_magic -t lvl-up/page-magic bundle"
3
+ #alias ruby="bundle exec ruby"
4
+ #alias rake="bundle exec rake"
5
+ #alias rubocop="bundle exec rubocop"
6
+ #alias gem="docker run -v $(pwd):/page_magic -t lvl-up/page-magic gem"
data/Dockerfile ADDED
@@ -0,0 +1,10 @@
1
+ FROM ruby:2.7.2-alpine
2
+
3
+ ENV APP_HOME /page_magic
4
+ RUN mkdir $APP_HOME
5
+
6
+ COPY . $APP_HOME
7
+ WORKDIR $APP_HOME
8
+
9
+ RUN apk --update --no-cache add build-base git
10
+ RUN bundle install
data/Gemfile CHANGED
@@ -1,23 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
- gem 'capybara', '>= 2.5'
4
- gem 'activesupport', '~> 4'
5
+ gem 'activesupport'
6
+ gem 'capybara', ">=3.0"
5
7
 
6
8
  group :test do
7
- gem 'watir-webdriver'
8
- gem 'sinatra'
9
+ gem 'poltergeist'
9
10
  gem 'rspec', require: 'rspec/core/rake_task'
10
11
  gem 'simplecov', require: false
11
- gem 'poltergeist'
12
- gem 'codeclimate-test-reporter', group: :test, require: nil
13
- gem 'pullreview-coverage', require: false
14
- gem 'arbre'
12
+ gem 'sinatra'
13
+ gem 'watir'
15
14
  end
16
15
 
17
16
  group :development do
18
- gem 'jeweler', '~> 2.0'
19
- gem 'rubocop', '~> 0.34', require: 'rubocop/rake_task'
17
+ gem 'github-markup'
18
+ gem 'jeweler'
19
+ gem 'redcarpet'
20
+ gem 'rubocop', require: 'rubocop/rake_task'
21
+ gem 'ruby-debug-ide', require: false
20
22
  gem 'yard', '~> 0.8'
21
- gem 'redcarpet', '~> 3.3'
22
- gem 'github-markup', '~> 1.4'
23
23
  end
data/Gemfile.lock CHANGED
@@ -1,167 +1,174 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- activesupport (4.2.7)
5
- i18n (~> 0.7)
6
- json (~> 1.7, >= 1.7.7)
7
- minitest (~> 5.1)
8
- thread_safe (~> 0.3, >= 0.3.4)
9
- tzinfo (~> 1.1)
4
+ activesupport (6.1.3.1)
5
+ concurrent-ruby (~> 1.0, >= 1.0.2)
6
+ i18n (>= 1.6, < 2)
7
+ minitest (>= 5.1)
8
+ tzinfo (~> 2.0)
9
+ zeitwerk (~> 2.3)
10
10
  addressable (2.4.0)
11
- arbre (1.1.1)
12
- activesupport (>= 3.0.0)
13
- ast (2.3.0)
14
- builder (3.2.2)
15
- capybara (2.7.1)
11
+ ast (2.4.2)
12
+ builder (3.2.4)
13
+ capybara (3.35.3)
16
14
  addressable
17
- mime-types (>= 1.16)
18
- nokogiri (>= 1.3.3)
19
- rack (>= 1.0.0)
20
- rack-test (>= 0.5.4)
21
- xpath (~> 2.0)
22
- certifi (2016.02.28)
23
- childprocess (0.5.9)
24
- ffi (~> 1.0, >= 1.0.11)
15
+ mini_mime (>= 0.1.3)
16
+ nokogiri (~> 1.8)
17
+ rack (>= 1.6.0)
18
+ rack-test (>= 0.6.3)
19
+ regexp_parser (>= 1.5, < 3.0)
20
+ xpath (~> 3.2)
21
+ childprocess (3.0.0)
25
22
  cliver (0.3.2)
26
- codeclimate-test-reporter (0.6.0)
27
- simplecov (>= 0.7.1, < 1.0.0)
23
+ concurrent-ruby (1.1.8)
28
24
  descendants_tracker (0.0.4)
29
25
  thread_safe (~> 0.3, >= 0.3.1)
30
- diff-lcs (1.2.5)
31
- docile (1.1.5)
26
+ diff-lcs (1.4.4)
27
+ docile (1.3.5)
32
28
  faraday (0.9.2)
33
29
  multipart-post (>= 1.2, < 3)
34
- ffi (1.9.14)
35
- git (1.3.0)
36
- github-markup (1.4.0)
37
- github_api (0.14.4)
30
+ git (1.8.1)
31
+ rchardet (~> 1.8)
32
+ github-markup (4.0.0)
33
+ github_api (0.16.0)
38
34
  addressable (~> 2.4.0)
39
35
  descendants_tracker (~> 0.0.4)
40
36
  faraday (~> 0.8, < 0.10)
41
37
  hashie (>= 3.4)
42
- oauth2 (~> 1.0.0)
43
- hashie (3.4.4)
44
- highline (1.7.8)
45
- i18n (0.7.0)
46
- jeweler (2.1.1)
38
+ mime-types (>= 1.16, < 3.0)
39
+ oauth2 (~> 1.0)
40
+ hashie (4.1.0)
41
+ highline (2.0.3)
42
+ i18n (1.8.10)
43
+ concurrent-ruby (~> 1.0)
44
+ jeweler (2.3.9)
47
45
  builder
48
- bundler (>= 1.0)
46
+ bundler
49
47
  git (>= 1.2.5)
50
- github_api
48
+ github_api (~> 0.16.0)
51
49
  highline (>= 1.6.15)
52
50
  nokogiri (>= 1.5.10)
51
+ psych
53
52
  rake
54
53
  rdoc
55
- semver
56
- json (1.8.3)
57
- jwt (1.5.4)
58
- mime-types (3.1)
59
- mime-types-data (~> 3.2015)
60
- mime-types-data (3.2016.0521)
61
- mini_portile2 (2.1.0)
62
- minitest (5.9.0)
63
- multi_json (1.12.1)
64
- multi_xml (0.5.5)
65
- multipart-post (2.0.0)
66
- nokogiri (1.6.8)
67
- mini_portile2 (~> 2.1.0)
68
- pkg-config (~> 1.1.7)
69
- oauth2 (1.0.0)
70
- faraday (>= 0.8, < 0.10)
71
- jwt (~> 1.0)
54
+ semver2
55
+ jwt (2.2.2)
56
+ mime-types (2.99.3)
57
+ mini_mime (1.1.0)
58
+ mini_portile2 (2.5.0)
59
+ minitest (5.14.4)
60
+ multi_json (1.15.0)
61
+ multi_xml (0.6.0)
62
+ multipart-post (2.1.1)
63
+ mustermann (1.1.1)
64
+ ruby2_keywords (~> 0.0.1)
65
+ nokogiri (1.11.3)
66
+ mini_portile2 (~> 2.5.0)
67
+ racc (~> 1.4)
68
+ oauth2 (1.4.7)
69
+ faraday (>= 0.8, < 2.0)
70
+ jwt (>= 1.0, < 3.0)
72
71
  multi_json (~> 1.3)
73
72
  multi_xml (~> 0.5)
74
- rack (~> 1.2)
75
- parser (2.3.1.2)
76
- ast (~> 2.2)
77
- pkg-config (1.1.7)
78
- poltergeist (1.10.0)
79
- capybara (~> 2.1)
73
+ rack (>= 1.2, < 3)
74
+ parallel (1.20.1)
75
+ parser (3.0.1.0)
76
+ ast (~> 2.4.1)
77
+ poltergeist (1.18.1)
78
+ capybara (>= 2.1, < 4)
80
79
  cliver (~> 0.3.1)
81
80
  websocket-driver (>= 0.2.0)
82
- powerpack (0.1.1)
83
- pullreview-coverage (0.0.5)
84
- certifi
85
- simplecov (>= 0.7.1, < 1.0.0)
86
- rack (1.6.4)
87
- rack-protection (1.5.3)
81
+ psych (3.3.1)
82
+ racc (1.5.2)
83
+ rack (2.2.3)
84
+ rack-protection (2.1.0)
88
85
  rack
89
- rack-test (0.6.3)
90
- rack (>= 1.0)
91
- rainbow (2.1.0)
92
- rake (11.2.2)
93
- rdoc (4.2.2)
94
- json (~> 1.4)
95
- redcarpet (3.3.4)
96
- rspec (3.5.0)
97
- rspec-core (~> 3.5.0)
98
- rspec-expectations (~> 3.5.0)
99
- rspec-mocks (~> 3.5.0)
100
- rspec-core (3.5.1)
101
- rspec-support (~> 3.5.0)
102
- rspec-expectations (3.5.0)
86
+ rack-test (1.1.0)
87
+ rack (>= 1.0, < 3)
88
+ rainbow (3.0.0)
89
+ rake (13.0.3)
90
+ rchardet (1.8.0)
91
+ rdoc (6.3.0)
92
+ redcarpet (3.5.1)
93
+ regexp_parser (2.1.1)
94
+ rexml (3.2.5)
95
+ rspec (3.10.0)
96
+ rspec-core (~> 3.10.0)
97
+ rspec-expectations (~> 3.10.0)
98
+ rspec-mocks (~> 3.10.0)
99
+ rspec-core (3.10.1)
100
+ rspec-support (~> 3.10.0)
101
+ rspec-expectations (3.10.1)
103
102
  diff-lcs (>= 1.2.0, < 2.0)
104
- rspec-support (~> 3.5.0)
105
- rspec-mocks (3.5.0)
103
+ rspec-support (~> 3.10.0)
104
+ rspec-mocks (3.10.2)
106
105
  diff-lcs (>= 1.2.0, < 2.0)
107
- rspec-support (~> 3.5.0)
108
- rspec-support (3.5.0)
109
- rubocop (0.42.0)
110
- parser (>= 2.3.1.1, < 3.0)
111
- powerpack (~> 0.1)
112
- rainbow (>= 1.99.1, < 3.0)
106
+ rspec-support (~> 3.10.0)
107
+ rspec-support (3.10.2)
108
+ rubocop (1.12.1)
109
+ parallel (~> 1.10)
110
+ parser (>= 3.0.0.0)
111
+ rainbow (>= 2.2.2, < 4.0)
112
+ regexp_parser (>= 1.8, < 3.0)
113
+ rexml
114
+ rubocop-ast (>= 1.2.0, < 2.0)
113
115
  ruby-progressbar (~> 1.7)
114
- unicode-display_width (~> 1.0, >= 1.0.1)
115
- ruby-progressbar (1.8.1)
116
- rubyzip (1.2.0)
117
- selenium-webdriver (2.53.4)
118
- childprocess (~> 0.5)
119
- rubyzip (~> 1.0)
120
- websocket (~> 1.0)
121
- semver (1.0.1)
122
- simplecov (0.12.0)
123
- docile (~> 1.1.0)
124
- json (>= 1.8, < 3)
125
- simplecov-html (~> 0.10.0)
126
- simplecov-html (0.10.0)
127
- sinatra (1.4.7)
128
- rack (~> 1.5)
129
- rack-protection (~> 1.4)
130
- tilt (>= 1.3, < 3)
131
- thread_safe (0.3.5)
132
- tilt (2.0.5)
133
- tzinfo (1.2.2)
134
- thread_safe (~> 0.1)
135
- unicode-display_width (1.1.0)
136
- watir-webdriver (0.9.1)
137
- selenium-webdriver (>= 2.46.2)
138
- websocket (1.2.3)
139
- websocket-driver (0.6.4)
116
+ unicode-display_width (>= 1.4.0, < 3.0)
117
+ rubocop-ast (1.4.1)
118
+ parser (>= 2.7.1.5)
119
+ ruby-debug-ide (0.7.2)
120
+ rake (>= 0.8.1)
121
+ ruby-progressbar (1.11.0)
122
+ ruby2_keywords (0.0.4)
123
+ rubyzip (2.3.0)
124
+ selenium-webdriver (3.142.7)
125
+ childprocess (>= 0.5, < 4.0)
126
+ rubyzip (>= 1.2.2)
127
+ semver2 (3.4.2)
128
+ simplecov (0.21.2)
129
+ docile (~> 1.1)
130
+ simplecov-html (~> 0.11)
131
+ simplecov_json_formatter (~> 0.1)
132
+ simplecov-html (0.12.3)
133
+ simplecov_json_formatter (0.1.2)
134
+ sinatra (2.1.0)
135
+ mustermann (~> 1.0)
136
+ rack (~> 2.2)
137
+ rack-protection (= 2.1.0)
138
+ tilt (~> 2.0)
139
+ thread_safe (0.3.6)
140
+ tilt (2.0.10)
141
+ tzinfo (2.0.4)
142
+ concurrent-ruby (~> 1.0)
143
+ unicode-display_width (2.0.0)
144
+ watir (6.19.1)
145
+ regexp_parser (>= 1.2, < 3)
146
+ selenium-webdriver (>= 3.142.7)
147
+ websocket-driver (0.7.3)
140
148
  websocket-extensions (>= 0.1.0)
141
- websocket-extensions (0.1.2)
142
- xpath (2.0.0)
143
- nokogiri (~> 1.3)
144
- yard (0.9.5)
149
+ websocket-extensions (0.1.5)
150
+ xpath (3.2.0)
151
+ nokogiri (~> 1.8)
152
+ yard (0.9.26)
153
+ zeitwerk (2.4.2)
145
154
 
146
155
  PLATFORMS
147
156
  ruby
148
157
 
149
158
  DEPENDENCIES
150
- activesupport (~> 4)
151
- arbre
152
- capybara (>= 2.5)
153
- codeclimate-test-reporter
154
- github-markup (~> 1.4)
155
- jeweler (~> 2.0)
159
+ activesupport
160
+ capybara (>= 3.0)
161
+ github-markup
162
+ jeweler
156
163
  poltergeist
157
- pullreview-coverage
158
- redcarpet (~> 3.3)
164
+ redcarpet
159
165
  rspec
160
- rubocop (~> 0.34)
166
+ rubocop
167
+ ruby-debug-ide
161
168
  simplecov
162
169
  sinatra
163
- watir-webdriver
170
+ watir
164
171
  yard (~> 0.8)
165
172
 
166
173
  BUNDLED WITH
167
- 1.11.2
174
+ 2.1.4
data/Makefile ADDED
@@ -0,0 +1,13 @@
1
+ .PHONY: help
2
+ DOCKER_IMAGE = lvl-up/page-magic
3
+
4
+ help:
5
+ @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
6
+
7
+ build: ## build project docker image
8
+ docker build -t $(DOCKER_IMAGE) .
9
+
10
+ test: ## Run tests
11
+ docker run -v $(PWD):/usr/src/app -t $(DOCKER_IMAGE) bundle exec rspec
12
+
13
+ all: test
data/README.md CHANGED
@@ -20,14 +20,34 @@ Well PageMagic might just be the answer!
20
20
 
21
21
  Give it a try and let us know what you think! There will undoubtedly be things that can be improved and issues that
22
22
  we are not aware of so your feedback/pull requests are greatly appreciated!
23
+
24
+ ##Under the hood
25
+ Under the hood PageMagic uses the totally brilliant [Capybara](https://github.com/teamcapybara/capybara) to benefit from its amazing cross browser support.
26
+
27
+ PageMagic builds on top of Capybara to build resuable models for webpages and website structure.
28
+
29
+ ##What about the other PageObject frameworks out there?
30
+ PageMagic isn't the first [PageObject](https://martinfowler.com/bliki/PageObject.html) framework to be written, indeed there are others out there that are totaly awesome e.g:
31
+ - [PageObject](https://github.com/cheezy/page-object)
32
+ - [SitePrism](https://github.com/natritmeyer/site_prism)
33
+
34
+ Whilst these APIs are great, PageMagic goes much further in the power it provides for:
35
+ - [modelling pages](defining-pages) and page components
36
+ - defining the [wait logic](#hooks) and [watchers](#watchers) that are required to build robust page objects that work reliably with javascript rich webpages.
37
+ - Supporting [page transitions](#page-mapping)
38
+
39
+ Check it out :)
40
+
41
+
23
42
  # Contents
24
43
 
25
44
  - [Installation](#installation)
26
45
  - [Quick Start](#quick-start)
27
46
  - [Defining Pages](#defining-pages)
28
47
  - [Elements](#elements)
48
+ - [Singlular Results](#singular-results)
49
+ - [Multiple Results](#multiple-results)
29
50
  - [Interacting with elements](#interacting-with-elements)
30
- - [Multple Results](#multiple-results)
31
51
  - [Sub elements](#sub-elements)
32
52
  - [Custom elements](#custom-elements)
33
53
  - [Hooks](#hooks)
@@ -95,7 +115,12 @@ class Github
95
115
  end
96
116
  ```
97
117
  ## Elements
98
- Defining elements is easy. The following example defines a text field called 'search_field' that can be found using its name which is 'q'
118
+ Defining elements is easy. Just give the:
119
+ - element_type
120
+ - id to refer to it by
121
+ - selector to find it in the page
122
+
123
+ The following example defines a text field called 'search_field' that can be found using its name which is 'q'
99
124
 
100
125
  ```ruby
101
126
  class Github
@@ -105,27 +130,66 @@ class Github
105
130
  end
106
131
  ```
107
132
 
108
- ### Interacting with elements
109
- Elements are defined with an id which is the name of the method you will use to reference it. In the above example,
110
- the text field was defined with the ide `:search_field`.
133
+ Element types supported by PageMagic are:
134
+ - text_field
135
+ - button
136
+ - link
137
+ - checkbox
138
+ - select_list
139
+ - radio
140
+ - textarea
111
141
 
112
- After visiting a page you are will get a `Session` object. Elements can be accessed through the session itself.
142
+ PageMagic is very powerful and provides a number of different ways to define a page element so for more details please look at the [API](http://www.rubydoc.info/gems/page_magic/PageMagic%2FElements:element)
113
143
 
114
- ```ruby
115
- page.search_field.set 'page_magic'
116
- ```
144
+ ### Singular Results
145
+ The element types written above are the method names you need to use in order to define elements of those types on your pages.
117
146
 
118
- #### Multiple Results
119
- Where an element has been scoped to return multple results, these will be returned in an array.
147
+ Using them as they are written above will tell PageMagic to expect to find only one element using the selector you supply. Finding more than one result will cause PageMagic to raise an `AmbiguousQueryException`
148
+
149
+ ### Multiple Results
150
+ Applying an 's' to the end of the element definition method name will tell PageMagic that more than one result can be returned using the given selector.
151
+
152
+ results are returned in an `Array`.
120
153
  ```ruby
121
154
  class ResultsPage
122
155
  include PageMagic
123
- element :results, css: '.repo-list-item'
156
+ elements :results, css: '.repo-list-item'
124
157
  end
125
158
 
126
159
  page.results #=> Array<Element>
127
160
  ```
128
161
 
162
+
163
+ ### Interacting with elements
164
+ ```ruby
165
+ class Github
166
+ include PageMagic
167
+
168
+ text_field :search_field, name: 'q'
169
+ end
170
+ ```
171
+ Elements are defined with an id which is the name of the method you will use to reference it. In the above example,
172
+ the text field was defined with the id `:search_field`.
173
+
174
+ After visiting a page you are will get a `Session` object. Elements can be accessed through the session itself.
175
+
176
+ ```ruby
177
+ page.search_field.set 'page_magic'
178
+ ```
179
+ PageMagic sits on top of [Capybara](https://github.com/teamcapybara/capybara) and ultimately returns capybara elements elements for you interact with. Interacting with the element types above is done by calling the following methods:
180
+
181
+ element | method
182
+ --- | ---
183
+ text_field | set(String)
184
+ checkbox | set(Boolean)
185
+ radio | choose(String)
186
+ link | click
187
+ text_area | set(String)
188
+ select_list | select(String)
189
+
190
+ Typically you will not need to know much about Capybara itself but there will be times when you want to interact with elements at a lower level.In this case please see Capybara's [API](http://www.rubydoc.info/github/jnicklas/capybara/Capybara/Node/Element) For more information.
191
+
192
+
129
193
  ### Sub Elements
130
194
  If your pages are complex you can use PageMagic to compose pages, their elements and subelements to as many levels as
131
195
  you need to.
@@ -251,13 +315,13 @@ end
251
315
  In the above example the selector looks for an element that has a link containing text that includes that organisation.
252
316
  The example uses a named parameter and is invoked as follows.
253
317
  ```ruby
254
- page.results(organisation: 'Ladtech')
318
+ page.results(organisation: 'lvlup')
255
319
  ```
256
320
 
257
321
  # Starting a session
258
322
  To start a PageMagic session simply decide what browser you want to use and pass it to PageMagic's `.session` method
259
323
  ```ruby
260
- session = PageMagic.session(browser: :chrome, url: 'https://www.github.com)
324
+ session = PageMagic.session(browser: :chrome, url: 'https://www.github.com')
261
325
  ```
262
326
 
263
327
  Your session won't do much besides navigating to the given url until you have [mapped pages](#page-mapping) to it, so