symbiont 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/symbiont/accessor.rb +2 -0
- data/lib/symbiont/assertions.rb +2 -2
- data/lib/symbiont/elements.rb +84 -6
- data/lib/symbiont/pages.rb +103 -8
- data/lib/symbiont/version.rb +1 -1
- data/lib/symbiont.rb +23 -3
- data/spec/fixtures/element_definitions.rb +23 -0
- data/spec/symbiont/element_spec.rb +1 -0
- data/spec/symbiont/page_spec.rb +110 -6
- data/test/symbiont-script.rb +68 -12
- metadata +3 -5
- data/lib/symbiont/logging.rb +0 -5
- data/lib/symbiont/platform.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd18724d4d14d9283a706ab94d792c729abdb1c9
|
4
|
+
data.tar.gz: 8f7e64b7080775f04027710b2e01d87599bb5861
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0481286fe56b0e66938637a42d68ee64e9207ba210788aa3e488e8632f44fcdca78598f2288f296836d69d76e5e0f008d21ae8a49a4c555d1453c1291468b49a
|
7
|
+
data.tar.gz: 4f4ce214003961b53b594eb6e1e09540a6e70f4b92281e2a93e3e398d1323f7a7b0ae1cdc87119a5bdbbb463d9ece9e7f47a443f9fabb5297bdde166f26e66ef
|
data/lib/symbiont/accessor.rb
CHANGED
data/lib/symbiont/assertions.rb
CHANGED
data/lib/symbiont/elements.rb
CHANGED
@@ -10,6 +10,14 @@ module Symbiont
|
|
10
10
|
@elements
|
11
11
|
end
|
12
12
|
|
13
|
+
def self.settable
|
14
|
+
@settable ||= [:text_field]
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.settable?(element)
|
18
|
+
settable.include? element.to_sym
|
19
|
+
end
|
20
|
+
|
13
21
|
module Element
|
14
22
|
# Iterates through Watir factory methods. Each method is defined
|
15
23
|
# as a method that can be called on a page class. This is what
|
@@ -19,22 +27,53 @@ module Symbiont
|
|
19
27
|
identifier, locator = parse_signature(signature)
|
20
28
|
context = context_from_signature(locator, &block)
|
21
29
|
define_element_accessor(identifier, locator, element, &context)
|
30
|
+
define_set_accessor(identifier, locator, element, &context) if Symbiont.settable?(element)
|
22
31
|
end
|
23
32
|
end
|
24
33
|
|
25
34
|
private
|
26
35
|
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
36
|
+
# Defines an accessor method for an element that allows the friendly
|
37
|
+
# name of the element to be proxied to a Watir element object that
|
38
|
+
# corresponds to the element type.
|
39
|
+
#
|
40
|
+
# @param identifier [Symbol] friendly name of element definition
|
41
|
+
# @param locator [Hash] locators for referencing the element
|
42
|
+
# @param element [Symbol] name of Watir-based object
|
30
43
|
# @param block [Proc] a context block
|
31
44
|
#
|
32
45
|
# @example
|
33
|
-
#
|
46
|
+
# This element definition:
|
47
|
+
# text_field :weight, id: 'wt', index: 0
|
48
|
+
#
|
49
|
+
# passed in like this:
|
50
|
+
# :weight, {:id => 'wt', :index => 0}, :text_field
|
51
|
+
#
|
52
|
+
# This allows access like this:
|
53
|
+
# @page.weight.set '200'
|
54
|
+
#
|
55
|
+
# Access could also be done this way:
|
56
|
+
# @page.weight(id: 'wt').set '200'
|
57
|
+
#
|
58
|
+
# The second approach would lead to the *values variable having
|
59
|
+
# an array like this: [{:id => 'wt'}].
|
60
|
+
#
|
61
|
+
# A third approach would be to utilize one element definition
|
62
|
+
# within the context of another. Consider the following element
|
63
|
+
# definitions:
|
64
|
+
# article :practice, id: 'practice'
|
65
|
+
#
|
66
|
+
# a :page_link do |text|
|
67
|
+
# practice.a(text: text)
|
68
|
+
# end
|
69
|
+
#
|
70
|
+
# These could be utilized as such:
|
71
|
+
# on_view(Practice).page_link('Click Me').click
|
72
|
+
#
|
73
|
+
# This approach would lead to the *values variable having
|
74
|
+
# an array like this: ["Click Me"].
|
34
75
|
def define_element_accessor(identifier, locator, element, &block)
|
35
76
|
define_method "#{identifier}".to_sym do |*values|
|
36
|
-
#puts "*** *values: #{values}"
|
37
|
-
|
38
77
|
if block_given?
|
39
78
|
instance_exec(*values, &block)
|
40
79
|
else
|
@@ -43,6 +82,44 @@ module Symbiont
|
|
43
82
|
end
|
44
83
|
end
|
45
84
|
|
85
|
+
# Defines an accessor method for an element that allows the value of
|
86
|
+
# the element to be set via appending an "=" to the friendly name
|
87
|
+
# (identifier) of the element passed in.
|
88
|
+
#
|
89
|
+
# @param identifier [Symbol] friendly name of element definition
|
90
|
+
# @param locator [Hash] locators for referencing the element
|
91
|
+
# @param element [Symbol] name of Watir-based object
|
92
|
+
# @param block [Proc] a context block
|
93
|
+
#
|
94
|
+
# @example
|
95
|
+
# This element definition:
|
96
|
+
# text_field :weight, id: 'wt'
|
97
|
+
#
|
98
|
+
# Can be accessed in two ways:
|
99
|
+
# @page.weight.set '200'
|
100
|
+
# @page.weight = '200'
|
101
|
+
#
|
102
|
+
# The second approach would lead to the *values variable having
|
103
|
+
# an array like this: ['200']. The first approach would be
|
104
|
+
# handled by define_element_accessor instead.
|
105
|
+
def define_set_accessor(identifier, locator, element, &block)
|
106
|
+
define_method "#{identifier}=".to_sym do |*values|
|
107
|
+
puts "*** *values: #{values}"
|
108
|
+
|
109
|
+
accessor = if block_given?
|
110
|
+
instance_exec(&block)
|
111
|
+
else
|
112
|
+
reference_element(element, locator)
|
113
|
+
end
|
114
|
+
|
115
|
+
if accessor.respond_to?(:set)
|
116
|
+
accessor.set *values
|
117
|
+
else
|
118
|
+
accessor.send_keys *values
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
46
123
|
# Returns the identifier and locator portions of an element definition.
|
47
124
|
#
|
48
125
|
# @param signature [Array] full element definition
|
@@ -56,6 +133,7 @@ module Symbiont
|
|
56
133
|
#
|
57
134
|
# @param locator [Array] locators from element definition
|
58
135
|
# @param block [Proc] a context block
|
136
|
+
# @return [Proc] the context block or nil if there is no procedure
|
59
137
|
def context_from_signature(*locator, &block)
|
60
138
|
if block_given?
|
61
139
|
block
|
data/lib/symbiont/pages.rb
CHANGED
@@ -3,8 +3,8 @@ module Symbiont
|
|
3
3
|
include Helpers
|
4
4
|
|
5
5
|
def view
|
6
|
-
no_url_is_provided if
|
7
|
-
driver.goto(
|
6
|
+
no_url_is_provided if asserted_url.nil?
|
7
|
+
driver.goto(asserted_url)
|
8
8
|
end
|
9
9
|
|
10
10
|
def has_correct_url?
|
@@ -13,20 +13,115 @@ module Symbiont
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def has_correct_title?
|
16
|
-
no_title_is_provided if
|
17
|
-
!(driver.title.match(
|
16
|
+
no_title_is_provided if asserted_title.nil?
|
17
|
+
!(driver.title.match(asserted_title)).nil?
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
self.class.
|
20
|
+
def asserted_url
|
21
|
+
self.class.asserted_url
|
22
22
|
end
|
23
23
|
|
24
24
|
def url_match
|
25
25
|
self.class.url_match
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
29
|
-
self.class.
|
28
|
+
def asserted_title
|
29
|
+
self.class.asserted_title
|
30
|
+
end
|
31
|
+
|
32
|
+
def url
|
33
|
+
driver.url
|
34
|
+
end
|
35
|
+
|
36
|
+
def markup
|
37
|
+
driver.html
|
38
|
+
end
|
39
|
+
|
40
|
+
def text
|
41
|
+
driver.text
|
42
|
+
end
|
43
|
+
|
44
|
+
def title
|
45
|
+
driver.title
|
46
|
+
end
|
47
|
+
|
48
|
+
def visit(url)
|
49
|
+
driver.goto(url)
|
50
|
+
end
|
51
|
+
|
52
|
+
def screenshot(file)
|
53
|
+
driver.wd.save_screenshot(file)
|
30
54
|
end
|
55
|
+
|
56
|
+
def run_script(script, *args)
|
57
|
+
driver.execute_script(script, *args)
|
58
|
+
end
|
59
|
+
|
60
|
+
def get_cookie(name)
|
61
|
+
for cookie in driver.cookies.to_a
|
62
|
+
if cookie[:name] == name
|
63
|
+
return cookie[:value]
|
64
|
+
end
|
65
|
+
end
|
66
|
+
nil
|
67
|
+
end
|
68
|
+
|
69
|
+
def clear_cookies
|
70
|
+
driver.cookies.clear
|
71
|
+
end
|
72
|
+
|
73
|
+
def refresh
|
74
|
+
driver.refresh
|
75
|
+
end
|
76
|
+
|
77
|
+
# @param block [Proc] the code that generates the alert
|
78
|
+
# @return [String] the message contained in the alert message box
|
79
|
+
def will_alert(&block)
|
80
|
+
yield
|
81
|
+
value = nil
|
82
|
+
if driver.alert.exists?
|
83
|
+
value = driver.alert.text
|
84
|
+
driver.alert.ok
|
85
|
+
end
|
86
|
+
value
|
87
|
+
end
|
88
|
+
|
89
|
+
# @param response [Boolean] true to accept the confirmation, false to cancel it
|
90
|
+
# @param block [Proc] the code that generates the confirmation
|
91
|
+
# @return [String] the message contained in the confirmation message box
|
92
|
+
def will_confirm(response, &block)
|
93
|
+
yield
|
94
|
+
value = nil
|
95
|
+
if driver.alert.exists?
|
96
|
+
value = driver.alert.text
|
97
|
+
response ? driver.alert.ok : driver.alert.close
|
98
|
+
end
|
99
|
+
value
|
100
|
+
end
|
101
|
+
|
102
|
+
# @param response [String] the value to be used in the prompt
|
103
|
+
# @param block [Proc] the code that generates the prompt
|
104
|
+
# @return [Hash] :message for the prompt message, :default_value for
|
105
|
+
# the value that the prompt had before the response was applied
|
106
|
+
def will_prompt(response, &block)
|
107
|
+
cmd = "window.prompt = function(text, value) {window.__lastWatirPrompt = {message: text, default_value: value}; return '#{response}';}"
|
108
|
+
driver.wd.execute_script(cmd)
|
109
|
+
yield
|
110
|
+
result = driver.wd.execute_script('return window.__lastWatirPrompt')
|
111
|
+
result && result.dup.each_key { |k| result[k.to_sym] = result.delete(k) }
|
112
|
+
result
|
113
|
+
end
|
114
|
+
|
115
|
+
alias_method :current_url, :url
|
116
|
+
alias_method :page_url, :url
|
117
|
+
alias_method :html, :markup
|
118
|
+
alias_method :page_text, :text
|
119
|
+
alias_method :page_title, :title
|
120
|
+
alias_method :navigate_to, :visit
|
121
|
+
alias_method :goto, :visit
|
122
|
+
alias_method :save_screenshot, :screenshot
|
123
|
+
alias_method :execute_script, :run_script
|
124
|
+
alias_method :remove_cookies, :clear_cookies
|
125
|
+
alias_method :refresh_page, :refresh
|
31
126
|
end
|
32
127
|
end
|
data/lib/symbiont/version.rb
CHANGED
data/lib/symbiont.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
require 'watir-webdriver'
|
2
2
|
|
3
3
|
require 'symbiont/version'
|
4
|
-
require 'symbiont/logging'
|
5
4
|
require 'symbiont/errors'
|
6
5
|
require 'symbiont/helpers'
|
7
6
|
|
8
7
|
require 'colorize'
|
9
8
|
|
10
|
-
require 'symbiont/platform'
|
11
9
|
require 'symbiont/assertions'
|
12
10
|
require 'symbiont/pages'
|
13
11
|
require 'symbiont/elements'
|
@@ -15,8 +13,14 @@ require 'symbiont/accessor'
|
|
15
13
|
require 'symbiont/factory'
|
16
14
|
|
17
15
|
module Symbiont
|
18
|
-
include Platform
|
19
16
|
|
17
|
+
# The included callback is used to provide the core functionality of the
|
18
|
+
# library to any class or module that includes the Symbiont library. The
|
19
|
+
# calling class or module is extended with logic that the library makes
|
20
|
+
# available as class methods. Any such class or module becomes a page or
|
21
|
+
# activity definition. The class methods allow assertions and element
|
22
|
+
# defintions to be defined.
|
23
|
+
#
|
20
24
|
# @param caller [Class] the class including the framework
|
21
25
|
def self.included(caller)
|
22
26
|
caller.extend Symbiont::Assertion
|
@@ -27,6 +31,22 @@ module Symbiont
|
|
27
31
|
|
28
32
|
Symbiont.trace("#{caller.class} #{caller} has attached the Symbiont.")
|
29
33
|
end
|
34
|
+
|
35
|
+
def self.trace(message, level = 1)
|
36
|
+
puts '*' * level + " #{message}" if ENV['SYMBIONT_TRACE'] == 'on'
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [Object] browser driver reference
|
40
|
+
attr_reader :driver
|
41
|
+
|
42
|
+
# @param driver [Object] a tool driver instance
|
43
|
+
def initialize(driver)
|
44
|
+
Symbiont.trace("Dialect attached to driver:\n\t#{driver.inspect}")
|
45
|
+
@driver = driver
|
46
|
+
|
47
|
+
initialize_page if respond_to?(:initialize_page)
|
48
|
+
initialize_activity if respond_to?(:initialize_activity)
|
49
|
+
end
|
30
50
|
end
|
31
51
|
|
32
52
|
def attach(mod=Symbiont)
|
@@ -30,3 +30,26 @@ shared_examples_for 'element generator for' do |elements|
|
|
30
30
|
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
shared_examples_for 'element set generator for' do |elements|
|
35
|
+
elements.each do |element|
|
36
|
+
it "will set a value on a specific #{element} with a single locator" do
|
37
|
+
expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
|
38
|
+
expect(watir_element).to receive(:set).with('value')
|
39
|
+
watir_definition.send "#{element}=", 'value'
|
40
|
+
end
|
41
|
+
|
42
|
+
it "will attempt to send keypresses if a #{element} cannot be set" do
|
43
|
+
expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
|
44
|
+
allow(watir_element).to receive(:respond_to?).with(:set).and_return(false)
|
45
|
+
expect(watir_element).to receive(:send_keys).with('value')
|
46
|
+
watir_definition.send "#{element}=", 'value'
|
47
|
+
end
|
48
|
+
|
49
|
+
it "will set a value on a specific #{element} with a proc" do
|
50
|
+
expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
|
51
|
+
expect(watir_element).to receive(:set).with('value')
|
52
|
+
watir_definition.send "#{element}_proc=", 'value'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/spec/symbiont/page_spec.rb
CHANGED
@@ -2,15 +2,16 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Symbiont::Page do
|
4
4
|
include_context :page
|
5
|
+
include_context :element
|
5
6
|
|
6
7
|
context 'a page definition being used - url' do
|
7
8
|
it 'will establish no default url' do
|
8
|
-
expect(empty_definition.
|
9
|
+
expect(empty_definition.asserted_url).to be_nil
|
9
10
|
end
|
10
11
|
|
11
12
|
it 'will establish a page url with the url_is assertion' do
|
12
|
-
expect(watir_definition).to respond_to :
|
13
|
-
expect(watir_definition.
|
13
|
+
expect(watir_definition).to respond_to :asserted_url
|
14
|
+
expect(watir_definition.asserted_url).to eq('http://localhost:9292')
|
14
15
|
end
|
15
16
|
|
16
17
|
it 'will not view a page if the url_is assertion has not been set' do
|
@@ -35,16 +36,119 @@ describe Symbiont::Page do
|
|
35
36
|
|
36
37
|
context 'a page definition being used - title' do
|
37
38
|
it 'will establish no default title' do
|
38
|
-
expect(empty_definition.
|
39
|
+
expect(empty_definition.asserted_title).to be_nil
|
39
40
|
end
|
40
41
|
|
41
42
|
it 'will establish a page title with the title_is assertion' do
|
42
|
-
expect(watir_definition).to respond_to :
|
43
|
-
expect(watir_definition.
|
43
|
+
expect(watir_definition).to respond_to :asserted_title
|
44
|
+
expect(watir_definition.asserted_title).to eq('Dialogic')
|
44
45
|
end
|
45
46
|
|
46
47
|
it 'will not verify a title if the title_is assertion has not been set' do
|
47
48
|
expect { empty_definition.has_correct_title? }.to raise_error Symbiont::Errors::NoTitleForDefinition
|
48
49
|
end
|
49
50
|
end
|
51
|
+
|
52
|
+
context 'an instance of a page definition' do
|
53
|
+
it 'will be able to get the active url' do
|
54
|
+
watir_browser.should_receive(:url).exactly(3).times.and_return('http://localhost:9292')
|
55
|
+
expect(watir_definition).to respond_to :url
|
56
|
+
expect(watir_definition.current_url).to eq('http://localhost:9292')
|
57
|
+
expect(watir_definition.page_url).to eq('http://localhost:9292')
|
58
|
+
expect(watir_definition.url).to eq('http://localhost:9292')
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'will be able to get the markup of a page' do
|
62
|
+
watir_browser.should_receive(:html).exactly(3).times.and_return('<h1>Page Section</h1>')
|
63
|
+
expect(watir_definition.markup).to eq('<h1>Page Section</h1>')
|
64
|
+
expect(watir_definition.html).to eq('<h1>Page Section</h1>')
|
65
|
+
expect(watir_definition.html).to include('<h1>Page')
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'will be able to get the text of a page' do
|
69
|
+
watir_browser.should_receive(:text).exactly(3).times.and_return('some page text')
|
70
|
+
expect(watir_definition.page_text).to eq('some page text')
|
71
|
+
expect(watir_definition.text).to eq('some page text')
|
72
|
+
expect(watir_definition.text).to include('page text')
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'will be able to get the title of a page' do
|
76
|
+
watir_browser.should_receive(:title).exactly(3).times.and_return('Page Title')
|
77
|
+
expect(watir_definition.page_title).to eq('Page Title')
|
78
|
+
expect(watir_definition.title).to eq('Page Title')
|
79
|
+
expect(watir_definition.title).to include('Title')
|
80
|
+
end
|
81
|
+
|
82
|
+
it 'will navigate to a specific url' do
|
83
|
+
watir_browser.should_receive(:goto).exactly(3).times.with('http://localhost:9292')
|
84
|
+
watir_definition.visit('http://localhost:9292')
|
85
|
+
watir_definition.navigate_to('http://localhost:9292')
|
86
|
+
watir_definition.goto('http://localhost:9292')
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'will be able to get a screenshot of the current page' do
|
90
|
+
watir_browser.should_receive(:wd).twice.and_return(watir_browser)
|
91
|
+
watir_browser.should_receive(:save_screenshot).twice
|
92
|
+
watir_definition.screenshot('testing.png')
|
93
|
+
watir_definition.save_screenshot('testing.png')
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'will run a script against the browser' do
|
97
|
+
watir_browser.should_receive(:execute_script).twice.and_return('input')
|
98
|
+
expect(watir_definition.run_script('return document.activeElement')).to eq('input')
|
99
|
+
expect(watir_definition.execute_script('return document.activeElement')).to eq('input')
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should run a script, with arguments, against the browser' do
|
103
|
+
watir_browser.should_receive(:execute_script).with('return arguments[0].innerHTML', watir_element).and_return('testing')
|
104
|
+
watir_definition.execute_script('return arguments[0].innerHTML', watir_element).should == 'testing'
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'will be able to get a cookie value' do
|
108
|
+
cookie = [{:name => 'test', :value => 'cookie', :path => '/'}]
|
109
|
+
watir_browser.should_receive(:cookies).and_return(cookie)
|
110
|
+
expect(watir_definition.get_cookie('test')).to eq('cookie')
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'will return nothing if a cookie value is not found' do
|
114
|
+
cookie = [{:name => 'test', :value =>'cookie', :path => '/'}]
|
115
|
+
watir_browser.should_receive(:cookies).and_return(nil)
|
116
|
+
expect(watir_definition.get_cookie('testing')).to be_nil
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'will be able to clear all cookies from the browser' do
|
120
|
+
watir_browser.should_receive(:cookies).twice.and_return(watir_browser)
|
121
|
+
watir_browser.should_receive(:clear).twice
|
122
|
+
watir_definition.remove_cookies
|
123
|
+
watir_definition.clear_cookies
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'will be able to refresh the page' do
|
127
|
+
watir_browser.should_receive(:refresh).twice.and_return(watir_browser)
|
128
|
+
watir_definition.refresh_page
|
129
|
+
watir_definition.refresh
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'will be able to handle JavaScript alert dialogs' do
|
133
|
+
watir_browser.should_receive(:alert).exactly(3).times.and_return(watir_browser)
|
134
|
+
watir_browser.should_receive(:exists?).and_return(true)
|
135
|
+
watir_browser.should_receive(:text)
|
136
|
+
watir_browser.should_receive(:ok)
|
137
|
+
watir_definition.will_alert {}
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'will be able to handle JavaScript confirmation dialogs' do
|
141
|
+
watir_browser.should_receive(:alert).exactly(3).times.and_return(watir_browser)
|
142
|
+
watir_browser.should_receive(:exists?).and_return(true)
|
143
|
+
watir_browser.should_receive(:text)
|
144
|
+
watir_browser.should_receive(:ok)
|
145
|
+
watir_definition.will_confirm(true) {}
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'will be able to handle JavaScript prompt dialogs' do
|
149
|
+
watir_browser.should_receive(:wd).twice.and_return(watir_browser)
|
150
|
+
watir_browser.should_receive(:execute_script).twice
|
151
|
+
watir_definition.will_prompt('Testing') {}
|
152
|
+
end
|
153
|
+
end
|
50
154
|
end
|
data/test/symbiont-script.rb
CHANGED
@@ -15,6 +15,18 @@ class Dialogic
|
|
15
15
|
attach Symbiont
|
16
16
|
|
17
17
|
url_is 'http://localhost:9292'
|
18
|
+
|
19
|
+
p :login_form, id: 'open'
|
20
|
+
text_field :username, id: 'username'
|
21
|
+
text_field :password, id: 'password'
|
22
|
+
button :login, id: 'login-button'
|
23
|
+
|
24
|
+
def login_as_admin
|
25
|
+
login_form.click
|
26
|
+
username.set 'admin'
|
27
|
+
password.set 'admin'
|
28
|
+
login.click
|
29
|
+
end
|
18
30
|
end
|
19
31
|
|
20
32
|
class Weight
|
@@ -37,6 +49,10 @@ class Practice
|
|
37
49
|
url_matches /:\d{4}/
|
38
50
|
title_is 'Dialogic - Practice Page'
|
39
51
|
|
52
|
+
button :alert, id: 'alertButton'
|
53
|
+
button :confirm, id: 'confirmButton'
|
54
|
+
button :prompt, id: 'promptButton'
|
55
|
+
|
40
56
|
link :view_in_frame, id: 'framed_page'
|
41
57
|
|
42
58
|
iframe :boxframe, class: 'fancybox-iframe'
|
@@ -62,9 +78,11 @@ end
|
|
62
78
|
def framed
|
63
79
|
@page = Practice.new(@driver)
|
64
80
|
@page.view
|
65
|
-
|
81
|
+
##@page.view_in_frame.click
|
66
82
|
@page.page_link('View Weight Calculator in Frame').click
|
67
83
|
@page.weight.set '200'
|
84
|
+
|
85
|
+
##on_view(Practice).page_link('View Weight Calculator in Frame').click
|
68
86
|
end
|
69
87
|
|
70
88
|
def basic
|
@@ -78,20 +96,58 @@ def basic
|
|
78
96
|
|
79
97
|
@page.should have_correct_url
|
80
98
|
@page.should have_correct_title
|
81
|
-
end
|
82
99
|
|
83
|
-
|
100
|
+
expect(@page.url).to eq('http://localhost:9292/practice')
|
101
|
+
@page.markup.include?('<strong id="group">Apocalypticists Unite</strong>').should be_true
|
102
|
+
@page.text.include?('LEAST FAVORITE WAY').should be_true
|
103
|
+
expect(@page.title).to eq('Dialogic - Practice Page')
|
84
104
|
|
85
|
-
|
86
|
-
|
87
|
-
|
105
|
+
script = <<-JS
|
106
|
+
return arguments[0].innerHTML
|
107
|
+
JS
|
88
108
|
|
89
|
-
|
90
|
-
|
91
|
-
@active.calculate.click
|
109
|
+
result = @page.run_script(script, @page.view_in_frame)
|
110
|
+
expect(result).to eq('View Weight Calculator in Frame')
|
92
111
|
end
|
93
112
|
|
94
|
-
|
95
|
-
|
96
|
-
|
113
|
+
def factory
|
114
|
+
on_view(Weight)
|
115
|
+
on(Weight).convert('200')
|
116
|
+
on(Weight).calculate.click
|
117
|
+
|
118
|
+
on(Weight) do
|
119
|
+
@active.convert('200')
|
120
|
+
@active.calculate.click
|
121
|
+
end
|
122
|
+
|
123
|
+
on(Weight) do |page|
|
124
|
+
page.convert('200')
|
125
|
+
page.calculate.click
|
126
|
+
end
|
97
127
|
end
|
128
|
+
|
129
|
+
#basic
|
130
|
+
|
131
|
+
@page = Dialogic.new(@driver)
|
132
|
+
@page.view
|
133
|
+
@page.login_as_admin
|
134
|
+
|
135
|
+
@page = Practice.new(@driver)
|
136
|
+
@page.view
|
137
|
+
|
138
|
+
response = @page.will_alert { @page.alert.click }
|
139
|
+
expect(response).to eq 'Alert Message Received'
|
140
|
+
|
141
|
+
response = @page.will_confirm(false) { @page.confirm.click }
|
142
|
+
expect(response).to eq 'Confirmation Message Received'
|
143
|
+
|
144
|
+
response = @page.will_prompt("magenta") { @page.prompt.click }
|
145
|
+
expect(response[:message]).to eq('Favorite Color')
|
146
|
+
expect(response[:default_value]).to eq('blue')
|
147
|
+
|
148
|
+
@page = Weight.new(@driver)
|
149
|
+
@page.view
|
150
|
+
|
151
|
+
Watir::Wait.until { @page.weight.exists? }
|
152
|
+
|
153
|
+
@page.weight.when_present.set '200'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: symbiont
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Nyman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -109,9 +109,7 @@ files:
|
|
109
109
|
- lib/symbiont/errors.rb
|
110
110
|
- lib/symbiont/factory.rb
|
111
111
|
- lib/symbiont/helpers.rb
|
112
|
-
- lib/symbiont/logging.rb
|
113
112
|
- lib/symbiont/pages.rb
|
114
|
-
- lib/symbiont/platform.rb
|
115
113
|
- lib/symbiont/version.rb
|
116
114
|
- spec/fixtures/element_definitions.rb
|
117
115
|
- spec/fixtures/mock_drivers.rb
|
@@ -129,7 +127,7 @@ licenses:
|
|
129
127
|
- MIT
|
130
128
|
metadata: {}
|
131
129
|
post_install_message: "\n (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
|
132
|
-
(::)\n\n Symbiont 0.
|
130
|
+
(::)\n\n Symbiont 0.4.0 has been installed.\n\n (::) (::) (::) (::) (::)
|
133
131
|
(::) (::) (::) (::) (::) (::) (::)\n "
|
134
132
|
rdoc_options: []
|
135
133
|
require_paths:
|
data/lib/symbiont/logging.rb
DELETED
data/lib/symbiont/platform.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
module Symbiont
|
2
|
-
module Platform
|
3
|
-
# @return [Object] browser driver reference
|
4
|
-
attr_reader :driver
|
5
|
-
|
6
|
-
# @param driver [Object] a tool driver instance
|
7
|
-
def initialize(driver)
|
8
|
-
Symbiont.trace("Dialect attached to driver:\n\t#{driver.inspect}")
|
9
|
-
@driver = driver
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|