web-object 0.3 → 0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/features/pages/web_object_form_page.rb +66 -20
- data/features/scenarios/element_property.feature +19 -1
- data/features/scenarios/text.feature +29 -0
- data/features/scenarios/title.feature +14 -0
- data/features/scenarios/url.feature +14 -0
- data/features/step_definitions/alert_steps.rb +11 -3
- data/features/step_definitions/element_property_steps.rb +17 -1
- data/features/step_definitions/text_steps.rb +30 -0
- data/features/step_definitions/title_steps.rb +13 -0
- data/features/step_definitions/url_steps.rb +13 -0
- data/lib/web-object/conditions/element_property.rb +50 -0
- data/lib/web-object/conditions/elements_count.rb +52 -0
- data/lib/web-object/conditions/text.rb +49 -0
- data/lib/web-object/conditions/title.rb +32 -0
- data/lib/web-object/conditions/url.rb +32 -0
- data/lib/web-object/conditions/waiting.rb +11 -0
- data/lib/web-object/version +1 -1
- data/lib/web-object.rb +5 -0
- metadata +19 -4
- data/lib/web-object/conditions/url_n_title.rb +0 -0
- data/lib/web-object/conditions/window_n_frame.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8eae72fe16cf8d5395d86ba7cf83f07647ad9ea6
|
4
|
+
data.tar.gz: '038bdd6033856b97ee0c8a06b1ca60350bc9107a'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af376321aad8c7ad1bc2cd691060a17cd2a26cce3e441536320ccc3c09373e4f8447dfb8e3f8b32b6489f26e20dbfd02b04ede340bce1ba079d6f7ecd94b5a9f
|
7
|
+
data.tar.gz: 668e9197b50b0191d6b40d9c67ddc544a29b1e60fdb4d35bed31b6a4087693c330ba041708ee8d0fefa3d49da5bac2f73d072f86a946cd2e966ca39654c0c050
|
data/README.md
CHANGED
@@ -16,6 +16,7 @@ commands on it like send_keys, click, displayed? .. and so on...
|
|
16
16
|
- [Finding Multiple Elements](#find_elements)
|
17
17
|
- [Syntax Summary](#summary)
|
18
18
|
- [Usage](#usage)
|
19
|
+
- [WebConditions](#webconditions)
|
19
20
|
- [Aliases](#alias)
|
20
21
|
- [Contributing](#contributing)
|
21
22
|
- [Issues](#issues)
|
@@ -1,11 +1,13 @@
|
|
1
1
|
class WebObjectFormPage < WebObject
|
2
2
|
|
3
|
+
element :body_element, {:tag_name => 'body'}
|
3
4
|
element :delayed_alert_button, {:id => 'alert_button'}
|
4
5
|
|
5
6
|
element :toggle_visibility_button, {:id => 'toggle_visibility'}
|
6
7
|
element :toggle_visibility_text, {:id => 'visible_text'}
|
7
8
|
|
8
9
|
element :toggle_presence_button, {:id => 'toggle_presence'}
|
10
|
+
element :toggle_presence_div, {:id => 'presence'}
|
9
11
|
element :toggle_presence_link, {:id => 'toggle_presence_link'}, error=false
|
10
12
|
|
11
13
|
element :toggle_enability_button, {:id => 'enable_button'}
|
@@ -16,65 +18,109 @@ class WebObjectFormPage < WebObject
|
|
16
18
|
|
17
19
|
element :toggle_attribute_button, {:id => 'toggle_attribute'}
|
18
20
|
element :empty_attribute_button, {:id => 'empty_attribute'}
|
21
|
+
|
22
|
+
element :delayed_url_button, {:id => 'delayed_url'}
|
23
|
+
element :delayed_title_button, {:id => 'delayed_title'}
|
19
24
|
|
25
|
+
element :delayed_more_cells_button, {:id => 'delayed_more_cells'}
|
26
|
+
element :delayed_less_cells_button, {:id => 'delayed_less_cells'}
|
27
|
+
elements :count_of_cells, {:css => 'tr#row>td'}
|
28
|
+
|
29
|
+
def initialize(driver)
|
30
|
+
@wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
31
|
+
super(driver)
|
32
|
+
end
|
20
33
|
|
21
34
|
def wait_for_text_visibility(state)
|
22
|
-
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
23
35
|
if state=="visible"
|
24
36
|
# puts ExpectedConditions.instance_methods
|
25
|
-
wait.until{element_is_visible(toggle_visibility_text)}
|
37
|
+
@wait.until{element_is_visible(toggle_visibility_text)}
|
26
38
|
else
|
27
|
-
wait.until{element_is_invisible(toggle_visibility_text)}
|
39
|
+
@wait.until{element_is_invisible(toggle_visibility_text)}
|
28
40
|
end
|
29
41
|
end
|
30
42
|
|
31
43
|
def wait_for_link_presence(state)
|
32
|
-
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
33
44
|
if state=="present"
|
34
|
-
wait.until{element_is_present(:id => 'toggle_presence_link')}
|
45
|
+
@wait.until{element_is_present(:id => 'toggle_presence_link')}
|
35
46
|
else
|
36
|
-
wait.until{element_is_absent(:id => 'toggle_presence_link')}
|
47
|
+
@wait.until{element_is_absent(:id => 'toggle_presence_link')}
|
37
48
|
end
|
38
49
|
end
|
39
50
|
|
40
51
|
def wait_for_field_to_be_enabled(state)
|
41
|
-
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
42
52
|
if state=="enabled"
|
43
|
-
wait.until{element_is_enabled(toggle_enability_field)}
|
53
|
+
@wait.until{element_is_enabled(toggle_enability_field)}
|
44
54
|
else
|
45
|
-
wait.until{element_is_disabled(toggle_enability_field)}
|
55
|
+
@wait.until{element_is_disabled(toggle_enability_field)}
|
46
56
|
end
|
47
57
|
end
|
48
58
|
|
49
59
|
def wait_for_button_to_be_clickable
|
50
|
-
wait
|
51
|
-
wait.until{element_is_clickable(desired_clickable_button)}
|
60
|
+
@wait.until{element_is_clickable(desired_clickable_button)}
|
52
61
|
end
|
53
62
|
|
54
63
|
def wait_for_attribute(state)
|
55
|
-
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
56
64
|
if state=="present"
|
57
|
-
wait.until{attribute_is_present(toggle_attribute_button,'style')}
|
65
|
+
@wait.until{attribute_is_present(toggle_attribute_button,'style')}
|
58
66
|
else
|
59
|
-
wait.until{attribute_is_absent(toggle_attribute_button,'style')}
|
67
|
+
@wait.until{attribute_is_absent(toggle_attribute_button,'style')}
|
60
68
|
end
|
61
69
|
end
|
62
70
|
|
63
71
|
def wait_for_attribute_value(state)
|
64
|
-
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
65
72
|
if state=="set"
|
66
|
-
wait.until{attribute_is_not_empty(empty_attribute_button,'style')}
|
73
|
+
@wait.until{attribute_is_not_empty(empty_attribute_button,'style')}
|
67
74
|
else
|
68
|
-
wait.until{attribute_is_empty(empty_attribute_button,'style')}
|
75
|
+
@wait.until{attribute_is_empty(empty_attribute_button,'style')}
|
69
76
|
end
|
70
77
|
end
|
71
78
|
|
72
79
|
def wait_for_attribute_value_match(action)
|
73
|
-
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
74
80
|
if action=="match"
|
75
|
-
wait.until{attribute_to_match(toggle_attribute_button, 'style', 'color: red;')}
|
81
|
+
@wait.until{attribute_to_match(toggle_attribute_button, 'style', 'color: red;')}
|
82
|
+
else
|
83
|
+
@wait.until{attribute_to_contain(toggle_attribute_button, 'style', 'red')}
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def wait_for_url(action, expected)
|
88
|
+
if action=="match"
|
89
|
+
@wait.until{url_to_match(expected)}
|
90
|
+
else
|
91
|
+
@wait.until{url_to_include(expected)}
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def wait_for_title(action, expected)
|
96
|
+
if action=="match"
|
97
|
+
@wait.until{title_to_match(expected)}
|
98
|
+
else
|
99
|
+
@wait.until{title_to_include(expected)}
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def wait_for_text_presence(txt)
|
104
|
+
@wait.until{text_to_be_on_page(txt)}
|
105
|
+
end
|
106
|
+
|
107
|
+
def wait_for_text_in_element(action, ele, txt)
|
108
|
+
if action == "present"
|
109
|
+
@wait.until{text_in_element_to_match(ele,txt)}
|
110
|
+
elsif action == 'included'
|
111
|
+
@wait.until{text_in_element_to_include(ele,txt)}
|
112
|
+
else
|
113
|
+
@wait.until{text_in_element_to_contain(ele,txt)}
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def wait_for_element_count(type,count)
|
118
|
+
if type == 'greater'
|
119
|
+
waiting(10).until{elements_count_to_be_more_than({:css=>'#row>td'}, count)}
|
120
|
+
elsif type == 'less'
|
121
|
+
waiting(10).until{elements_count_to_be_less_than({:css=>'#row>td'}, count)}
|
76
122
|
else
|
77
|
-
|
123
|
+
waiting(10).until{elements_count_to_be_equal_to({:css=>'#row>td'}, count)}
|
78
124
|
end
|
79
125
|
end
|
80
126
|
|
@@ -30,4 +30,22 @@ Feature: As a web-object author, I want to make sure
|
|
30
30
|
Scenario: Verify condition for attribute value to contain expected text
|
31
31
|
When I follow toggle_attribute button
|
32
32
|
Then I wait for attribute to be contain value
|
33
|
-
And I verify element attribute is present
|
33
|
+
And I verify element attribute is present
|
34
|
+
|
35
|
+
Scenario: Verify condition for element count to be greater than expected
|
36
|
+
When I follow delayed_more_cells button
|
37
|
+
Then I wait for element count to be greater than 7
|
38
|
+
And I verify element count is greater than 7
|
39
|
+
|
40
|
+
Scenario: Verify condition for element count to be less than expected
|
41
|
+
When I follow delayed_less_cells button
|
42
|
+
Then I wait for element count to be less than 3
|
43
|
+
And I verify element count is less than 3
|
44
|
+
|
45
|
+
Scenario: Verify condition for element count to be equal to expected
|
46
|
+
When I follow delayed_more_cells button
|
47
|
+
Then I wait for element count to be equal to 9
|
48
|
+
And I verify element count is equal to 9
|
49
|
+
When I follow delayed_less_cells button
|
50
|
+
Then I wait for element count to be equal to 2
|
51
|
+
And I verify element count is equal to 2
|
@@ -0,0 +1,29 @@
|
|
1
|
+
Feature: As a web-object author, I want to make sure
|
2
|
+
conditional method around element properties work fine.
|
3
|
+
|
4
|
+
Background:
|
5
|
+
Given I am on web-object form page
|
6
|
+
|
7
|
+
Scenario: Verify condition for delayed text presence and absence
|
8
|
+
And I verify text is absent
|
9
|
+
When I follow toggle_presence button
|
10
|
+
Then I wait for text to be present
|
11
|
+
And I verify text is present
|
12
|
+
|
13
|
+
Scenario: Verify condition for delayed text presence inside element
|
14
|
+
And I verify text is absent inside element
|
15
|
+
When I follow toggle_presence button
|
16
|
+
Then I wait for text to be present inside element
|
17
|
+
And I verify text is present inside element
|
18
|
+
|
19
|
+
Scenario: Verify condition for delayed text presence inside element
|
20
|
+
And I verify text is absent inside element
|
21
|
+
When I follow toggle_presence button
|
22
|
+
Then I wait for text to be included inside element
|
23
|
+
And I verify text is included inside element
|
24
|
+
|
25
|
+
Scenario: Verify condition for delayed text presence inside element using alias method
|
26
|
+
And I verify text is absent inside element
|
27
|
+
When I follow toggle_presence button
|
28
|
+
Then I wait for text to be contained inside element
|
29
|
+
And I verify text is included inside element
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Feature: As a web-object author, I want to make sure
|
2
|
+
conditional method around titles work fine.
|
3
|
+
|
4
|
+
Scenario: Verify condition for delayed alert
|
5
|
+
Given I am on web-object form page
|
6
|
+
When I follow delayed_title button
|
7
|
+
And I wait for title to update
|
8
|
+
Then I verify newly updated title
|
9
|
+
|
10
|
+
Scenario: Verify condition for delayed alert
|
11
|
+
Given I am on web-object form page
|
12
|
+
When I follow delayed_title button
|
13
|
+
And I wait for title to contain a sub string
|
14
|
+
Then I verify newly updated title
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Feature: As a web-object author, I want to make sure
|
2
|
+
conditional method around urls work fine.
|
3
|
+
|
4
|
+
Scenario: Verify condition for delayed alert
|
5
|
+
Given I am on web-object form page
|
6
|
+
When I follow delayed_url button
|
7
|
+
And I wait for url to update
|
8
|
+
Then I verify newly updated url
|
9
|
+
|
10
|
+
Scenario: Verify condition for delayed alert
|
11
|
+
Given I am on web-object form page
|
12
|
+
When I follow delayed_url button
|
13
|
+
And I wait for url to contain a sub string
|
14
|
+
Then I verify newly updated url
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Given(/^I am on web-object form page$/) do
|
2
|
-
|
3
|
-
|
4
|
-
@driver.get(
|
2
|
+
# @base_url = "https://krupani.github.io/web-object"
|
3
|
+
@base_url = "file:///Users/kaushal.rupani/projects/web-object/docs/index.html"
|
4
|
+
@driver.get(@base_url)
|
5
5
|
end
|
6
6
|
|
7
7
|
When(/^I follow ([^"]*) button$/) do |btn|
|
@@ -21,6 +21,14 @@ When(/^I follow ([^"]*) button$/) do |btn|
|
|
21
21
|
wo.toggle_attribute_button.click
|
22
22
|
when "empty_attribute"
|
23
23
|
wo.empty_attribute_button.click
|
24
|
+
when "delayed_url"
|
25
|
+
wo.delayed_url_button.click
|
26
|
+
when "delayed_title"
|
27
|
+
wo.delayed_title_button.click
|
28
|
+
when "delayed_more_cells"
|
29
|
+
wo.delayed_more_cells_button.click
|
30
|
+
when "delayed_less_cells"
|
31
|
+
wo.delayed_less_cells_button.click
|
24
32
|
end
|
25
33
|
end
|
26
34
|
|
@@ -23,4 +23,20 @@ end
|
|
23
23
|
Then(/^I wait for attribute to be (match|contain) value$/) do |action|
|
24
24
|
wo = WebObjectFormPage.new(@driver)
|
25
25
|
wo.wait_for_attribute_value_match(action)
|
26
|
-
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Then(/^I wait for element count to be (greater|less|equal) (?:than|to) (\d+)$/) do |type,count|
|
29
|
+
wo = WebObjectFormPage.new(@driver)
|
30
|
+
wo.wait_for_element_count(type, count)
|
31
|
+
end
|
32
|
+
|
33
|
+
And(/^I verify element count is (greater|less|equal) (?:than|to) (\d+)$/) do |type,count|
|
34
|
+
wo = WebObjectFormPage.new(@driver)
|
35
|
+
if type=='greater'
|
36
|
+
expect(wo.count_of_cells.size).to be > count.to_i
|
37
|
+
elsif type == 'less'
|
38
|
+
expect(wo.count_of_cells.size).to be < count.to_i
|
39
|
+
else
|
40
|
+
expect(wo.count_of_cells.size).to eq count.to_i
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
And(/^I verify text is (absent|present)$/) do |state|
|
2
|
+
wo = WebObjectFormPage.new(@driver)
|
3
|
+
if state=="present"
|
4
|
+
expect(wo.body_element.text).to include "This Link was recently added into DOM"
|
5
|
+
else
|
6
|
+
expect(wo.body_element.text).not_to include "This Link was recently added into DOM"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
Then(/^I wait for text to be (present|absent)$/) do |state|
|
11
|
+
wo = WebObjectFormPage.new(@driver)
|
12
|
+
wo.wait_for_text_presence("This Link was recently added into DOM")
|
13
|
+
end
|
14
|
+
|
15
|
+
And(/^I verify text is (absent|present|included) inside element$/) do |state|
|
16
|
+
wo = WebObjectFormPage.new(@driver)
|
17
|
+
if state=="present"
|
18
|
+
expect(wo.toggle_presence_div.text).to include "This Link was recently added into DOM"
|
19
|
+
elsif state == "included"
|
20
|
+
expect(wo.toggle_presence_div.text).to include "This Link was recently added into DOM"
|
21
|
+
else
|
22
|
+
expect(wo.toggle_presence_div.text).not_to include "This Link was recently added into DOM"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Then(/^I wait for text to be (present|included|contained) inside element$/) do |state|
|
27
|
+
wo = WebObjectFormPage.new(@driver)
|
28
|
+
wo.wait_for_text_in_element(state, wo.toggle_presence_div, "This Link was recently added into DOM")
|
29
|
+
end
|
30
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
And(/^I wait for title to contain a sub string$/) do
|
2
|
+
wo = WebObjectFormPage.new(@driver)
|
3
|
+
wo.wait_for_title("contain", "New")
|
4
|
+
end
|
5
|
+
|
6
|
+
And(/^I wait for title to update$/) do
|
7
|
+
wo = WebObjectFormPage.new(@driver)
|
8
|
+
wo.wait_for_title("match", 'This is New Title')
|
9
|
+
end
|
10
|
+
|
11
|
+
Then(/^I verify newly updated title$/) do
|
12
|
+
expect(@driver.title).to eq "This is New Title"
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
And(/^I wait for url to contain a sub string$/) do
|
2
|
+
wo = WebObjectFormPage.new(@driver)
|
3
|
+
wo.wait_for_url("contain", "newly_appended")
|
4
|
+
end
|
5
|
+
|
6
|
+
And(/^I wait for url to update$/) do
|
7
|
+
wo = WebObjectFormPage.new(@driver)
|
8
|
+
wo.wait_for_url("match", @base_url+"#newly_appended")
|
9
|
+
end
|
10
|
+
|
11
|
+
Then(/^I verify newly updated url$/) do
|
12
|
+
expect(@driver.current_url).to include("#newly_appended")
|
13
|
+
end
|
@@ -73,4 +73,54 @@ module WebConditions
|
|
73
73
|
end
|
74
74
|
alias_method :attribute_to_contain, :attribute_to_include
|
75
75
|
|
76
|
+
|
77
|
+
# @method elements_count_to_be_more_than(ele,count)
|
78
|
+
# @param ele [Array of WebElement object]
|
79
|
+
# @param ele [locator Hash] -- eg {:id => 'some_id'}]
|
80
|
+
# @param count [Fixnum] -- expected count of elements present on page
|
81
|
+
# @return [Boolean true] -- if actual count found on page is greater than expected count passed in param
|
82
|
+
# @return [Boolean false] -- if actual count found on page is less than expected count passed in param
|
83
|
+
|
84
|
+
def elements_count_to_be_more_than(loc,count)
|
85
|
+
elements = @driver.find_elements(loc)
|
86
|
+
if elements.size > count.to_i
|
87
|
+
true
|
88
|
+
else
|
89
|
+
false
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
# @method elements_count_to_be_less_than(ele,count)
|
95
|
+
# @param ele [Array of WebElement object]
|
96
|
+
# @param ele [locator Hash] -- eg {:id => 'some_id'}]
|
97
|
+
# @param count [Fixnum] -- expected count of elements present on page
|
98
|
+
# @return [Boolean true] -- if actual count found on page is less than expected count passed in param
|
99
|
+
# @return [Boolean false] -- if actual count found on page is greater than expected count passed in param
|
100
|
+
|
101
|
+
def elements_count_to_be_less_than(loc,count)
|
102
|
+
elements = @driver.find_elements(loc)
|
103
|
+
if elements.size < count.to_i
|
104
|
+
true
|
105
|
+
else
|
106
|
+
false
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
# @method elements_count_to_be_equal_to(ele,count)
|
111
|
+
# @param ele [Array of WebElement object]
|
112
|
+
# @param ele [locator Hash] -- eg {:id => 'some_id'}]
|
113
|
+
# @param count [Fixnum] -- expected count of elements present on page
|
114
|
+
# @return [Boolean true] -- if actual count found on page is less than expected count passed in param
|
115
|
+
# @return [Boolean false] -- if actual count found on page is greater than expected count passed in param
|
116
|
+
|
117
|
+
def elements_count_to_be_equal_to(loc,count)
|
118
|
+
elements = @driver.find_elements(loc)
|
119
|
+
if elements.size == count.to_i
|
120
|
+
true
|
121
|
+
else
|
122
|
+
false
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
76
126
|
end #module WebConditions
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module WebConditions
|
2
|
+
|
3
|
+
# @method elements_count_to_be_more_than(ele,count)
|
4
|
+
# @param ele [Array of WebElement object]
|
5
|
+
# @param ele [locator Hash] -- eg {:id => 'some_id'}]
|
6
|
+
# @param count [Fixnum] -- expected count of elements present on page
|
7
|
+
# @return [Boolean true] -- if actual count found on page is greater than expected count passed in param
|
8
|
+
# @return [Boolean false] -- if actual count found on page is less than expected count passed in param
|
9
|
+
|
10
|
+
def elements_count_to_be_more_than(loc,count)
|
11
|
+
elements = @driver.find_elements(loc)
|
12
|
+
if elements.size > count.to_i
|
13
|
+
true
|
14
|
+
else
|
15
|
+
false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
# @method elements_count_to_be_less_than(ele,count)
|
21
|
+
# @param ele [Array of WebElement object]
|
22
|
+
# @param ele [locator Hash] -- eg {:id => 'some_id'}]
|
23
|
+
# @param count [Fixnum] -- expected count of elements present on page
|
24
|
+
# @return [Boolean true] -- if actual count found on page is less than expected count passed in param
|
25
|
+
# @return [Boolean false] -- if actual count found on page is greater than expected count passed in param
|
26
|
+
|
27
|
+
def elements_count_to_be_less_than(loc,count)
|
28
|
+
elements = @driver.find_elements(loc)
|
29
|
+
if elements.size < count.to_i
|
30
|
+
true
|
31
|
+
else
|
32
|
+
false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# @method elements_count_to_be_equal_to(ele,count)
|
37
|
+
# @param ele [Array of WebElement object]
|
38
|
+
# @param ele [locator Hash] -- eg {:id => 'some_id'}]
|
39
|
+
# @param count [Fixnum] -- expected count of elements present on page
|
40
|
+
# @return [Boolean true] -- if actual count found on page is less than expected count passed in param
|
41
|
+
# @return [Boolean false] -- if actual count found on page is greater than expected count passed in param
|
42
|
+
|
43
|
+
def elements_count_to_be_equal_to(loc,count)
|
44
|
+
elements = @driver.find_elements(loc)
|
45
|
+
if elements.size == count.to_i
|
46
|
+
true
|
47
|
+
else
|
48
|
+
false
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end #module WebConditions
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module WebConditions
|
2
|
+
|
3
|
+
# @method text_to_be_on_page(txt)
|
4
|
+
# @param txt [String]
|
5
|
+
# @return [Boolean true] -- if text is found in the body of page
|
6
|
+
# @return [Boolean false] -- if text is not found in the body of page
|
7
|
+
|
8
|
+
def text_to_be_on_page(txt)
|
9
|
+
# puts element_or_locator({:tag_name => 'body'}).text
|
10
|
+
if element_or_locator({:tag_name => 'body'}).text.include?(txt)
|
11
|
+
true
|
12
|
+
else
|
13
|
+
false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# @method text_in_element_to_match(ele,attr)
|
18
|
+
# @param ele [WebElement object]
|
19
|
+
# @param ele [locator Hash] -- eg {:id => 'some_id'}]
|
20
|
+
# @param txt [String] -- text that will be checked in the body of the page
|
21
|
+
# @return [Boolean true] -- if text is found inside element and is exact match of the passed text in parameter
|
22
|
+
# @return [Boolean false] -- if text is found inside element and is not an exact match of the passed text in parameter
|
23
|
+
|
24
|
+
def text_in_element_to_match(ele, txt)
|
25
|
+
if element_or_locator(ele).text == txt
|
26
|
+
true
|
27
|
+
else
|
28
|
+
false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# @method text_in_element_to_match(ele,attr)
|
33
|
+
# @param ele [WebElement object]
|
34
|
+
# @param ele [locator Hash] -- eg {:id => 'some_id'}]
|
35
|
+
# @param txt [String] -- text that will be checked in the body of the page
|
36
|
+
# @return [Boolean true] -- if text is found inside element and is exact match of the passed text in parameter
|
37
|
+
# @return [Boolean false] -- if text is found inside element and is not an exact match of the passed text in parameter
|
38
|
+
# @alias text_in_element_to_contain(txt) -- alternative name for this method, can be used as both
|
39
|
+
|
40
|
+
def text_in_element_to_include(ele, txt)
|
41
|
+
if element_or_locator(ele).text.include?(txt)
|
42
|
+
true
|
43
|
+
else
|
44
|
+
false
|
45
|
+
end
|
46
|
+
end
|
47
|
+
alias_method :text_in_element_to_contain, :text_in_element_to_include
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module WebConditions
|
2
|
+
|
3
|
+
# @method title_to_match
|
4
|
+
# @param [title] -- expected title to match the actual title of the web page
|
5
|
+
# @return [Boolean true] -- if expected title matches the actual title on the web page
|
6
|
+
# @return [Boolean false] -- if expected title does not match the actual title on the web page
|
7
|
+
|
8
|
+
def title_to_match(title)
|
9
|
+
actual = @driver.title
|
10
|
+
if actual == title
|
11
|
+
true
|
12
|
+
else
|
13
|
+
false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# @method title_to_include
|
18
|
+
# @param [title] -- expected title to match the actual title of the web page
|
19
|
+
# @return [Boolean true] -- if expected title is included in the actual title on the web page
|
20
|
+
# @return [Boolean false] -- if expected title is not included in the actual title on the web page
|
21
|
+
|
22
|
+
def title_to_include(title)
|
23
|
+
actual = @driver.title
|
24
|
+
if actual.include?(title)
|
25
|
+
true
|
26
|
+
else
|
27
|
+
false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
alias_method :title_to_contain, :title_to_include
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module WebConditions
|
2
|
+
|
3
|
+
# @method url_to_match
|
4
|
+
# @param [url] -- expected url to match the actual url on the browser
|
5
|
+
# @return [Boolean true] -- if expected url matches the actual url on the browser
|
6
|
+
# @return [Boolean false] -- if expected url does not match the actual url on the browser
|
7
|
+
|
8
|
+
def url_to_match(url)
|
9
|
+
actual = @driver.current_url
|
10
|
+
if actual == url
|
11
|
+
true
|
12
|
+
else
|
13
|
+
false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# @method url_to_include
|
18
|
+
# @param [url] -- part of the expected url to be present in actual url in the browser
|
19
|
+
# @return [Boolean true] -- if expected url in parameter in present in actual url
|
20
|
+
# @return [Boolean false] -- if expected url in parameter in not present in actual url
|
21
|
+
|
22
|
+
def url_to_include(url)
|
23
|
+
actual = @driver.current_url
|
24
|
+
if actual.include?(url)
|
25
|
+
true
|
26
|
+
else
|
27
|
+
false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
alias_method :url_to_contain, :url_to_include
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module WebConditions
|
2
|
+
|
3
|
+
# @method waiting(time_in_secs)
|
4
|
+
# @param time_in_secs [Fixnum] -- Maximum amount of time a condition needs to wait
|
5
|
+
# @return [object of WebDriver::Wait class]
|
6
|
+
|
7
|
+
def waiting(time_in_secs)
|
8
|
+
Selenium::WebDriver::Wait.new(:timeout => time_in_secs.to_i)
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
data/lib/web-object/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4
|
data/lib/web-object.rb
CHANGED
@@ -5,6 +5,11 @@ require 'web-object/elements'
|
|
5
5
|
require 'web-object/conditions/alert'
|
6
6
|
require 'web-object/conditions/element_interaction'
|
7
7
|
require 'web-object/conditions/element_property'
|
8
|
+
require 'web-object/conditions/url'
|
9
|
+
require 'web-object/conditions/title'
|
10
|
+
require 'web-object/conditions/text'
|
11
|
+
require 'web-object/conditions/waiting'
|
12
|
+
require 'web-object/conditions/elements_count'
|
8
13
|
|
9
14
|
include WebConditions
|
10
15
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web-object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kaushal Rupani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Helps in generating page object style framework using original webdriver
|
14
14
|
flavor
|
@@ -26,17 +26,26 @@ files:
|
|
26
26
|
- features/scenarios/alert.feature
|
27
27
|
- features/scenarios/element_interaction.feature
|
28
28
|
- features/scenarios/element_property.feature
|
29
|
+
- features/scenarios/text.feature
|
30
|
+
- features/scenarios/title.feature
|
31
|
+
- features/scenarios/url.feature
|
29
32
|
- features/step_definitions/alert_steps.rb
|
30
33
|
- features/step_definitions/element_interaction_steps.rb
|
31
34
|
- features/step_definitions/element_property_steps.rb
|
35
|
+
- features/step_definitions/text_steps.rb
|
36
|
+
- features/step_definitions/title_steps.rb
|
37
|
+
- features/step_definitions/url_steps.rb
|
32
38
|
- features/support/env.rb
|
33
39
|
- features/support/hooks.rb
|
34
40
|
- lib/web-object.rb
|
35
41
|
- lib/web-object/conditions/alert.rb
|
36
42
|
- lib/web-object/conditions/element_interaction.rb
|
37
43
|
- lib/web-object/conditions/element_property.rb
|
38
|
-
- lib/web-object/conditions/
|
39
|
-
- lib/web-object/conditions/
|
44
|
+
- lib/web-object/conditions/elements_count.rb
|
45
|
+
- lib/web-object/conditions/text.rb
|
46
|
+
- lib/web-object/conditions/title.rb
|
47
|
+
- lib/web-object/conditions/url.rb
|
48
|
+
- lib/web-object/conditions/waiting.rb
|
40
49
|
- lib/web-object/element.rb
|
41
50
|
- lib/web-object/elements.rb
|
42
51
|
- lib/web-object/version
|
@@ -70,9 +79,15 @@ test_files:
|
|
70
79
|
- features/scenarios/alert.feature
|
71
80
|
- features/scenarios/element_interaction.feature
|
72
81
|
- features/scenarios/element_property.feature
|
82
|
+
- features/scenarios/text.feature
|
83
|
+
- features/scenarios/title.feature
|
84
|
+
- features/scenarios/url.feature
|
73
85
|
- features/step_definitions/alert_steps.rb
|
74
86
|
- features/step_definitions/element_interaction_steps.rb
|
75
87
|
- features/step_definitions/element_property_steps.rb
|
88
|
+
- features/step_definitions/text_steps.rb
|
89
|
+
- features/step_definitions/title_steps.rb
|
90
|
+
- features/step_definitions/url_steps.rb
|
76
91
|
- features/support/env.rb
|
77
92
|
- features/support/hooks.rb
|
78
93
|
- cucumber.yml
|
File without changes
|
File without changes
|