web-object 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +24 -0
- data/Rakefile +5 -0
- data/cucumber.yml +1 -0
- data/features/pages/web_object_form_page.rb +81 -0
- data/features/scenarios/alert.feature +8 -0
- data/features/scenarios/element_interaction.feature +38 -0
- data/features/scenarios/element_property.feature +33 -0
- data/features/step_definitions/alert_steps.rb +30 -0
- data/features/step_definitions/element_interaction_steps.rb +55 -0
- data/features/step_definitions/element_property_steps.rb +26 -0
- data/features/support/env.rb +5 -0
- data/features/support/hooks.rb +21 -0
- data/lib/web-object.rb +7 -0
- data/lib/web-object/conditions/alert.rb +14 -0
- data/lib/web-object/conditions/element_interaction.rb +124 -0
- data/lib/web-object/conditions/element_property.rb +76 -0
- data/lib/web-object/conditions/url_n_title.rb +0 -0
- data/lib/web-object/conditions/window_n_frame.rb +0 -0
- data/lib/web-object/version +1 -1
- metadata +35 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a2fffeb3acf048b6957849ea39944b1c75a8c23
|
4
|
+
data.tar.gz: 0ea943c4bb8d2532da1539d40d490e40c6818249
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cafb9c804bb6d197f8d2ad9ada415a51e0921fa2466703c5b7f39702d876467e3260e6c902442f0eb2a8387e2a71d49c1611b0b56513f99361e43866c291f5b5
|
7
|
+
data.tar.gz: 2ea732d8685f7ba1a2e6128e100870e735ee0d979722f7fc7a2786fd5f780659eb08de51ba7695d1812a7e2d1485bed492f39974f1b1cfe7684b0443c9934a1d
|
data/README.md
CHANGED
@@ -154,6 +154,30 @@ class Login < WebObject
|
|
154
154
|
end
|
155
155
|
end
|
156
156
|
```
|
157
|
+
|
158
|
+
## <a name="webconditions"></a> WebConditions :eyes:
|
159
|
+
Always envied the fancy ExpectedConditions class which Java and Python has where they smoothly pass a condition within the WebDriver explicit wait object... And when it comes to Ruby, you need to go through a painfully lenghty procudere of creating your own method or fallback to other framweworks like Capybara or Watir loosing the original WebDriver flavor.
|
160
|
+
|
161
|
+
Well, not to worry as web-object gem to the rescue.
|
162
|
+
|
163
|
+
web-object gem is now equipped with an extensive list of WebConditions (we do not want to be called people who copied the name from Java so we call it WebConditions). It can be used for both waiting for a particular condition inside the wait.until object and also in rspec assertions.
|
164
|
+
|
165
|
+
|
166
|
+
How to use it then: here is how:
|
167
|
+
```
|
168
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 30)
|
169
|
+
wait.until{alert_present?}
|
170
|
+
```
|
171
|
+
or
|
172
|
+
```
|
173
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 30) # Create wait object
|
174
|
+
wait.until{element_is_visible(element)} # Pass a condition with web element parameter
|
175
|
+
wait.until{element_is_invisible(:id => 'some_button')} # or just pass a condition with a locator hash
|
176
|
+
|
177
|
+
```
|
178
|
+
|
179
|
+
Full list of WebConditions and [documentation](https://github.com/krupani/web-object/wiki) on how to use can be found [here](https://github.com/krupani/web-object/wiki).
|
180
|
+
|
157
181
|
|
158
182
|
## <a name="alias"></a> Aliases :eyes:
|
159
183
|
There is an option to use PageObject class instead of WebObject.
|
data/Rakefile
ADDED
data/cucumber.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
default: --require features --no-source --color --format progress --format html --out wo_report.html
|
@@ -0,0 +1,81 @@
|
|
1
|
+
class WebObjectFormPage < WebObject
|
2
|
+
|
3
|
+
element :delayed_alert_button, {:id => 'alert_button'}
|
4
|
+
|
5
|
+
element :toggle_visibility_button, {:id => 'toggle_visibility'}
|
6
|
+
element :toggle_visibility_text, {:id => 'visible_text'}
|
7
|
+
|
8
|
+
element :toggle_presence_button, {:id => 'toggle_presence'}
|
9
|
+
element :toggle_presence_link, {:id => 'toggle_presence_link'}, error=false
|
10
|
+
|
11
|
+
element :toggle_enability_button, {:id => 'enable_button'}
|
12
|
+
element :toggle_enability_field, {:id => 'enable_field'}
|
13
|
+
|
14
|
+
element :delayed_clickability_button, {:id => 'delayed_clickability'}
|
15
|
+
element :desired_clickable_button, {name: 'clickable_button'}
|
16
|
+
|
17
|
+
element :toggle_attribute_button, {:id => 'toggle_attribute'}
|
18
|
+
element :empty_attribute_button, {:id => 'empty_attribute'}
|
19
|
+
|
20
|
+
|
21
|
+
def wait_for_text_visibility(state)
|
22
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
23
|
+
if state=="visible"
|
24
|
+
# puts ExpectedConditions.instance_methods
|
25
|
+
wait.until{element_is_visible(toggle_visibility_text)}
|
26
|
+
else
|
27
|
+
wait.until{element_is_invisible(toggle_visibility_text)}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def wait_for_link_presence(state)
|
32
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
33
|
+
if state=="present"
|
34
|
+
wait.until{element_is_present(:id => 'toggle_presence_link')}
|
35
|
+
else
|
36
|
+
wait.until{element_is_absent(:id => 'toggle_presence_link')}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def wait_for_field_to_be_enabled(state)
|
41
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
42
|
+
if state=="enabled"
|
43
|
+
wait.until{element_is_enabled(toggle_enability_field)}
|
44
|
+
else
|
45
|
+
wait.until{element_is_disabled(toggle_enability_field)}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def wait_for_button_to_be_clickable
|
50
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
51
|
+
wait.until{element_is_clickable(desired_clickable_button)}
|
52
|
+
end
|
53
|
+
|
54
|
+
def wait_for_attribute(state)
|
55
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
56
|
+
if state=="present"
|
57
|
+
wait.until{attribute_is_present(toggle_attribute_button,'style')}
|
58
|
+
else
|
59
|
+
wait.until{attribute_is_absent(toggle_attribute_button,'style')}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def wait_for_attribute_value(state)
|
64
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
65
|
+
if state=="set"
|
66
|
+
wait.until{attribute_is_not_empty(empty_attribute_button,'style')}
|
67
|
+
else
|
68
|
+
wait.until{attribute_is_empty(empty_attribute_button,'style')}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def wait_for_attribute_value_match(action)
|
73
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
|
74
|
+
if action=="match"
|
75
|
+
wait.until{attribute_to_match(toggle_attribute_button, 'style', 'color: red;')}
|
76
|
+
else
|
77
|
+
wait.until{attribute_to_contain(toggle_attribute_button, 'style', 'red')}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
Feature: As a web-object author, I want to make sure
|
2
|
+
conditional method around alerts work fine.
|
3
|
+
|
4
|
+
Scenario: Verify condition for delayed alert
|
5
|
+
Given I am on web-object form page
|
6
|
+
When I follow delayed_alert button
|
7
|
+
And I wait for alert to appear
|
8
|
+
Then I verify n accept alert
|
@@ -0,0 +1,38 @@
|
|
1
|
+
Feature: As a web-object author, I want to make sure
|
2
|
+
conditional method around element presence and visibility work fine.
|
3
|
+
|
4
|
+
Background:
|
5
|
+
Given I am on web-object form page
|
6
|
+
|
7
|
+
Scenario: Verify condition for delayed visibility and invisibility
|
8
|
+
And I verify text is invisible
|
9
|
+
When I follow toggle_visibility button
|
10
|
+
Then I wait for text to become visible
|
11
|
+
And I verify text is visible
|
12
|
+
When I follow toggle_visibility button
|
13
|
+
Then I wait for text to become invisible
|
14
|
+
And I verify text is invisible
|
15
|
+
|
16
|
+
Scenario: Verify condition for delayed presence and absence
|
17
|
+
And I verify link is absent
|
18
|
+
When I follow toggle_presence button
|
19
|
+
Then I wait for link to be present
|
20
|
+
And I verify link is present
|
21
|
+
When I follow toggle_presence button
|
22
|
+
Then I wait for link to be absent
|
23
|
+
And I verify link is absent
|
24
|
+
|
25
|
+
Scenario: Verify condition for delayed enabling and disabling
|
26
|
+
And I verify text field is disabled
|
27
|
+
When I follow toggle_enabling button
|
28
|
+
Then I wait for text field to be enabled
|
29
|
+
And I verify text field is enabled
|
30
|
+
When I follow toggle_enabling button
|
31
|
+
Then I wait for text field to be disabled
|
32
|
+
And I verify text field is disabled
|
33
|
+
|
34
|
+
Scenario: Verify conditions for delayed clickability
|
35
|
+
And I verify desired button is not clickable
|
36
|
+
When I follow delayed_clickability button
|
37
|
+
Then I wait for desired button to be clickable
|
38
|
+
And I verify desired button is now clickable
|
@@ -0,0 +1,33 @@
|
|
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 attribute presence and absence
|
8
|
+
Given I verify element attribute is absent
|
9
|
+
When I follow toggle_attribute button
|
10
|
+
Then I wait for attribute to be present
|
11
|
+
And I verify element attribute is present
|
12
|
+
When I follow toggle_attribute button
|
13
|
+
Then I wait for attribute to be absent
|
14
|
+
And I verify element attribute is absent
|
15
|
+
|
16
|
+
Scenario: Verify condition for delayed attribute value presence and absence
|
17
|
+
Given I verify element attribute value is set
|
18
|
+
When I follow empty_attribute button
|
19
|
+
Then I wait for attribute value to be empty
|
20
|
+
And I verify element attribute value is empty
|
21
|
+
When I follow empty_attribute button
|
22
|
+
Then I wait for attribute value to be set
|
23
|
+
And I verify element attribute value is set
|
24
|
+
|
25
|
+
Scenario: Verify condition for attribute value to match expected value
|
26
|
+
When I follow toggle_attribute button
|
27
|
+
Then I wait for attribute to be match value
|
28
|
+
And I verify element attribute is present
|
29
|
+
|
30
|
+
Scenario: Verify condition for attribute value to contain expected text
|
31
|
+
When I follow toggle_attribute button
|
32
|
+
Then I wait for attribute to be contain value
|
33
|
+
And I verify element attribute is present
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Given(/^I am on web-object form page$/) do
|
2
|
+
url = "https://krupani.github.io/web-object"
|
3
|
+
# url = "file:////Users/kaushal.rupani/projects/web-object/docs/index.html"
|
4
|
+
@driver.get(url)
|
5
|
+
end
|
6
|
+
|
7
|
+
When(/^I follow ([^"]*) button$/) do |btn|
|
8
|
+
wo = WebObjectFormPage.new(@driver)
|
9
|
+
case btn
|
10
|
+
when "delayed_alert"
|
11
|
+
wo.delayed_alert_button.click
|
12
|
+
when "toggle_visibility"
|
13
|
+
wo.toggle_visibility_button.click
|
14
|
+
when "toggle_presence"
|
15
|
+
wo.toggle_presence_button.click
|
16
|
+
when "toggle_enabling"
|
17
|
+
wo.toggle_enability_button.click
|
18
|
+
when "delayed_clickability"
|
19
|
+
wo.delayed_clickability_button.click
|
20
|
+
when "toggle_attribute"
|
21
|
+
wo.toggle_attribute_button.click
|
22
|
+
when "empty_attribute"
|
23
|
+
wo.empty_attribute_button.click
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Then(/^I wait for alert to appear$/) do
|
28
|
+
wait = Selenium::WebDriver::Wait.new(timeout: 10)
|
29
|
+
wait.until{alert_present?}
|
30
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
|
2
|
+
Then(/^I wait for text to become (invisible|visible)$/) do |state|
|
3
|
+
wo = WebObjectFormPage.new(@driver)
|
4
|
+
wo.wait_for_text_visibility(state)
|
5
|
+
end
|
6
|
+
|
7
|
+
Then(/^I verify n accept alert$/) do
|
8
|
+
alert = @driver.switch_to.alert
|
9
|
+
expect(alert.text).to eq "This is a delayed alert, came 5 seconds late"
|
10
|
+
alert.accept
|
11
|
+
end
|
12
|
+
|
13
|
+
And(/^I verify text is (visible|invisible)$/) do |state|
|
14
|
+
wo = WebObjectFormPage.new(@driver)
|
15
|
+
state=="visible" ? flag=true : flag=false
|
16
|
+
expect(wo.toggle_visibility_text.displayed?).to be flag
|
17
|
+
end
|
18
|
+
|
19
|
+
And(/^I verify link is (absent|present)$/) do |state|
|
20
|
+
wo = WebObjectFormPage.new(@driver)
|
21
|
+
if state=="present"
|
22
|
+
expect(wo.toggle_presence_link.displayed?).to be true
|
23
|
+
else
|
24
|
+
expect(wo.toggle_presence_link).to be false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Then(/^I wait for link to be (present|absent)$/) do |state|
|
29
|
+
wo = WebObjectFormPage.new(@driver)
|
30
|
+
wo.wait_for_link_presence(state)
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
And(/^I verify text field is (enabled|disabled)$/) do |state|
|
35
|
+
wo = WebObjectFormPage.new(@driver)
|
36
|
+
state=="enabled" ? flag=true : flag=false
|
37
|
+
expect(wo.toggle_enability_field.enabled?).to be flag
|
38
|
+
end
|
39
|
+
|
40
|
+
Then(/^I wait for text field to be (enabled|disabled)$/) do |state|
|
41
|
+
wo = WebObjectFormPage.new(@driver)
|
42
|
+
wo.wait_for_field_to_be_enabled(state)
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
And(/^I verify desired button is (now|not) clickable$/) do |state|
|
47
|
+
wo = WebObjectFormPage.new(@driver)
|
48
|
+
state=="now" ? flag=true : flag=false
|
49
|
+
expect(element_is_clickable(wo.desired_clickable_button)).to be flag
|
50
|
+
end
|
51
|
+
|
52
|
+
Then(/^I wait for desired button to be clickable$/) do
|
53
|
+
wo = WebObjectFormPage.new(@driver)
|
54
|
+
wo.wait_for_button_to_be_clickable
|
55
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Given(/^I verify element attribute is (present|absent)$/) do |state|
|
2
|
+
wo = WebObjectFormPage.new(@driver)
|
3
|
+
state=="present" ? flag="color: red;" : flag=""
|
4
|
+
expect(wo.toggle_attribute_button.attribute('style')).to eq flag
|
5
|
+
end
|
6
|
+
|
7
|
+
Then(/^I wait for attribute to be (present|absent)$/) do |state|
|
8
|
+
wo = WebObjectFormPage.new(@driver)
|
9
|
+
wo.wait_for_attribute(state)
|
10
|
+
end
|
11
|
+
|
12
|
+
Given(/^I verify element attribute value is (set|empty)$/) do |state|
|
13
|
+
wo = WebObjectFormPage.new(@driver)
|
14
|
+
state=="set" ? flag="background: yellow" : flag=""
|
15
|
+
expect(wo.empty_attribute_button.attribute('style')).to include flag
|
16
|
+
end
|
17
|
+
|
18
|
+
Then(/^I wait for attribute value to be (set|empty)$/) do |state|
|
19
|
+
wo = WebObjectFormPage.new(@driver)
|
20
|
+
wo.wait_for_attribute_value(state)
|
21
|
+
end
|
22
|
+
|
23
|
+
Then(/^I wait for attribute to be (match|contain) value$/) do |action|
|
24
|
+
wo = WebObjectFormPage.new(@driver)
|
25
|
+
wo.wait_for_attribute_value_match(action)
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
driver = Selenium::WebDriver.for :chrome
|
2
|
+
|
3
|
+
Before do
|
4
|
+
@driver = driver
|
5
|
+
@driver.manage.delete_all_cookies
|
6
|
+
end
|
7
|
+
|
8
|
+
After do |scenario|
|
9
|
+
if scenario.failed?
|
10
|
+
begin
|
11
|
+
encoded_img = driver.screenshot_as(:base64)
|
12
|
+
embed("#{encoded_img}", "image/png;base64")
|
13
|
+
rescue
|
14
|
+
p "*** Could not take failed scenario screenshot ***"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
at_exit do
|
20
|
+
driver.quit
|
21
|
+
end
|
data/lib/web-object.rb
CHANGED
@@ -2,6 +2,13 @@ require 'selenium-webdriver'
|
|
2
2
|
require 'web-object/element'
|
3
3
|
require 'web-object/elements'
|
4
4
|
|
5
|
+
require 'web-object/conditions/alert'
|
6
|
+
require 'web-object/conditions/element_interaction'
|
7
|
+
require 'web-object/conditions/element_property'
|
8
|
+
|
9
|
+
include WebConditions
|
10
|
+
|
11
|
+
|
5
12
|
class WebObject
|
6
13
|
include Element
|
7
14
|
include Elements
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module WebConditions
|
2
|
+
|
3
|
+
# @method alert_present?
|
4
|
+
# @return [Boolean true] -- if alert is present on page
|
5
|
+
# @return [Boolean false] -- if alert is absent from page
|
6
|
+
|
7
|
+
def alert_present?
|
8
|
+
@driver.switch_to.alert
|
9
|
+
true
|
10
|
+
rescue
|
11
|
+
false
|
12
|
+
end
|
13
|
+
|
14
|
+
end #module WebConditions
|
@@ -0,0 +1,124 @@
|
|
1
|
+
module WebConditions
|
2
|
+
|
3
|
+
# @method element_is_clickable(ele)
|
4
|
+
# @param ele [WebElement object]
|
5
|
+
# @param ele [locator Hash] -- eg {:id => 'some_id'}]
|
6
|
+
# @return [Boolean true] -- if element is clickable(visible and enabled) on page
|
7
|
+
# @return [Boolean false] -- if element is not clickable(visible and enabled) on page
|
8
|
+
|
9
|
+
def element_is_clickable(ele)
|
10
|
+
element = element_or_locator(ele)
|
11
|
+
if element_is_visible(element) and element_is_enabled(element)
|
12
|
+
true
|
13
|
+
else
|
14
|
+
false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
# @method element_is_enabled(ele)
|
20
|
+
# @param ele [WebElement object]
|
21
|
+
# @param ele [locator Hash] -- eg {:id => 'some_id'}]
|
22
|
+
# @return [Boolean true] -- if element is enabled on page
|
23
|
+
# @return [Boolean false] -- if element is disabled on page
|
24
|
+
|
25
|
+
def element_is_enabled(ele)
|
26
|
+
element = element_or_locator(ele)
|
27
|
+
if element.enabled?
|
28
|
+
true
|
29
|
+
else
|
30
|
+
false
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
# @method element_is_disabled(ele)
|
36
|
+
# @param ele [WebElement object]
|
37
|
+
# @param ele [locator Hash] -- eg {:id => 'some_id'}]
|
38
|
+
# @return [Boolean true] -- if element is disabled on page
|
39
|
+
# @return [Boolean false] -- if element is enabled on page
|
40
|
+
|
41
|
+
def element_is_disabled(ele)
|
42
|
+
element = element_or_locator(ele)
|
43
|
+
if element.enabled?
|
44
|
+
false
|
45
|
+
else
|
46
|
+
true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
# @method element_is_visible(ele)
|
52
|
+
# @param ele [WebElement object]
|
53
|
+
# @param ele [locator Hash] -- eg {:id => 'some_id'}]
|
54
|
+
# @return [Boolean true] -- if element is visible on page
|
55
|
+
# @return [Boolean false] -- if element is invisible / hidden on page
|
56
|
+
|
57
|
+
def element_is_visible(ele)
|
58
|
+
element = element_or_locator(ele)
|
59
|
+
if element.displayed?
|
60
|
+
true
|
61
|
+
else
|
62
|
+
false
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
# @method element_is_invisible(ele)
|
68
|
+
# @param ele [WebElement object]
|
69
|
+
# @param ele [locator Hash] -- eg {:id => 'some_id'}]
|
70
|
+
# @return [Boolean true] -- if element is invisible / hidden on page
|
71
|
+
# @return [Boolean false] -- if element is visible on page
|
72
|
+
|
73
|
+
def element_is_invisible(ele)
|
74
|
+
element = element_or_locator(ele)
|
75
|
+
if element.displayed?
|
76
|
+
false
|
77
|
+
else
|
78
|
+
true
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
# @method element_is_present(ele)
|
84
|
+
# @param locator [locator Hash] -- eg {:id => 'some_id'}]
|
85
|
+
# @return [Boolean true] -- if element is present in DOM of page
|
86
|
+
# @return [Boolean false] -- if element is absent from DOM of page
|
87
|
+
|
88
|
+
def element_is_present(locator)
|
89
|
+
begin
|
90
|
+
@driver.find_element(locator)
|
91
|
+
true
|
92
|
+
rescue
|
93
|
+
false
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# @method element_is_absent(ele)
|
98
|
+
# @param locator [locator Hash] -- eg {:id => 'some_id'}]
|
99
|
+
# @return [Boolean true] -- if element is absent in DOM of page
|
100
|
+
# @return [Boolean false] -- if element is present from DOM of page
|
101
|
+
|
102
|
+
def element_is_absent(locator)
|
103
|
+
begin
|
104
|
+
@driver.find_element(locator)
|
105
|
+
false
|
106
|
+
rescue
|
107
|
+
true
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# internal method
|
112
|
+
def element_or_locator(ele)
|
113
|
+
if ele.class == Hash
|
114
|
+
begin
|
115
|
+
@driver.find_element(ele)
|
116
|
+
rescue
|
117
|
+
raise 'Looks like the element itself is not present on the page, Please wait for element to be present'
|
118
|
+
end
|
119
|
+
else
|
120
|
+
ele
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
end #module WebConditions
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module WebConditions
|
2
|
+
|
3
|
+
|
4
|
+
# @method attribute_is_present(ele,attr)
|
5
|
+
# @param ele [WebElement object]
|
6
|
+
# @param ele [locator Hash] -- eg {:id => 'some_id'}]
|
7
|
+
# @param attr [String] -- attribute that need to be checked for presence
|
8
|
+
# @return [Boolean true] -- if element attribute is found in the html tag in page source
|
9
|
+
# @return [Boolean false] -- if element attribute is not found in the html tag in page source
|
10
|
+
|
11
|
+
def attribute_is_present(ele,attr)
|
12
|
+
element = element_or_locator(ele)
|
13
|
+
if element.attribute(attr).empty?
|
14
|
+
false
|
15
|
+
else
|
16
|
+
true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
alias_method :attribute_is_not_empty, :attribute_is_present
|
20
|
+
|
21
|
+
|
22
|
+
# @method attribute_is_absent(ele,attr)
|
23
|
+
# @param ele [WebElement object]
|
24
|
+
# @param ele [locator Hash] -- eg {:id => 'some_id'}]
|
25
|
+
# @param attr [String] -- attribute that need to be checked for absence
|
26
|
+
# @return [Boolean true] -- if element attribute is not found in the html tag in page source
|
27
|
+
# @return [Boolean false] -- if element attribute is found in the html tag in page source
|
28
|
+
|
29
|
+
def attribute_is_absent(ele,attr)
|
30
|
+
element = element_or_locator(ele)
|
31
|
+
if element.attribute(attr).empty?
|
32
|
+
true
|
33
|
+
else
|
34
|
+
false
|
35
|
+
end
|
36
|
+
end
|
37
|
+
alias_method :attribute_is_empty, :attribute_is_absent
|
38
|
+
|
39
|
+
|
40
|
+
# @method attribute_to_match(ele,attr)
|
41
|
+
# @param ele [WebElement object]
|
42
|
+
# @param ele [locator Hash] -- eg {:id => 'some_id'}]
|
43
|
+
# @param attr [String] -- attribute that need to be checked for actual value in page source
|
44
|
+
# @param item [String] -- expected value of attribute that needs to be exactly matched with actual in page source
|
45
|
+
# @return [Boolean true] -- if element attribute value is exact match with expected value in the html tag in page source
|
46
|
+
# @return [Boolean false] -- if element attribute is mismatch with expected value in the html tag in page source
|
47
|
+
|
48
|
+
def attribute_to_match(ele,attr,item)
|
49
|
+
element = element_or_locator(ele)
|
50
|
+
if element.attribute(attr).to_s == (item.to_s)
|
51
|
+
true
|
52
|
+
else
|
53
|
+
false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
# @method attribute_to_match(ele,attr)
|
59
|
+
# @param ele [WebElement object]
|
60
|
+
# @param ele [locator Hash] -- eg {:id => 'some_id'}]
|
61
|
+
# @param attr [String] -- attribute that need to be checked for actual value in page source
|
62
|
+
# @param item [String] -- substring value of attribute that needs to be contained within actual in page source
|
63
|
+
# @return [Boolean true] -- if element attribute substring is present within actual value in the html tag in page source
|
64
|
+
# @return [Boolean false] -- if actual attribute value does not contain passed substring
|
65
|
+
|
66
|
+
def attribute_to_include(ele,attr,item)
|
67
|
+
element = element_or_locator(ele)
|
68
|
+
if element.attribute(attr).to_s.include?(item.to_s)
|
69
|
+
true
|
70
|
+
else
|
71
|
+
false
|
72
|
+
end
|
73
|
+
end
|
74
|
+
alias_method :attribute_to_contain, :attribute_to_include
|
75
|
+
|
76
|
+
end #module WebConditions
|
File without changes
|
File without changes
|
data/lib/web-object/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web-object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.3'
|
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-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: selenium-webdriver
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '3'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '3'
|
11
|
+
date: 2017-05-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
27
13
|
description: Helps in generating page object style framework using original webdriver
|
28
14
|
flavor
|
29
15
|
email:
|
@@ -34,7 +20,23 @@ extra_rdoc_files: []
|
|
34
20
|
files:
|
35
21
|
- LICENCE
|
36
22
|
- README.md
|
23
|
+
- Rakefile
|
24
|
+
- cucumber.yml
|
25
|
+
- features/pages/web_object_form_page.rb
|
26
|
+
- features/scenarios/alert.feature
|
27
|
+
- features/scenarios/element_interaction.feature
|
28
|
+
- features/scenarios/element_property.feature
|
29
|
+
- features/step_definitions/alert_steps.rb
|
30
|
+
- features/step_definitions/element_interaction_steps.rb
|
31
|
+
- features/step_definitions/element_property_steps.rb
|
32
|
+
- features/support/env.rb
|
33
|
+
- features/support/hooks.rb
|
37
34
|
- lib/web-object.rb
|
35
|
+
- lib/web-object/conditions/alert.rb
|
36
|
+
- lib/web-object/conditions/element_interaction.rb
|
37
|
+
- lib/web-object/conditions/element_property.rb
|
38
|
+
- lib/web-object/conditions/url_n_title.rb
|
39
|
+
- lib/web-object/conditions/window_n_frame.rb
|
38
40
|
- lib/web-object/element.rb
|
39
41
|
- lib/web-object/elements.rb
|
40
42
|
- lib/web-object/version
|
@@ -50,7 +52,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
52
|
requirements:
|
51
53
|
- - ">="
|
52
54
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
55
|
+
version: 1.9.3
|
54
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
57
|
requirements:
|
56
58
|
- - ">="
|
@@ -58,8 +60,20 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
60
|
version: '0'
|
59
61
|
requirements: []
|
60
62
|
rubyforge_project:
|
61
|
-
rubygems_version: 2.
|
63
|
+
rubygems_version: 2.6.12
|
62
64
|
signing_key:
|
63
65
|
specification_version: 4
|
64
|
-
summary: Page Objects in Original WebDriver flavor
|
65
|
-
|
66
|
+
summary: Page Objects in Original WebDriver flavor + Vast list of Expected Conditions
|
67
|
+
and WebDriver Utilities
|
68
|
+
test_files:
|
69
|
+
- features/pages/web_object_form_page.rb
|
70
|
+
- features/scenarios/alert.feature
|
71
|
+
- features/scenarios/element_interaction.feature
|
72
|
+
- features/scenarios/element_property.feature
|
73
|
+
- features/step_definitions/alert_steps.rb
|
74
|
+
- features/step_definitions/element_interaction_steps.rb
|
75
|
+
- features/step_definitions/element_property_steps.rb
|
76
|
+
- features/support/env.rb
|
77
|
+
- features/support/hooks.rb
|
78
|
+
- cucumber.yml
|
79
|
+
- Rakefile
|