watirmark 5.27.2 → 5.28.0
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/lib/watirmark/configuration.rb +4 -0
- data/lib/watirmark/controller/controller.rb +5 -3
- data/lib/watirmark/controller/dialogs.rb +22 -23
- data/lib/watirmark/cucumber/cuke_helper.rb +3 -2
- data/lib/watirmark/cucumber/email_helper.rb +20 -4
- data/lib/watirmark/extensions/webdriver_extensions.rb +70 -41
- data/lib/watirmark/models/cucumber_helper.rb +3 -1
- data/lib/watirmark/models/factory.rb +1 -0
- data/lib/watirmark/models/factory_methods.rb +3 -1
- data/lib/watirmark/page/keyed_element.rb +1 -1
- data/lib/watirmark/session.rb +12 -7
- data/lib/watirmark/version.rb +1 -1
- data/spec/controller_spec.rb +2 -3
- data/spec/helper_methods_spec.rb +29 -0
- data/spec/model_factory_spec.rb +64 -4
- data/spec/spec_helper.rb +2 -0
- data/spec/watir_webdriver_spec.rb +73 -0
- metadata +17 -13
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e78eaa4edbdd389f9e45df9a84d9c31cc6d67768
|
|
4
|
+
data.tar.gz: 8801907ff42e5266d2b5a7756fbe70ce780353eb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a3f23b508646544a92d9a9bc8df2aa7b1d4ad54d9c1795e526c2d2bb7b4a064f621f6628746bf210f58c5ccbe36eb11fe5f1315e312acd09d5367a41d1bac87c
|
|
7
|
+
data.tar.gz: e687c597de0e65e999969bd4f7bd862faa9487396a1a2133921a8c15d344308dc9e6f1c97a7c641411a77a040ac9c3a5549b6e2cb548aedf88ec9c843f14ed22
|
|
@@ -123,14 +123,16 @@ module Watirmark
|
|
|
123
123
|
|
|
124
124
|
def populate_keyword_value(keyed_element)
|
|
125
125
|
call_method_if_exists("populate_#{keyed_element.keyword}") do
|
|
126
|
-
|
|
127
|
-
@view.send(keyed_element.keyword).send(:wait_until_present) unless @seen_value
|
|
126
|
+
@view.send(keyed_element.keyword).wait_until_present unless @view.send(keyed_element.keyword).kind_of? Watir::Radio
|
|
128
127
|
@view.send("#{keyed_element.keyword}=", value(keyed_element))
|
|
129
128
|
end
|
|
130
129
|
end
|
|
131
130
|
|
|
132
131
|
def verify_keyword_value(keyed_element)
|
|
133
|
-
call_method_if_exists("verify_#{keyed_element.keyword}")
|
|
132
|
+
call_method_if_exists("verify_#{keyed_element.keyword}") do
|
|
133
|
+
keyed_element.get.wait_until_present
|
|
134
|
+
assert_equal(keyed_element.get, value(keyed_element))
|
|
135
|
+
end
|
|
134
136
|
end
|
|
135
137
|
|
|
136
138
|
def keyword_value(keyed_element)
|
|
@@ -1,33 +1,32 @@
|
|
|
1
1
|
module Watirmark
|
|
2
2
|
module Dialogs
|
|
3
|
+
|
|
4
|
+
def current_window_index
|
|
5
|
+
current_window = Page.browser.window
|
|
6
|
+
Page.browser.windows.find_index(current_window)
|
|
7
|
+
end
|
|
8
|
+
|
|
3
9
|
def modal_exists?
|
|
4
|
-
|
|
10
|
+
Page.browser.window(index: current_window_index+1).exists?
|
|
5
11
|
end
|
|
6
12
|
|
|
7
|
-
def
|
|
13
|
+
def wait_for_modal_dialog
|
|
14
|
+
Watir::Wait.until { modal_exists? }
|
|
15
|
+
rescue TimeoutError
|
|
16
|
+
raise Watirmark::TestError, 'Timed out while waiting for modal dialog to open'
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def with_modal_dialog &blk
|
|
8
20
|
wait_for_modal_dialog
|
|
9
|
-
|
|
10
|
-
begin
|
|
11
|
-
Page.browser.windows.last.use
|
|
12
|
-
Page.browser.wait
|
|
13
|
-
yield
|
|
14
|
-
ensure
|
|
15
|
-
Page.browser.windows[parent_window].use
|
|
16
|
-
end
|
|
21
|
+
Page.browser.windows.last.use &blk
|
|
17
22
|
end
|
|
18
23
|
|
|
19
|
-
def
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Page.browser.wait
|
|
26
|
-
sleep 0.02
|
|
27
|
-
}
|
|
28
|
-
rescue Timeout::Error
|
|
29
|
-
raise Watirmark::TestError, 'Timed out while waiting for modal dialog to open'
|
|
30
|
-
end
|
|
24
|
+
def close_chrome_windows
|
|
25
|
+
Page.browser.windows(url: /chrome-extension/).each {|win| win.close}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def close_modal_window
|
|
29
|
+
Page.browser.window(index: current_window_index+1).close if Page.browser.windows.size >= current_window_index
|
|
31
30
|
end
|
|
32
31
|
end
|
|
33
|
-
end
|
|
32
|
+
end
|
|
@@ -8,10 +8,11 @@ module CukeHelper
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def eval_keywords(hash)
|
|
11
|
+
newhash = {}
|
|
11
12
|
hash.each do |key, value|
|
|
12
|
-
|
|
13
|
+
newhash[key] = format_value(value)
|
|
13
14
|
end
|
|
14
|
-
|
|
15
|
+
newhash
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
# when the input is an array, eval each element
|
|
@@ -27,20 +27,36 @@ module EmailHelper
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
# Read the contents of an email, cache it and delete the email
|
|
30
|
-
def read_email(model,
|
|
31
|
-
|
|
30
|
+
def read_email(model, options_hash, timeout=30)
|
|
31
|
+
Kernel.raise ArgumentError, 'The options provided are not in the form of a hash, i.e. {:subject => "subject"}' unless options_hash.is_a?(Hash)
|
|
32
|
+
search_array = options_hash_to_array(options_hash)
|
|
33
|
+
email_content = qa_inbox(model).get_email_text(search_array, timeout)
|
|
32
34
|
email[model.model_name] = EmailBody.new(email_content)
|
|
33
35
|
end
|
|
34
36
|
|
|
37
|
+
def options_hash_to_array(hash_of_search_params)
|
|
38
|
+
converted_array = Array.new
|
|
39
|
+
hash_of_search_params.each do | search_key, search_value |
|
|
40
|
+
converted_array << search_key.to_s.upcase
|
|
41
|
+
converted_array << search_value.to_s
|
|
42
|
+
end
|
|
43
|
+
converted_array
|
|
44
|
+
end
|
|
45
|
+
|
|
35
46
|
def read_email_from(model, from, timeout=30)
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
Kernel.warn(self.to_s + ':>' + Kernel.__callee__.to_s + ': This method is deprecated, please use read_email')
|
|
48
|
+
read_email(model, {:from => from, :to => model.email}, timeout)
|
|
38
49
|
end
|
|
39
50
|
|
|
40
51
|
def read_email_replyto(model, from, timeout=30)
|
|
41
52
|
qa_inbox(model).get_email_replyto(["FROM", from, "TO", model.email], timeout)
|
|
42
53
|
end
|
|
43
54
|
|
|
55
|
+
def read_email_subject_and_from(model, from, subject, timeout=30)
|
|
56
|
+
Kernel.warn(self.to_s + ':>' + Kernel.__callee__.to_s + ': This method is deprecated, please use read_email')
|
|
57
|
+
read_email(model, {:from => from, :to => model.email, :subject => subject}, timeout)
|
|
58
|
+
end
|
|
59
|
+
|
|
44
60
|
def log_email(model)
|
|
45
61
|
Watirmark.logger.info "Email Received"
|
|
46
62
|
Watirmark.logger.info email[model.model_name].body.inspect
|
|
@@ -1,38 +1,7 @@
|
|
|
1
1
|
require 'watir-webdriver/extensions/select_text'
|
|
2
2
|
|
|
3
|
-
Watir::always_locate = false
|
|
4
|
-
|
|
5
3
|
module Watir
|
|
6
4
|
|
|
7
|
-
class Browser
|
|
8
|
-
# for modal dialogs that close on submission, these might
|
|
9
|
-
# fail to run because the window has been destroyed
|
|
10
|
-
alias :old_run_checkers :run_checkers
|
|
11
|
-
|
|
12
|
-
# this is basically a check to make sure we're not
|
|
13
|
-
# running the checkers on a modal dialog that has closed
|
|
14
|
-
# by the time the checkers have run
|
|
15
|
-
def run_checkers
|
|
16
|
-
@error_checkers.each do |checker|
|
|
17
|
-
begin
|
|
18
|
-
checker.call(self)
|
|
19
|
-
rescue Selenium::WebDriver::Error::UnknownError, Selenium::WebDriver::Error::NoSuchWindowError => e
|
|
20
|
-
Watirmark.logger.warn "Unable to run checker: #{e.message}"
|
|
21
|
-
break
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
# Trigger checkers when manually submitting a form
|
|
28
|
-
class Form < HTMLElement
|
|
29
|
-
alias :old_submit :submit
|
|
30
|
-
def submit
|
|
31
|
-
old_submit
|
|
32
|
-
browser.run_checkers
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
5
|
module Container
|
|
37
6
|
alias :row :tr
|
|
38
7
|
alias :cell :td
|
|
@@ -79,6 +48,11 @@ module Watir
|
|
|
79
48
|
end
|
|
80
49
|
end
|
|
81
50
|
|
|
51
|
+
module Atoms
|
|
52
|
+
ATOMS[:getPreviousSibling] = File.read(File.expand_path("../atoms/getPreviousSibling.js", __FILE__))
|
|
53
|
+
ATOMS[:getNextSibling] = File.read(File.expand_path("../atoms/getNextSibling.js", __FILE__))
|
|
54
|
+
end
|
|
55
|
+
|
|
82
56
|
class Table < HTMLElement
|
|
83
57
|
def each
|
|
84
58
|
rows.each { |x| yield x }
|
|
@@ -136,30 +110,85 @@ module Watir
|
|
|
136
110
|
end
|
|
137
111
|
|
|
138
112
|
class Element
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
113
|
+
|
|
114
|
+
def next_sibling
|
|
115
|
+
e = locate_dom_element(:getNextSibling)
|
|
116
|
+
e.nil? ? element(xpath: './following-sibling::*') : e
|
|
117
|
+
end
|
|
118
|
+
alias_method :nextsibling, :next_sibling
|
|
119
|
+
|
|
120
|
+
def previous_sibling
|
|
121
|
+
e = locate_dom_element(:getPreviousSibling)
|
|
122
|
+
e.nil? ? element(xpath: './preceding-sibling::*') : e
|
|
123
|
+
end
|
|
124
|
+
alias_method :prev_sibling, :previous_sibling
|
|
125
|
+
alias_method :prevsibling, :previous_sibling
|
|
126
|
+
|
|
127
|
+
def locate_dom_element(method)
|
|
128
|
+
assert_exists
|
|
129
|
+
|
|
130
|
+
e = element_call { execute_atom method, @element }
|
|
131
|
+
|
|
132
|
+
if e.kind_of?(Selenium::WebDriver::Element)
|
|
133
|
+
Watir.element_class_for(e.tag_name.downcase).new(@parent, :element => e)
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
alias_method :old_element_call, :element_call
|
|
138
|
+
def element_call &block
|
|
139
|
+
old_element_call &block
|
|
140
|
+
rescue Selenium::WebDriver::Error::UnknownError => ex
|
|
141
|
+
raise unless ex.message.include?("Element is not clickable at point")
|
|
142
|
+
reset!
|
|
143
|
+
assert_exists
|
|
144
|
+
retry
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
alias_method :old_text, :text
|
|
148
|
+
def text
|
|
149
|
+
old_text.strip
|
|
145
150
|
end
|
|
146
151
|
|
|
147
152
|
def click_if_exists
|
|
148
153
|
click if exists?
|
|
149
154
|
end
|
|
150
155
|
|
|
151
|
-
|
|
156
|
+
alias_method :click_no_wait, :click
|
|
152
157
|
end
|
|
153
158
|
|
|
154
159
|
class TextFieldLocator
|
|
155
|
-
def
|
|
160
|
+
def check_deprecation(element)
|
|
156
161
|
if element.tag_name.downcase == 'textarea'
|
|
157
162
|
warn "Locating textareas with '#text_field' is deprecated. Please, use '#textarea' method instead for #{@selector}"
|
|
158
163
|
end
|
|
159
|
-
super
|
|
160
164
|
end
|
|
161
165
|
end
|
|
162
166
|
|
|
167
|
+
class IFrame < HTMLElement
|
|
168
|
+
alias_method :old_switch_to!, :switch_to!
|
|
169
|
+
def switch_to!
|
|
170
|
+
retry_attempts ||= 0
|
|
171
|
+
old_switch_to!
|
|
172
|
+
rescue Watir::Exception::UnknownFrameException
|
|
173
|
+
# UnknownFrameException is workaround for- https://code.google.com/p/chromedriver/issues/detail?id=948
|
|
174
|
+
retry_attempts += 1
|
|
175
|
+
retry if retry_attempts == 1
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
class Alert
|
|
180
|
+
alias_method :old_text, :text
|
|
181
|
+
def text
|
|
182
|
+
old_text.strip
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
class Browser
|
|
187
|
+
alias_method :old_text, :text
|
|
188
|
+
def text
|
|
189
|
+
old_text.strip
|
|
190
|
+
end
|
|
191
|
+
end
|
|
163
192
|
|
|
164
193
|
end
|
|
165
194
|
|
|
@@ -182,4 +211,4 @@ module Selenium
|
|
|
182
211
|
end
|
|
183
212
|
end
|
|
184
213
|
end
|
|
185
|
-
end
|
|
214
|
+
end
|
|
@@ -24,7 +24,9 @@ module Watirmark
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def insert_model(text)
|
|
27
|
-
|
|
27
|
+
# cucumber 2.0 defines a Core module between Cucumber and Ast
|
|
28
|
+
doc_class = Cucumber::Ast.const_defined?(:DocString) ? Cucumber::Ast::DocString : Cucumber::Core::Ast::DocString
|
|
29
|
+
return text unless text.is_a?(String) || text.is_a?(doc_class)
|
|
28
30
|
result = text
|
|
29
31
|
method_regexp = /\[([^\[\]]+)\]\.(\w+)/
|
|
30
32
|
model_regexp = /\[([^\[\]]+)\]/
|
|
@@ -21,6 +21,7 @@ module Watirmark
|
|
|
21
21
|
def get *args
|
|
22
22
|
@process_page.activate
|
|
23
23
|
watir_object = @context.instance_exec(*args, &@block)
|
|
24
|
+
return if watir_object.nil?
|
|
24
25
|
watir_object.extend(KeywordMethods)
|
|
25
26
|
watir_object.radio_map = @map if @map
|
|
26
27
|
watir_object.keyword = @keyword
|
|
@@ -29,7 +30,6 @@ module Watirmark
|
|
|
29
30
|
|
|
30
31
|
def set val
|
|
31
32
|
return if val.nil?
|
|
32
|
-
@process_page.activate
|
|
33
33
|
element = get
|
|
34
34
|
val = @map.lookup(val) if @map
|
|
35
35
|
case val
|
data/lib/watirmark/session.rb
CHANGED
|
@@ -117,6 +117,10 @@ module Watirmark
|
|
|
117
117
|
end
|
|
118
118
|
|
|
119
119
|
def openbrowser
|
|
120
|
+
Watir.default_timeout = config.watir_timeout
|
|
121
|
+
Watir.prefer_css = config.prefer_css
|
|
122
|
+
Watir.always_locate = config.always_locate
|
|
123
|
+
|
|
120
124
|
use_headless_display if config.headless
|
|
121
125
|
Page.browser = new_watir_browser
|
|
122
126
|
initialize_page_checkers
|
|
@@ -162,15 +166,16 @@ module Watirmark
|
|
|
162
166
|
end
|
|
163
167
|
|
|
164
168
|
def new_watir_browser
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
client = Selenium::WebDriver::Remote::Http::Default.new
|
|
170
|
+
client.timeout = config.http_timeout
|
|
171
|
+
|
|
172
|
+
case config.webdriver.to_sym
|
|
173
|
+
when :firefox, :firefox_proxy
|
|
174
|
+
Watir::Browser.new :firefox, profile: config.firefox_profile, http_client: client
|
|
175
|
+
when :sauce
|
|
171
176
|
Watir::Browser.new use_sauce
|
|
172
177
|
else
|
|
173
|
-
Watir::Browser.new config.webdriver.to_sym
|
|
178
|
+
Watir::Browser.new config.webdriver.to_sym, http_client: client
|
|
174
179
|
end
|
|
175
180
|
end
|
|
176
181
|
|
data/lib/watirmark/version.rb
CHANGED
data/spec/controller_spec.rb
CHANGED
|
@@ -96,9 +96,8 @@ describe Watirmark::WebPage::Controller do
|
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
specify 'should be able to create and use a new keyword' do
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
expect(view.send(@keyword).value == 'test' ).to be_true
|
|
99
|
+
TestView.new.send("#{@keyword}=", 'test')
|
|
100
|
+
expect { @controller.send(@keyword).value == 'text' }.to be_true
|
|
102
101
|
end
|
|
103
102
|
|
|
104
103
|
specify 'should be able to populate' do
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require_relative 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Testing helpers for email_helper's read_email method" do
|
|
4
|
+
|
|
5
|
+
it "should return an array of options given a hash" do
|
|
6
|
+
test_collection = EmailHelper::EmailCollection
|
|
7
|
+
option_hash = {:from => "foo@bar.com",
|
|
8
|
+
:to => "bar@foo.com",
|
|
9
|
+
:subject => "Foo Bar"}
|
|
10
|
+
transformed_options = test_collection.options_hash_to_array(option_hash)
|
|
11
|
+
transformed_options.is_a?(Array).should == true
|
|
12
|
+
option_hash.each_with_index do | keyvalue, index |
|
|
13
|
+
key = keyvalue[0]
|
|
14
|
+
value = keyvalue[1]
|
|
15
|
+
transformed_options[index*2].downcase.to_sym.should == key
|
|
16
|
+
transformed_options[index*2].should == key.to_s.upcase
|
|
17
|
+
transformed_options[index*2 + 1].should == value
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "should throw an argument exception because of the options parameter" do
|
|
22
|
+
test_collection = EmailHelper::EmailCollection
|
|
23
|
+
option_hash = ["Subject", "subject"]
|
|
24
|
+
dummy_model = Watirmark::Model::Factory.new
|
|
25
|
+
expect { test_collection.read_email(dummy_model,option_hash) }.to raise_error(ArgumentError)
|
|
26
|
+
expect { test_collection.read_email(dummy_model, nil)}.to raise_error(ArgumentError)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
data/spec/model_factory_spec.rb
CHANGED
|
@@ -520,6 +520,22 @@ describe "keywords" do
|
|
|
520
520
|
last_name { "Last #{uuid}" }
|
|
521
521
|
end
|
|
522
522
|
end
|
|
523
|
+
|
|
524
|
+
class MultipleKeywordsModel < Watirmark::Model::Factory
|
|
525
|
+
keywords :first_name
|
|
526
|
+
keywords :last_name
|
|
527
|
+
defaults do
|
|
528
|
+
first_name { "First" }
|
|
529
|
+
last_name {"Last"}
|
|
530
|
+
end
|
|
531
|
+
end
|
|
532
|
+
|
|
533
|
+
class DuplicateKeywordsModel < Watirmark::Model::Factory
|
|
534
|
+
keywords :first_name, :first_name
|
|
535
|
+
defaults do
|
|
536
|
+
first_name { "First" }
|
|
537
|
+
end
|
|
538
|
+
end
|
|
523
539
|
end
|
|
524
540
|
end
|
|
525
541
|
|
|
@@ -541,6 +557,18 @@ describe "keywords" do
|
|
|
541
557
|
FactoryTest::SomeModel.new.keywords.sort.should == [:first_name, :middle_name, :last_name].sort
|
|
542
558
|
end
|
|
543
559
|
|
|
560
|
+
specify "should be able to support multiple calls to keywords method" do
|
|
561
|
+
a = FactoryTest::MultipleKeywordsModel.new
|
|
562
|
+
a.first_name.should == "First"
|
|
563
|
+
a.keywords.include?(:last_name).should == true
|
|
564
|
+
a.last_name.should == "Last"
|
|
565
|
+
end
|
|
566
|
+
|
|
567
|
+
specify "should not contain duplicate values in the keywords" do
|
|
568
|
+
a = FactoryTest::DuplicateKeywordsModel.new
|
|
569
|
+
a.keywords.size.should == 1
|
|
570
|
+
end
|
|
571
|
+
|
|
544
572
|
end
|
|
545
573
|
|
|
546
574
|
describe "subclassing" do
|
|
@@ -549,6 +577,10 @@ describe "subclassing" do
|
|
|
549
577
|
trait :some_trait do
|
|
550
578
|
full_name { "full_name" }
|
|
551
579
|
end
|
|
580
|
+
|
|
581
|
+
trait :new_trait do
|
|
582
|
+
dog_name {"sugar"}
|
|
583
|
+
end
|
|
552
584
|
end
|
|
553
585
|
module FactoryTest
|
|
554
586
|
class BaseModel < Watirmark::Model::Factory
|
|
@@ -572,6 +604,19 @@ describe "subclassing" do
|
|
|
572
604
|
|
|
573
605
|
class NoDefaultModel < BaseModel
|
|
574
606
|
end
|
|
607
|
+
|
|
608
|
+
class KeywordsSubModel < BaseModel
|
|
609
|
+
keywords :middle_name, :cat_name, :dog_name
|
|
610
|
+
traits :new_trait
|
|
611
|
+
defaults do
|
|
612
|
+
middle_name {'middle_name'}
|
|
613
|
+
cat_name {'Annie'}
|
|
614
|
+
end
|
|
615
|
+
end
|
|
616
|
+
|
|
617
|
+
class DuplicateKeywordsSubModel < BaseModel
|
|
618
|
+
keywords :first_name
|
|
619
|
+
end
|
|
575
620
|
end
|
|
576
621
|
end
|
|
577
622
|
|
|
@@ -588,10 +633,25 @@ describe "subclassing" do
|
|
|
588
633
|
end
|
|
589
634
|
|
|
590
635
|
specify "submodel should be able to override defaults" do
|
|
591
|
-
FactoryTest::SubModel.new
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
636
|
+
a = FactoryTest::SubModel.new
|
|
637
|
+
a.first_name.should == 'sub_first_name'
|
|
638
|
+
a.last_name.should == 'sub_last_name'
|
|
639
|
+
a.attr_test.should == 'I came from SubModel'
|
|
640
|
+
a.base_attr.should == 'This is a base attribute'
|
|
641
|
+
end
|
|
642
|
+
|
|
643
|
+
specify "submodel should be able to add new keywords to the inherited set" do
|
|
644
|
+
a = FactoryTest::KeywordsSubModel.new
|
|
645
|
+
a.middle_name.should == 'middle_name'
|
|
646
|
+
a.keywords.include?(:first_name).should == true
|
|
647
|
+
a.cat_name.should == 'Annie'
|
|
648
|
+
a.first_name.should == 'base_first_name'
|
|
649
|
+
a.dog_name.should == 'sugar'
|
|
650
|
+
end
|
|
651
|
+
|
|
652
|
+
specify "should not have duplicate keywords after inheritance" do
|
|
653
|
+
a = FactoryTest::DuplicateKeywordsSubModel.new
|
|
654
|
+
a.keywords.select{|x| x == :first_name}.size.should == 1
|
|
595
655
|
end
|
|
596
656
|
|
|
597
657
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
lib_dir = File.join(File.dirname(__FILE__), '..', 'lib')
|
|
2
2
|
$: << File.expand_path(lib_dir)
|
|
3
|
+
$: << File.expand_path(lib_dir + '/watirmark/cucumber')
|
|
3
4
|
|
|
4
5
|
ENV['WEBDRIVER'] = 'firefox'
|
|
5
6
|
|
|
@@ -7,6 +8,7 @@ ENV['WEBDRIVER'] = 'firefox'
|
|
|
7
8
|
require 'rspec/autorun'
|
|
8
9
|
require 'watirmark'
|
|
9
10
|
require 'watirmark/configuration'
|
|
11
|
+
require 'watirmark/cucumber/email_helper'
|
|
10
12
|
|
|
11
13
|
Watirmark.logger.level = Logger::FATAL
|
|
12
14
|
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
require_relative 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Watir::Element do
|
|
4
|
+
before :all do
|
|
5
|
+
@html = File.expand_path(File.dirname(__FILE__) + '/html/controller.html')
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
before :each do
|
|
9
|
+
Page.browser.goto "file://#{@html}"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe '#previous_sibling' do
|
|
13
|
+
specify 'prevsibling, prev_sibling, and previous_sibling return same element' do
|
|
14
|
+
element = Page.browser.option(:text => 'b')
|
|
15
|
+
prevsibling_el = element.prevsibling
|
|
16
|
+
prev_sibling_el = element.prev_sibling
|
|
17
|
+
previous_sibling_el = element.previous_sibling
|
|
18
|
+
expect(prevsibling_el).to eq(prev_sibling_el)
|
|
19
|
+
expect(prev_sibling_el).to eq(previous_sibling_el)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
specify 'can get previous sibling object even though sibling does not exist' do
|
|
23
|
+
element = Page.browser.option(:text => 'a')
|
|
24
|
+
sib = element.previous_sibling
|
|
25
|
+
expect(sib.class).to eq(Watir::HTMLElement)
|
|
26
|
+
expect(sib.exists?).to eq(false)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
specify 'can get child object for nonexistent previous sibling and does not raise exception, just returns false' do
|
|
30
|
+
element = Page.browser.option(:text => 'a')
|
|
31
|
+
child = element.previous_sibling.element(:text => 'doesntmatter')
|
|
32
|
+
expect(child.class).to eq(Watir::HTMLElement)
|
|
33
|
+
expect(child.exists?).to eq(false)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
specify 'can get previous sibling object and evaluate it does exist' do
|
|
37
|
+
element = Page.browser.option(:text => 'b')
|
|
38
|
+
sib = element.previous_sibling
|
|
39
|
+
expect(sib.exist?).to eq(true)
|
|
40
|
+
expect(sib.html).to eq('<option value="a">a</option>')
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
describe '#next_sibling' do
|
|
45
|
+
specify 'nextsibling and next_sibling return same element' do
|
|
46
|
+
element = Page.browser.option(:text => 'b')
|
|
47
|
+
nextsibling_el = element.nextsibling
|
|
48
|
+
next_sibling_el = element.next_sibling
|
|
49
|
+
expect(nextsibling_el).to eq(next_sibling_el)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
specify 'can get following sibling object even though sibling does not exist' do
|
|
53
|
+
element = Page.browser.option(:text => 'c')
|
|
54
|
+
sib = element.next_sibling
|
|
55
|
+
expect(sib.class).to eq(Watir::HTMLElement)
|
|
56
|
+
expect(sib.exists?).to eq(false)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
specify 'can get child object for nonexistent following sibling and does not raise exception, just returns false' do
|
|
60
|
+
element = Page.browser.option(:text => 'c')
|
|
61
|
+
child = element.next_sibling.element(:text => 'doesntmatter')
|
|
62
|
+
expect(child.class).to eq(Watir::HTMLElement)
|
|
63
|
+
expect(child.exists?).to eq(false)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
specify 'can get following sibling object and evaluate it does exist' do
|
|
67
|
+
element = Page.browser.option(:text => 'b')
|
|
68
|
+
sib = element.next_sibling
|
|
69
|
+
expect(sib.exist?).to eq(true)
|
|
70
|
+
expect(sib.html).to eq('<option value="c">c</option>')
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: watirmark
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.
|
|
4
|
+
version: 5.28.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hugh McGowan
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2015-05-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: watir-webdriver
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.
|
|
19
|
+
version: 0.7.0
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.
|
|
26
|
+
version: 0.7.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: american_date
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -199,12 +199,14 @@ files:
|
|
|
199
199
|
- spec/controller_actions_spec.rb
|
|
200
200
|
- spec/controller_spec.rb
|
|
201
201
|
- spec/controllers_and_models_spec.rb
|
|
202
|
+
- spec/helper_methods_spec.rb
|
|
202
203
|
- spec/model_factory_spec.rb
|
|
203
204
|
- spec/model_traits_spec.rb
|
|
204
205
|
- spec/page_spec.rb
|
|
205
206
|
- spec/process_page_spec.rb
|
|
206
207
|
- spec/session_spec.rb
|
|
207
208
|
- spec/spec_helper.rb
|
|
209
|
+
- spec/watir_webdriver_spec.rb
|
|
208
210
|
homepage: http://github.com/convio/watirmark
|
|
209
211
|
licenses: []
|
|
210
212
|
metadata: {}
|
|
@@ -224,19 +226,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
224
226
|
version: '0'
|
|
225
227
|
requirements: []
|
|
226
228
|
rubyforge_project:
|
|
227
|
-
rubygems_version: 2.
|
|
229
|
+
rubygems_version: 2.4.6
|
|
228
230
|
signing_key:
|
|
229
231
|
specification_version: 4
|
|
230
|
-
summary: watirmark 5.
|
|
232
|
+
summary: watirmark 5.28.0
|
|
231
233
|
test_files:
|
|
232
|
-
- spec/
|
|
233
|
-
- spec/
|
|
234
|
-
- spec/controller_actions_spec.rb
|
|
235
|
-
- spec/controller_spec.rb
|
|
234
|
+
- spec/session_spec.rb
|
|
235
|
+
- spec/helper_methods_spec.rb
|
|
236
236
|
- spec/controllers_and_models_spec.rb
|
|
237
|
+
- spec/process_page_spec.rb
|
|
238
|
+
- spec/page_spec.rb
|
|
239
|
+
- spec/config_spec.rb
|
|
237
240
|
- spec/model_factory_spec.rb
|
|
241
|
+
- spec/controller_actions_spec.rb
|
|
238
242
|
- spec/model_traits_spec.rb
|
|
239
|
-
- spec/
|
|
240
|
-
- spec/process_page_spec.rb
|
|
241
|
-
- spec/session_spec.rb
|
|
243
|
+
- spec/watir_webdriver_spec.rb
|
|
242
244
|
- spec/spec_helper.rb
|
|
245
|
+
- spec/controller_spec.rb
|
|
246
|
+
- spec/assertions_spec.rb
|