pageify 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +60 -17
- data/lib/pageify.rb +2 -2
- data/lib/pageify/page_object.rb +4 -4
- data/spec/page_object_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79f70b1d1b54b94a46aac17cc21306777a6e88e9
|
4
|
+
data.tar.gz: 6aaefb805f16b5610ada28ef173ef53ee705a6b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df29c5b9b1dd89e59a69264d9d944b54b0a5f5537de77e4c6f6da717782c0957b9dedb60d141be4b53ed0991037e5784ba013db1524ae8ea9580806885494b84
|
7
|
+
data.tar.gz: b2c869a51faca11d22e9ff82b68b410b082d34776cec7607b720a3250cfb1a9b02790ee81627f50e3e08cea742d1c5e3c49a68a3d06bda1171671f305af52283
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Code Climate](https://codeclimate.com/github/paramadeep/pageify.png)](https://codeclimate.com/github/paramadeep/pageify) [![Dependency Status](https://gemnasium.com/paramadeep/pageify.svg)](https://gemnasium.com/paramadeep/pageify) [![Build Status](https://travis-ci.org/paramadeep/pageify.svg?branch=master)](https://travis-ci.org/paramadeep/pageify)
|
4
4
|
|
5
|
-
|
5
|
+
Simplest way to define page objects. Bonus, tremendously fast tests.
|
6
6
|
|
7
7
|
##Example
|
8
8
|
|
@@ -19,12 +19,12 @@ home_page: ".home"
|
|
19
19
|
```
|
20
20
|
Test steps looks like this
|
21
21
|
```ruby
|
22
|
-
home_page.login.user_name
|
23
|
-
home_page.login.password
|
24
|
-
home_page.login.submit
|
22
|
+
home_page.login.user_name.f.set "hi"
|
23
|
+
home_page.login.password.f.set "bla"
|
24
|
+
home_page.login.submit.f.click
|
25
25
|
|
26
|
-
home_page.profile_name
|
27
|
-
hoem_page.settings
|
26
|
+
home_page.profile_name.f.should match_text "hi"
|
27
|
+
hoem_page.settings.f.should be_visible
|
28
28
|
```
|
29
29
|
|
30
30
|
We will be able element whose locators are dynamic
|
@@ -35,17 +35,19 @@ products_page: ".products"
|
|
35
35
|
cost: ".cost"
|
36
36
|
```
|
37
37
|
```ruby
|
38
|
-
products_page.product("candy").details_row(1).cost
|
39
|
-
products_page.product("tyres").details_row(2).cost
|
38
|
+
products_page.product("candy").details_row(1).cost.f.should have_text "Rs.10"
|
39
|
+
products_page.product("tyres").details_row(2).cost.f.should have_text "Rs.20"
|
40
40
|
```
|
41
41
|
|
42
42
|
|
43
43
|
## Key benefits
|
44
44
|
|
45
|
+
- [Tests runs tremendously fast.] (https://github.com/paramadeep/pageify#how-tests-gets-faster-with-pageify)
|
45
46
|
- Your test will be more **readable**.
|
46
47
|
- **Eliminates duplicate** definition of selectors across test.
|
47
48
|
- **Easy Maintenance**.
|
48
49
|
|
50
|
+
|
49
51
|
## Usage
|
50
52
|
In your project Gemfile add
|
51
53
|
```ruby
|
@@ -64,26 +66,31 @@ gem 'pageify'
|
|
64
66
|
|
65
67
|
##Methods
|
66
68
|
|
67
|
-
###Get Element '
|
69
|
+
###Get Element 'f' or 'find'
|
68
70
|
```ruby
|
69
|
-
home_page.login.user_name
|
70
|
-
home_page.login.user_name
|
71
|
-
home_page.login.user_name
|
72
|
-
home_page.login.submit
|
71
|
+
home_page.login.user_name.f #=> user_name text box
|
72
|
+
home_page.login.user_name.f.set "hi" # set text box value
|
73
|
+
home_page.login.user_name.find.should have_value "hi" # assert value
|
74
|
+
home_page.login.submit.find.click
|
73
75
|
```
|
74
76
|
|
77
|
+
###Get Element Collection 'find_all'
|
78
|
+
```ruby
|
79
|
+
home_page.product.find_all #=> all products in page
|
80
|
+
home_page.product.find_all[0] #=> first product in page
|
81
|
+
```
|
75
82
|
|
76
|
-
###Get Selector '
|
83
|
+
###Get Selector 'selector'
|
77
84
|
At times we would need selector of the object
|
78
85
|
```ruby
|
79
|
-
home_page.login.user_name.
|
86
|
+
home_page.login.user_name.selector #=> ".home div.login input.user"
|
80
87
|
|
81
88
|
#check element doesn't exist
|
82
|
-
page.should_not have_selector home_page.login.user_name.
|
89
|
+
page.should_not have_selector home_page.login.user_name.selector
|
83
90
|
|
84
91
|
#using capybara actions
|
85
92
|
fill_in home_page.login.user_name.p, :with=> "hi"
|
86
|
-
click_on home_page.login.submit.
|
93
|
+
click_on home_page.login.submit.selector
|
87
94
|
```
|
88
95
|
|
89
96
|
##Splitting Long Page Definitions
|
@@ -106,3 +113,39 @@ search_results: '.search_results'
|
|
106
113
|
:section/product
|
107
114
|
|
108
115
|
```
|
116
|
+
|
117
|
+
## Experimental Feature
|
118
|
+
|
119
|
+
Making the test more readable is a constant persuite. Currently working on removing use of "find" or "f" in every step
|
120
|
+
|
121
|
+
```
|
122
|
+
#currently
|
123
|
+
home_page.login.user_name.find.set "used"
|
124
|
+
home_page.login.user_name.find.click "used"
|
125
|
+
|
126
|
+
#with experimaental work under progress the above will look like
|
127
|
+
home_page.login.user_name.set "used"
|
128
|
+
home_page.login.user_name.click "used"
|
129
|
+
```
|
130
|
+
You can try this in your test suite by
|
131
|
+
```
|
132
|
+
#instead of the adding the below line
|
133
|
+
require 'pageify/capybara'
|
134
|
+
|
135
|
+
# use this
|
136
|
+
require 'pageify/capybara_experimental'
|
137
|
+
```
|
138
|
+
**Note:** There will be a considrable drop in performance, with the use of this experimental feature. Once this performance drop is fixed, this could used in main stream.
|
139
|
+
|
140
|
+
## How tests gets faster with Pageify
|
141
|
+
|
142
|
+
Finding a street in a country, would be much faster when given state -> city -> area -> street, against searching just the street name.
|
143
|
+
|
144
|
+
Since we used entire hirerchy of the selector to locate an element, against specific selector, the identification of element gets really faster.
|
145
|
+
For example,
|
146
|
+
```
|
147
|
+
page.find(".user_name")
|
148
|
+
page.find(".home_page .login .user_name")
|
149
|
+
# The later would be much faster, scope for search is reduced to particular container at every level.
|
150
|
+
```
|
151
|
+
The effect gets magnified when the same is done on each and every step of, hundreds and thousand steps, tests.
|
data/lib/pageify.rb
CHANGED
@@ -14,9 +14,9 @@ module Pageify
|
|
14
14
|
element = PageObject.create(raw_row)
|
15
15
|
define_method(element.name) do |*arguments|
|
16
16
|
unless arguments.eql? []
|
17
|
-
|
17
|
+
element.full_selector = (element.self_selector % arguments).strip_quotes.strip
|
18
18
|
else
|
19
|
-
|
19
|
+
element.full_selector = (element.self_selector % '').strip_quotes.strip
|
20
20
|
end
|
21
21
|
element
|
22
22
|
end
|
data/lib/pageify/page_object.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class PageObject
|
2
|
-
attr_accessor :name,:parent,:self_selector,:intend
|
2
|
+
attr_accessor :name,:parent,:self_selector,:intend,:full_selector
|
3
3
|
|
4
4
|
def createChild (raw_row)
|
5
5
|
child = PageObject.create(raw_row)
|
@@ -11,9 +11,9 @@ class PageObject
|
|
11
11
|
child_selector = (child.self_selector % '').strip_quotes.strip
|
12
12
|
end
|
13
13
|
if child_selector.start_with? "&"
|
14
|
-
|
14
|
+
child.full_selector = @full_selector + child_selector.gsub(/^&/, "")
|
15
15
|
else
|
16
|
-
|
16
|
+
child.full_selector = @full_selector + " " + child_selector
|
17
17
|
end
|
18
18
|
child
|
19
19
|
end
|
@@ -28,7 +28,7 @@ class PageObject
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def selector
|
31
|
-
|
31
|
+
@full_selector.strip
|
32
32
|
end
|
33
33
|
|
34
34
|
def initialize (name,self_selector,intend)
|
data/spec/page_object_spec.rb
CHANGED
@@ -37,11 +37,11 @@ describe Pageify do
|
|
37
37
|
expect(@page.root.complex.arg(1).arg_nested.selector).to eq(".root .complex .arg:nth-of-type(1) .arg_nested")
|
38
38
|
end
|
39
39
|
|
40
|
-
it "
|
40
|
+
it "support multiple pages at the same time" do
|
41
41
|
p1 = @page.root.simple
|
42
42
|
p2 = @page.root.complex.nested
|
43
43
|
|
44
|
-
expect(p1.selector).to eq(".root .
|
44
|
+
expect(p1.selector).to eq(".root .simple")
|
45
45
|
expect(p2.selector).to eq(".root .complex .nested")
|
46
46
|
end
|
47
47
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pageify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Deepak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|