druid-ts 1.2.5 → 1.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a37878faec17d55dc5e46271488aa642a92a3f00
4
- data.tar.gz: cf7cfade0356638ddd7e22c310789f33c4cd60a8
2
+ SHA256:
3
+ metadata.gz: 0bc85b82790651f4995b6bfff19d44d5b1817d7663d325dfff35bfe371b7a910
4
+ data.tar.gz: 1e6a812da3665d7dc1478f26308279e91c8722e36077226887197688597a1029
5
5
  SHA512:
6
- metadata.gz: 351a66a011905ed2722a268153d9d9dbfbca1a276a51cbb2681a831823fa4c93785e193983aa8aa7831d9912883c2f160d8eeb55e15840206345b93064c635e9
7
- data.tar.gz: 56f28412001a34ad9c26dd3d43fff4141bad3774b567203b03dfdc22d48f5c715137b9cee773d303bf34914f7c360edf92c1d881ffb7b9b5c113cb11f198918a
6
+ metadata.gz: 80a5a12a176279950b9ff8fcea84d0d238fd19173b15432c8a18ea6d6e26c0b696f2a1de56a6eb6f831f1695a3903baead8556431820a3249622c2c086d2e66c
7
+ data.tar.gz: 341a7d92c16fec02628d56ff8158732507028e4691b8cdcb3eb7f09f8b50a8e8f574407c40503ccc372bd60035a090e62d6f64ad2da98cd1059c40c0497067af
@@ -2,7 +2,10 @@ sudo: required
2
2
  dist: trusty
3
3
  rvm:
4
4
  - 2.2.5
5
+ - 2.2.7
6
+ - 2.3.4
5
7
  - 2.3.1
8
+ - 2.4.1
6
9
  cache: bundler
7
10
  before_script:
8
11
  - export CHROME_BIN=/usr/bin/google-chrome
@@ -19,4 +22,5 @@ before_script:
19
22
  - sudo mv chromedriver /usr/local/bin
20
23
  script: bundle exec rake $RAKE_TASK
21
24
  env:
25
+ - RAKE_TASK=spec
22
26
  - RAKE_TASK=features:watir
data/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ === Version 1.2.6/ 2019-04-09
2
+ * Enhancements
3
+ * populate_page_with will work with anything that can be converted to a Hash
4
+ * Fixes
5
+ * Fixed present? when using with ActiveSupport
6
+ * Fixed issues with when_visible and when_not_visible
1
7
  === Version 1.2.5/ 2017-10-16
2
8
  * Enhancements
3
9
  * Added the ability to get the values of a table column
@@ -35,7 +35,6 @@ Feature: Elements
35
35
  And I should know its' tag name is "a"
36
36
  And I should know the attribute "readonly" is false
37
37
  And I should know the attribute "href" includes "success.html"
38
- And I should know its' value is ""
39
38
  And I should be able to click it
40
39
 
41
40
  Scenario: Button element methods
@@ -65,7 +64,6 @@ Feature: Elements
65
64
  Then I should know it exists
66
65
  And I should know it is visible
67
66
  And I should know its' text is "page-object rocks!"
68
- And I should know its' value is ""
69
67
  And I should know it is equal to itself
70
68
  And I should know its' tag name is "div"
71
69
  And I should know the attribute "readonly" is false
@@ -97,7 +95,6 @@ Feature: Elements
97
95
  When I retrieve a table element
98
96
  Then I should know it is visible
99
97
  Then I should know it exists
100
- And I should know its' value is ""
101
98
  And I should know its' text includes "Data1"
102
99
  And I should know it is equal to itself
103
100
  And I should know its' tag name is "table"
@@ -108,7 +105,6 @@ Feature: Elements
108
105
  When I retrieve table cell
109
106
  Then I should know it exists
110
107
  And I should know it is visible
111
- Then I should know its' value is ""
112
108
  And I should know its' text includes "Data4"
113
109
  And I should know it is equal to itself
114
110
  And I should know its' tag name is "td"
@@ -129,7 +125,6 @@ Feature: Elements
129
125
  Scenario: Image element methods
130
126
  When I get the image element
131
127
  Then I should know it exists
132
- Then I should know its' value is ""
133
128
  And I should know it is visible
134
129
  And I should know its' text includes ""
135
130
  And I should know it is equal to itself
@@ -155,7 +150,6 @@ Feature: Elements
155
150
  And I should know it is equal to itself
156
151
  And I should know its' tag name is "form"
157
152
  And I should know the attribute "readonly" is false
158
- And I should know its' value is ""
159
153
 
160
154
  Scenario: Text Area element methods
161
155
  When I retrieve the text area
@@ -26,7 +26,7 @@ end
26
26
 
27
27
  Then(/^I should be able to wait until a block returns true$/) do
28
28
  @element.wait_until do
29
- @element.visible?
29
+ @element.present?
30
30
  end
31
31
  end
32
32
 
@@ -29,7 +29,7 @@ Then(/^I should know its' text includes "(.*?)"$/) do |text|
29
29
  end
30
30
 
31
31
  Then(/^I should know it is not visible$/) do
32
- expect(@element.visible?).to be false
32
+ expect(@element.present?).to be false
33
33
  end
34
34
 
35
35
  When(/^I clear the text field$/) do
@@ -136,7 +136,7 @@ Then(/^I should know the html is "(.*)"$/) do |html|
136
136
  end
137
137
 
138
138
  Then(/^the heading element should be visible$/) do
139
- expect(@element.visible?).to be true
139
+ expect(@element.present?).to be true
140
140
  end
141
141
 
142
142
  When(/^I retrieve a div using data\-entity$/) do
@@ -84,9 +84,9 @@ Given(/^I am on the frame section page$/) do
84
84
  end
85
85
 
86
86
  Then(/^I should be able to access an element in the frame in the section repeatedly$/) do
87
- expect(@page.p_on_page_element).to be_visible
88
- expect(@page.frame_section.p_in_section_element).to be_visible
89
- expect(@page.frame_section.success_element).to be_visible
87
+ expect(@page.p_on_page_element).to be_present
88
+ expect(@page.frame_section.p_in_section_element).to be_present
89
+ expect(@page.frame_section.success_element).to be_present
90
90
  expect(@page.frame_section.success_element.text).to eq "this link should open the page success page"
91
91
  @page.frame_section.success
92
92
  expect(@page.text.strip).to eq 'Success'
@@ -21,7 +21,7 @@ Then(/^I should know it exists$/) do
21
21
  end
22
22
 
23
23
  Then(/^I should know it is visible$/) do
24
- expect(@element.visible?).to be true
24
+ expect(@element.present?).to be true
25
25
  end
26
26
 
27
27
  When(/^I select a link labeled "(.*?)" and index "(.*?)"$/) do |label, index|
@@ -266,6 +266,6 @@ When(/^I have a page section$/) do
266
266
  end
267
267
 
268
268
  Then(/^methods called on the section are passed to the root if missing$/) do
269
- expect { @section.visible? }.not_to raise_error
270
- expect(@section.visible?).to be true
269
+ expect { @section.present? }.not_to raise_error
270
+ expect(@section.present?).to be true
271
271
  end
@@ -23,6 +23,13 @@ module Druid
23
23
  not enabled?
24
24
  end
25
25
 
26
+ #
27
+ # return true if the element exists and is visible
28
+ #
29
+ def present?
30
+ element.present?
31
+ end
32
+
26
33
  #
27
34
  # compare this element to another to determine if they are equal
28
35
  # @return [Boolean]
@@ -33,7 +40,7 @@ module Druid
33
40
 
34
41
  def check_visible(timeout=Druid.default_element_wait)
35
42
  timed_loop(timeout) do |element|
36
- element.visible?
43
+ element.present?
37
44
  end
38
45
  # wait_until(timeout: timeout, message: "Element not visible in #{timeout} seconds", &:present?)
39
46
  end
@@ -116,6 +123,7 @@ module Druid
116
123
  element.wait_until(timeout: timeout, message: "Element not present in #{timeout} seconds", &:present?)
117
124
  self
118
125
  end
126
+ alias_method :when_visible, :when_present
119
127
 
120
128
  #
121
129
  # Waits until the element is not present
@@ -126,27 +134,7 @@ module Druid
126
134
  def when_not_present(timeout=Druid.default_element_wait)
127
135
  element.wait_while(timeout: timeout, message: "Element still present in #{timeout} seconds", &:present?)
128
136
  end
129
-
130
- #
131
- # Wait until the element is visible
132
- #
133
- # @param [Integer] (defaults to: 5) seconds to wait before timing out
134
- #
135
- def when_visible(timeout=Druid.default_element_wait)
136
- when_present(timeout)
137
- element.wait_until(timeout: timeout, message: "Element not visible in #{timeout} seconds", &:visible?)
138
- self
139
- end
140
-
141
- #
142
- # Waits until the element is not visible
143
- #
144
- # @param [Integer] (default to: 5) seconds to wait before timing out
145
- #
146
- def when_not_visible(timeout=Druid.default_element_wait)
147
- when_present(timeout)
148
- element.wait_while(timeout: timeout, message: "Element still visible after #{timeout} seconds", &:visible?)
149
- end
137
+ alias_method :when_not_visible, :when_not_present
150
138
 
151
139
  #
152
140
  # Waits until the block returns true
@@ -29,8 +29,8 @@ module Druid
29
29
  # false for a Checkbox or RadioButton.
30
30
  #
31
31
  def populate_page_with(data)
32
- data.each do |key, value|
33
- populate_section(key, value) if value.is_a?(Hash)
32
+ data.to_h.each do |key, value|
33
+ populate_section(key, value) if value.respond_to?(:to_h)
34
34
  populate_value(self, key, value)
35
35
  end
36
36
  end
@@ -39,7 +39,7 @@ module Druid
39
39
 
40
40
  def populate_section(section, data)
41
41
  return unless self.respond_to? section
42
- data.each do |key, value|
42
+ data.to_h.each do |key, value|
43
43
  populate_value(self.send(section), key, value)
44
44
  end
45
45
  end
@@ -98,7 +98,7 @@ module Druid
98
98
  return false if is_radiobuttongroup?(receiver, key)
99
99
  return true if (receiver.send "#{key}_element").tag_name == "textarea"
100
100
  element = receiver.send("#{key}_element")
101
- element.enabled? and element.visible?
101
+ element.enabled? and element.present?
102
102
  end
103
103
  end
104
104
  end
@@ -1,3 +1,3 @@
1
1
  module Druid
2
- VERSION = "1.2.5"
2
+ VERSION = "1.2.6"
3
3
  end
@@ -13,13 +13,13 @@ describe Druid::Elements::Element do
13
13
 
14
14
  context "on a druid" do
15
15
  it "should know when it is visible" do
16
- expect(we).to receive(:visible?).and_return(true)
17
- expect(element.visible?).to be true
16
+ expect(we).to receive(:present?).and_return(true)
17
+ expect(element.present?).to be true
18
18
  end
19
19
 
20
20
  it "should know when it is not visible" do
21
- expect(we).to receive(:visible?).and_return(false)
22
- expect(element.visible?).to be false
21
+ expect(we).to receive(:present?).and_return(false)
22
+ expect(element.present?).to be false
23
23
  end
24
24
 
25
25
  it "should know when it exists" do
@@ -62,11 +62,19 @@ describe Druid::Elements::Element do
62
62
  end
63
63
 
64
64
  it "should check if the element is visible" do
65
- expect(we).to receive(:visible?).and_return(false)
66
- expect(we).to receive(:visible?).and_return(true)
65
+ expect(we).to receive(:present?).and_return(false)
66
+ expect(we).to receive(:present?).and_return(true)
67
67
  expect(element.check_visible).to be true
68
68
  end
69
69
 
70
+ it "should check if the element is present" do
71
+ # simulate Active Support's Object#present? being included
72
+ allow_any_instance_of(Object).to receive(:present?)
73
+
74
+ expect(we).to receive(:present?)
75
+ element.present?
76
+ end
77
+
70
78
  it "should check if the element exists" do
71
79
  expect(we).to receive(:exists?).and_return(false)
72
80
  expect(we).to receive(:exists?).and_return(true)
@@ -92,15 +100,13 @@ describe Druid::Elements::Element do
92
100
 
93
101
  it "should be able to block until it is visible" do
94
102
  allow(we).to receive(:wait_until).with(timeout: 10, message: "Element not present in 10 seconds")
95
- allow(we).to receive(:wait_until).with(timeout: 10, message: "Element not visible in 10 seconds")
96
103
  allow(we).to receive(:displayed?).and_return(true)
97
104
  new_element = element.when_visible(10)
98
105
  expect(new_element).to eql element
99
106
  end
100
107
 
101
108
  it "should be able to block until it is not visible" do
102
- allow(we).to receive(:wait_until).with(timeout: 10, message: "Element not present in 10 seconds")
103
- allow(we).to receive(:wait_while).with(timeout: 10, message: "Element still visible after 10 seconds")
109
+ allow(we).to receive(:wait_while).with(timeout: 10, message: "Element still present in 10 seconds")
104
110
  allow(we).to receive(:displayed?).and_return(false)
105
111
  element.when_not_visible(10)
106
112
  end
@@ -23,6 +23,15 @@ describe Druid::PagePopulator do
23
23
  let(:driver) { mock_driver }
24
24
  let(:druid) { DruidPagePopulator.new(driver) }
25
25
 
26
+ it "should accept any object that can be converted to a Hash" do
27
+ os = OpenStruct.new('tf' => 'value', 'sl' => 'value')
28
+ expect(druid).to receive(:tf=).with('value')
29
+ expect(druid).to receive(:sl=).with('value')
30
+
31
+ allow(druid).to receive(:is_enabled?).and_return(true)
32
+ druid.populate_page_with(os)
33
+ end
34
+
26
35
  it "should set a value in a text field" do
27
36
  expect(druid).to receive(:tf=).with('value')
28
37
  expect(druid).to receive(:is_enabled?).and_return(true)
@@ -38,7 +47,7 @@ describe Druid::PagePopulator do
38
47
  expect(druid).not_to receive(:tf=)
39
48
  expect(druid).to receive(:tf_element).twice.and_return(driver)
40
49
  expect(driver).to receive(:enabled?).and_return(true)
41
- expect(driver).to receive(:visible?).and_return(false)
50
+ expect(driver).to receive(:present?).and_return(false)
42
51
  expect(driver).to receive(:tag_name).and_return('input')
43
52
  druid.populate_page_with('tf' => true)
44
53
  end
@@ -96,7 +105,7 @@ describe Druid::PagePopulator do
96
105
  expect(druid).not_to receive(:check_cb)
97
106
  expect(druid).to receive(:cb_element).twice.and_return(driver)
98
107
  expect(driver).to receive(:enabled?).and_return(true)
99
- expect(driver).to receive(:visible?).and_return(false)
108
+ expect(driver).to receive(:present?).and_return(false)
100
109
  expect(driver).to receive(:tag_name).and_return('input')
101
110
  druid.populate_page_with('cb' => true)
102
111
  end
@@ -121,7 +130,7 @@ describe Druid::PagePopulator do
121
130
  expect(druid).not_to receive(:select_rb)
122
131
  expect(druid).to receive(:rb_element).twice.and_return(driver)
123
132
  expect(driver).to receive(:enabled?).and_return(true)
124
- expect(driver).to receive(:visible?).and_return(false)
133
+ expect(driver).to receive(:present?).and_return(false)
125
134
  expect(driver).to receive(:tag_name).and_return('input')
126
135
  druid.populate_page_with('rb' => true)
127
136
  end
@@ -139,6 +148,15 @@ describe Druid::PagePopulator do
139
148
  druid.populate_page_with('section' => {'stf' => 'value'})
140
149
  end
141
150
 
151
+ it "populate a page section when the value repsonds to #to_h and it exists" do
152
+ os = OpenStruct.new('tf' => 'value', 'sl' => 'value')
153
+ expect(section).to receive(:tf=).with('value')
154
+ expect(section).to receive(:sl=).with('value')
155
+
156
+ allow(druid).to receive(:is_enabled?).twice.and_return(true)
157
+ druid.populate_page_with('section' => os)
158
+ end
159
+
142
160
  it "should not set a value in a text field if it is not found on the page" do
143
161
  expect(section).not_to receive(:text_field)
144
162
  druid.populate_page_with('section' => {'coffee' => 'value'})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: druid-ts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Sheng
@@ -338,7 +338,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
338
338
  version: '0'
339
339
  requirements: []
340
340
  rubyforge_project:
341
- rubygems_version: 2.5.1
341
+ rubygems_version: 2.7.9
342
342
  signing_key:
343
343
  specification_version: 4
344
344
  summary: Druid DSL for browser testing