symbiont 0.10.0 → 0.11.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/.gitignore +4 -0
- data/Gemfile +1 -1
- data/LICENSE.txt +0 -0
- data/README.md +18 -12
- data/Rakefile +0 -0
- data/bin/console +10 -0
- data/bin/setup +5 -0
- data/lib/symbiont/accessor.rb +0 -0
- data/lib/symbiont/assertions.rb +0 -0
- data/lib/symbiont/data_builder.rb +0 -0
- data/lib/symbiont/data_reader.rb +1 -0
- data/lib/symbiont/data_setter.rb +0 -0
- data/lib/symbiont/elements.rb +0 -0
- data/lib/symbiont/errors.rb +2 -0
- data/lib/symbiont/factory.rb +2 -0
- data/lib/symbiont/helpers.rb +0 -0
- data/lib/symbiont/pages.rb +0 -0
- data/lib/symbiont/service_objects.rb +78 -0
- data/lib/symbiont/soap_methods.rb +72 -0
- data/lib/symbiont/version.rb +1 -1
- data/lib/symbiont/workflows.rb +88 -0
- data/lib/symbiont.rb +3 -0
- data/symbiont.gemspec +7 -5
- metadata +40 -37
- data/.coveralls.yml +0 -1
- data/.travis.yml +0 -24
- data/spec/fixtures/default.yml +0 -3
- data/spec/fixtures/element_definitions.rb +0 -71
- data/spec/fixtures/mock_data.yml +0 -3
- data/spec/fixtures/mock_drivers.rb +0 -8
- data/spec/fixtures/page_definitions.rb +0 -36
- data/spec/spec_helper.rb +0 -49
- data/spec/symbiont/assertion_spec.rb +0 -88
- data/spec/symbiont/data_builder_spec.rb +0 -38
- data/spec/symbiont/data_setter_spec.rb +0 -19
- data/spec/symbiont/driver_spec.rb +0 -52
- data/spec/symbiont/element_spec.rb +0 -10
- data/spec/symbiont/factory_spec.rb +0 -117
- data/spec/symbiont/page_spec.rb +0 -177
- data/test/symbiont-script.rb +0 -159
@@ -1,71 +0,0 @@
|
|
1
|
-
shared_examples_for 'element generator for' do |elements|
|
2
|
-
elements.each do |element|
|
3
|
-
|
4
|
-
context "#{element} on the watir-webdriver platform" do
|
5
|
-
it "will locate a specific #{element} with a single locator" do
|
6
|
-
expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
|
7
|
-
expect(watir_definition.send "#{element}").to eq(watir_element)
|
8
|
-
end
|
9
|
-
|
10
|
-
it "will locate a specific #{element} with a proc" do
|
11
|
-
expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
|
12
|
-
expect(watir_definition.send "#{element}_proc").to eq(watir_element)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "will locate a specific #{element} with a lambda" do
|
16
|
-
expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
|
17
|
-
expect(watir_definition.send "#{element}_lambda").to eq(watir_element)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "will locate a specific #{element} with a block" do
|
21
|
-
expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
|
22
|
-
expect(watir_definition.send "#{element}_block", element).to eq(watir_element)
|
23
|
-
end
|
24
|
-
|
25
|
-
it "will locate a specific #{element} with a block and argument" do
|
26
|
-
expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
|
27
|
-
expect(watir_definition.send "#{element}_block_arg", element).to eq(watir_element)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
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
|
56
|
-
|
57
|
-
shared_examples_for 'element select generator for' do |elements|
|
58
|
-
elements.each do |element|
|
59
|
-
it "will set a value on a specific #{element} with a single locator" do
|
60
|
-
expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
|
61
|
-
expect(watir_element).to receive(:select).with('value')
|
62
|
-
watir_definition.send "#{element}=", 'value'
|
63
|
-
end
|
64
|
-
|
65
|
-
it "will set a value on a specific #{element} with a proc" do
|
66
|
-
expect(watir_browser).to receive(element).with(id: element).and_return(watir_element)
|
67
|
-
expect(watir_element).to receive(:select).with('value')
|
68
|
-
watir_definition.send "#{element}_proc=", 'value'
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
data/spec/fixtures/mock_data.yml
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
require 'watir-webdriver'
|
2
|
-
|
3
|
-
def mock_browser_for_watir
|
4
|
-
watir_browser = double('watir')
|
5
|
-
allow(watir_browser).to receive(:is_a?).with(Watir::Browser).and_return(true)
|
6
|
-
allow(watir_browser).to receive(:is_a?).with(Selenium::WebDriver::Driver).and_return(false)
|
7
|
-
watir_browser
|
8
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
class PageWithMissingAssertions
|
2
|
-
attach Symbiont
|
3
|
-
end
|
4
|
-
|
5
|
-
class TestFactory
|
6
|
-
include Symbiont::Factory
|
7
|
-
attr_accessor :browser
|
8
|
-
attr_accessor :page
|
9
|
-
end
|
10
|
-
|
11
|
-
class ValidPageNewContext
|
12
|
-
attach Symbiont
|
13
|
-
end
|
14
|
-
|
15
|
-
class ValidPage
|
16
|
-
attach Symbiont
|
17
|
-
|
18
|
-
url_is 'http://localhost:9292'
|
19
|
-
url_matches /:\d{4}/
|
20
|
-
title_is 'Dialogic'
|
21
|
-
|
22
|
-
%w(text_field button file_field textarea select_list checkbox).each do |element|
|
23
|
-
send element, :"#{element}", id: element
|
24
|
-
|
25
|
-
send element, :"#{element}_proc", proc { browser.send(element, id: element) }
|
26
|
-
send element, :"#{element}_lambda", -> { browser.send(element, id: element) }
|
27
|
-
|
28
|
-
send element, :"#{element}_block" do
|
29
|
-
browser.send(element, id: element)
|
30
|
-
end
|
31
|
-
|
32
|
-
send element, :"#{element}_block_arg" do |id|
|
33
|
-
browser.send(element, id: id)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
require 'coveralls'
|
3
|
-
|
4
|
-
Coveralls.wear!
|
5
|
-
|
6
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
7
|
-
SimpleCov::Formatter::HTMLFormatter,
|
8
|
-
Coveralls::SimpleCov::Formatter
|
9
|
-
]
|
10
|
-
|
11
|
-
SimpleCov.start do
|
12
|
-
add_filter '/spec'
|
13
|
-
coverage_dir "#{SimpleCov.root}/spec/reports/coverage"
|
14
|
-
minimum_coverage 90
|
15
|
-
maximum_coverage_drop 5
|
16
|
-
end
|
17
|
-
|
18
|
-
require 'symbiont'
|
19
|
-
|
20
|
-
RSpec.configure do |config|
|
21
|
-
original_stderr = $stderr
|
22
|
-
original_stdout = $stdout
|
23
|
-
config.before(:all) do
|
24
|
-
$stderr = File.new(File.join(File.dirname(__FILE__), 'reports/symbiont-output.txt'), 'w')
|
25
|
-
$stdout = File.new(File.join(File.dirname(__FILE__), 'reports/symbiont-output.txt'), 'w')
|
26
|
-
end
|
27
|
-
config.after(:all) do
|
28
|
-
$stderr = original_stderr
|
29
|
-
$stdout = original_stdout
|
30
|
-
end
|
31
|
-
|
32
|
-
config.alias_it_should_behave_like_to :provides_an, 'when providing an'
|
33
|
-
|
34
|
-
shared_context :page do
|
35
|
-
let(:watir_browser) { mock_browser_for_watir }
|
36
|
-
let(:watir_definition) { ValidPage.new(watir_browser) }
|
37
|
-
|
38
|
-
let(:empty_definition) { PageWithMissingAssertions.new(watir_browser) }
|
39
|
-
let(:no_driver_definition) { ValidPage.new(:unknown) }
|
40
|
-
end
|
41
|
-
|
42
|
-
shared_context :element do
|
43
|
-
let(:watir_element) { double('element') }
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
Dir['spec/fixtures/**/*.rb'].each do |file|
|
48
|
-
require file.sub(/spec\//, '')
|
49
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Symbiont::Assertion do
|
4
|
-
context 'a definition with valid assertions' do
|
5
|
-
it 'will allow a url to be asserted' do
|
6
|
-
expect {
|
7
|
-
class PageWithUrl
|
8
|
-
attach Symbiont
|
9
|
-
url_is 'http://localhost:9292'
|
10
|
-
end
|
11
|
-
}.not_to raise_error
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'will allow a url match pattern to be asserted' do
|
15
|
-
expect {
|
16
|
-
class PageWithUrlMatches
|
17
|
-
attach Symbiont
|
18
|
-
url_matches /localhost/
|
19
|
-
end
|
20
|
-
}.not_to raise_error
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'will allow a title to be asserted' do
|
24
|
-
expect {
|
25
|
-
class PageWithTitle
|
26
|
-
attach Symbiont
|
27
|
-
title_is 'Dialogic'
|
28
|
-
end
|
29
|
-
}.not_to raise_error
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'a definition with missing assertion values' do
|
34
|
-
it 'will indicate a missing url_is assertion value' do
|
35
|
-
expect {
|
36
|
-
class PageWithMissingUrl
|
37
|
-
attach Symbiont
|
38
|
-
url_is
|
39
|
-
end
|
40
|
-
}.to raise_error Symbiont::Errors::NoUrlForDefinition
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'will indicate an empty url_is assertion value' do
|
44
|
-
expect {
|
45
|
-
class PageWithEmptyUrl
|
46
|
-
attach Symbiont
|
47
|
-
url_is ''
|
48
|
-
end
|
49
|
-
}.to raise_error Symbiont::Errors::NoUrlForDefinition
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'will indicate a missing url_matches assertion value' do
|
53
|
-
expect {
|
54
|
-
class PageWithMissingUrlMatch
|
55
|
-
attach Symbiont
|
56
|
-
url_matches
|
57
|
-
end
|
58
|
-
}.to raise_error Symbiont::Errors::NoUrlMatchForDefinition
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'will indicate an empty url_matches assertion value' do
|
62
|
-
expect {
|
63
|
-
class PageWithEmptyUrlMatch
|
64
|
-
attach Symbiont
|
65
|
-
url_matches ''
|
66
|
-
end
|
67
|
-
}.to raise_error Symbiont::Errors::NoUrlMatchForDefinition
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'will indicate a missing title_is assertion value' do
|
71
|
-
expect {
|
72
|
-
class PageWithMissingTitle
|
73
|
-
attach Symbiont
|
74
|
-
title_is
|
75
|
-
end
|
76
|
-
}.to raise_error Symbiont::Errors::NoTitleForDefinition
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'will indicate an empty title_is assertion value' do
|
80
|
-
expect {
|
81
|
-
class PageWithEmptyTitle
|
82
|
-
attach Symbiont
|
83
|
-
title_is ''
|
84
|
-
end
|
85
|
-
}.to raise_error Symbiont::Errors::NoTitleForDefinition
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Symbiont::DataBuilder do
|
4
|
-
include_context :page
|
5
|
-
|
6
|
-
context 'when configuring the data path' do
|
7
|
-
it 'will default to a directory named data' do
|
8
|
-
expect(Symbiont::DataBuilder.data_path).to eq('data')
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'will store a data source directory' do
|
12
|
-
Symbiont::DataBuilder.data_path = 'config/data'
|
13
|
-
expect(Symbiont::DataBuilder.data_path).to eq('config/data')
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context 'when reading data files' do
|
18
|
-
it 'will read files from the data path directory' do
|
19
|
-
Symbiont::DataBuilder.data_path = 'config/data'
|
20
|
-
expect(YAML).to receive(:load_file).with('config/data/test_data_file').and_return({})
|
21
|
-
Symbiont::DataBuilder.load('test_data_file')
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'will load the correct data file from the default' do
|
25
|
-
Symbiont::DataBuilder.data_path = 'spec/fixtures'
|
26
|
-
data = watir_definition.data_about 'valid'
|
27
|
-
expect(data.keys.sort).to eq(['bank','name'])
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'when provided a file' do
|
32
|
-
it 'will load the correct data file and retrieve data' do
|
33
|
-
Symbiont::DataBuilder.data_path = 'spec/fixtures'
|
34
|
-
data = watir_definition.data_about 'mock_data/valid'
|
35
|
-
expect(data.keys.sort).to eq(['bank','name'])
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Symbiont::DataSetter do
|
4
|
-
include_context :page
|
5
|
-
include_context :element
|
6
|
-
|
7
|
-
it 'will attempt to utilize data' do
|
8
|
-
expect(watir_element).to receive(:visible?).and_return(true)
|
9
|
-
expect(watir_element).to receive(:enabled?).and_return(true)
|
10
|
-
expect(watir_browser).to receive(:text_field).with({:id => 'text_field'}).exactly(2).times.and_return(watir_element)
|
11
|
-
watir_definition.using(:text_field => 'works')
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'will allow methods to be chained' do
|
15
|
-
expect('testing'.call_method_chain("reverse.capitalize")).to eq('Gnitset')
|
16
|
-
expect('testing'.call_method_chain("start_with?", 't')).to be_truthy
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'Symbiont Driver' do
|
4
|
-
include_context :page
|
5
|
-
|
6
|
-
context 'a symbiont driver is requested' do
|
7
|
-
it 'will provide the default browser' do
|
8
|
-
allow(Watir::Browser).to receive(:new).and_return(Symbiont.driver)
|
9
|
-
symbiont_browser
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe 'Page Definitions' do
|
15
|
-
include_context :page
|
16
|
-
|
17
|
-
context 'a definition using watir-webdriver' do
|
18
|
-
context 'with a url_is assertion' do
|
19
|
-
it 'will call the driver navigation method when viewed' do
|
20
|
-
expect(watir_browser).to receive(:goto).twice
|
21
|
-
expect { watir_definition.view }.not_to raise_error
|
22
|
-
watir_definition.view
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
context 'with a url_matches assertion' do
|
27
|
-
it 'will verify a url if the url_matches assertion has been set' do
|
28
|
-
expect(watir_browser).to receive(:url).twice.and_return('http://localhost:9292')
|
29
|
-
expect { watir_definition.has_correct_url? }.not_to raise_error
|
30
|
-
expect(watir_definition.has_correct_url?).to be_truthy
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'will not verify a url if the url does not match the url_matches assertion' do
|
34
|
-
expect(watir_browser).to receive(:url).and_return('http://127.0.0.1')
|
35
|
-
expect(watir_definition.has_correct_url?).to be_falsey
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'with a title_is assertion' do
|
40
|
-
it 'will verify a title if the title_is assertion has been set' do
|
41
|
-
expect(watir_browser).to receive(:title).twice.and_return 'Dialogic'
|
42
|
-
expect { watir_definition.has_correct_title? }.not_to raise_error
|
43
|
-
expect(watir_definition.has_correct_title?).to be_truthy
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'will not verify a title if the title does not match the title_is assertion' do
|
47
|
-
expect(watir_browser).to receive(:title).and_return('Page Title')
|
48
|
-
expect(watir_definition.has_correct_title?).to be_falsey
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Symbiont::Element do
|
4
|
-
include_context :page
|
5
|
-
include_context :element
|
6
|
-
|
7
|
-
provides_an 'element generator for', %w{text_field button}
|
8
|
-
provides_an 'element set generator for', %w{text_field file_field textarea}
|
9
|
-
provides_an 'element select generator for', %w{select_list}
|
10
|
-
end
|
@@ -1,117 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Symbiont::Factory do
|
4
|
-
before(:each) do
|
5
|
-
@factory = TestFactory.new
|
6
|
-
@factory.browser = mock_browser_for_watir
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'will create a new definition and view it, using on_view' do
|
10
|
-
expect(@factory.browser).to receive(:goto)
|
11
|
-
@factory.on_view(ValidPage)
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'will create a new definition and view it, using on_view and a block' do
|
15
|
-
expect(@factory.browser).to receive(:goto)
|
16
|
-
@factory.on_view ValidPage do |page|
|
17
|
-
expect(page).to be_instance_of ValidPage
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'will create a new definition, using on and a block with a parameter' do
|
22
|
-
expect(@factory.browser).not_to receive(:goto)
|
23
|
-
@factory.on ValidPage do |page|
|
24
|
-
expect(page).to be_instance_of ValidPage
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'will create a new definition, using on and a block without a parameter' do
|
29
|
-
expect(@factory.browser).not_to receive(:goto)
|
30
|
-
@factory.on ValidPage do
|
31
|
-
expect(@factory.page).to be_instance_of ValidPage
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'will use an existing object reference with on' do
|
36
|
-
expect(@factory.browser).to receive(:goto)
|
37
|
-
obj1 = @factory.on_view ValidPage
|
38
|
-
obj2 = @factory.on ValidPage
|
39
|
-
expect(obj1).to be(obj2)
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'will not use an existing object reference with on_new' do
|
43
|
-
expect(@factory.browser).to receive(:goto)
|
44
|
-
obj1 = @factory.on_view ValidPage
|
45
|
-
obj2 = @factory.on_new ValidPage
|
46
|
-
expect(obj1).not_to be(obj2)
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'will create a new definition, using on_set' do
|
50
|
-
expect(@factory.browser).not_to receive(:goto)
|
51
|
-
@factory.on_set ValidPage do |page|
|
52
|
-
expect(page).to be_instance_of ValidPage
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'will set a reference to be used outside the factory' do
|
57
|
-
page = @factory.on ValidPage
|
58
|
-
current = @factory.instance_variable_get '@page'
|
59
|
-
expect(current).to be(page)
|
60
|
-
|
61
|
-
current = @factory.instance_variable_get '@model'
|
62
|
-
expect(current).to be(page)
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'will use an existing object reference with on_set' do
|
66
|
-
expect(@factory.browser).to receive(:goto)
|
67
|
-
obj1 = @factory.on_view ValidPage
|
68
|
-
obj2 = @factory.on_set ValidPage
|
69
|
-
expect(obj1).to be(obj2)
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'will use an existing context using on after using on_set' do
|
73
|
-
@factory.on_set ValidPage do |page|
|
74
|
-
@obj1 = page # obj1 is CONTEXT, ACTIVE
|
75
|
-
end
|
76
|
-
|
77
|
-
@factory.on ValidPageNewContext do |page|
|
78
|
-
@obj2 = page # obj2 is ACTIVE
|
79
|
-
end
|
80
|
-
|
81
|
-
@factory.on ValidPage do |page|
|
82
|
-
@obj3 = page # obj1 CONTEXT is still set
|
83
|
-
end
|
84
|
-
|
85
|
-
expect(@obj1).not_to be(@obj2)
|
86
|
-
expect(@obj1).to be(@obj3)
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'will use an existing context using on_new of a different class after using on_set' do
|
90
|
-
@factory.on_set ValidPage do |page|
|
91
|
-
@obj1 = page # obj1 is CONTEXT, ACTIVE
|
92
|
-
end
|
93
|
-
|
94
|
-
@factory.on_new ValidPageNewContext do |page|
|
95
|
-
@obj2 = page # ACTIVE nil, obj1 no longer ACTIVE, but is CONTEXT
|
96
|
-
end
|
97
|
-
|
98
|
-
@factory.on ValidPage do |page|
|
99
|
-
@obj3 = page # CONTEXT is set to obj1
|
100
|
-
end
|
101
|
-
|
102
|
-
expect(@obj1).not_to be(@obj2)
|
103
|
-
expect(@obj1).to be (@obj3)
|
104
|
-
end
|
105
|
-
|
106
|
-
it 'will clear existing context using on_new after using on_set' do
|
107
|
-
@factory.on_set ValidPage do |page|
|
108
|
-
@obj1 = page # obj1 is CONTEXT, ACTIVE
|
109
|
-
end
|
110
|
-
|
111
|
-
@factory.on_new ValidPage do |page|
|
112
|
-
@obj2 = page # ACTIVE nil; since page is same, CONTEXT is nil
|
113
|
-
end
|
114
|
-
|
115
|
-
expect(@obj1).not_to be(@obj2)
|
116
|
-
end
|
117
|
-
end
|
data/spec/symbiont/page_spec.rb
DELETED
@@ -1,177 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Symbiont::Page do
|
4
|
-
include_context :page
|
5
|
-
include_context :element
|
6
|
-
|
7
|
-
context 'a page definition being used - url' do
|
8
|
-
it 'will establish no default url' do
|
9
|
-
expect(empty_definition.asserted_url).to be_nil
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'will establish a page url with the url_is assertion' do
|
13
|
-
expect(watir_definition).to respond_to :asserted_url
|
14
|
-
expect(watir_definition.asserted_url).to eq('http://localhost:9292')
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'will not view a page if the url_is assertion has not been set' do
|
18
|
-
expect { empty_definition.view }.to raise_error Symbiont::Errors::NoUrlForDefinition
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'a page definition being used - url match' do
|
23
|
-
it 'will establish no default url matcher' do
|
24
|
-
expect(empty_definition.url_match).to be_nil
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'will establish a url matcher with the url_matches assertion' do
|
28
|
-
expect(watir_definition).to respond_to :url_match
|
29
|
-
expect(watir_definition.url_match).to eq(/:\d{4}/)
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'will not verify a url if the url_matches assertion has not been set' do
|
33
|
-
expect { empty_definition.has_correct_url? }.to raise_error Symbiont::Errors::NoUrlMatchForDefinition
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'a page definition being used - title' do
|
38
|
-
it 'will establish no default title' do
|
39
|
-
expect(empty_definition.asserted_title).to be_nil
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'will establish a page title with the title_is assertion' do
|
43
|
-
expect(watir_definition).to respond_to :asserted_title
|
44
|
-
expect(watir_definition.asserted_title).to eq('Dialogic')
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'will not verify a title if the title_is assertion has not been set' do
|
48
|
-
expect { empty_definition.has_correct_title? }.to raise_error Symbiont::Errors::NoTitleForDefinition
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context 'an instance of a page definition' do
|
53
|
-
it 'will be able to verify a page' do
|
54
|
-
expect(watir_browser).to receive(:title).and_return('Dialogic')
|
55
|
-
expect(watir_browser).to receive(:url).and_return('http://localhost:9292')
|
56
|
-
watir_definition.verified?
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'will be able to get the active url' do
|
60
|
-
expect(watir_browser).to receive(:url).exactly(3).times.and_return('http://localhost:9292')
|
61
|
-
expect(watir_definition).to respond_to :url
|
62
|
-
expect(watir_definition.current_url).to eq('http://localhost:9292')
|
63
|
-
expect(watir_definition.page_url).to eq('http://localhost:9292')
|
64
|
-
expect(watir_definition.url).to eq('http://localhost:9292')
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'will be able to get the markup of a page' do
|
68
|
-
expect(watir_browser).to receive(:html).exactly(3).times.and_return('<h1>Page Section</h1>')
|
69
|
-
expect(watir_definition.markup).to eq('<h1>Page Section</h1>')
|
70
|
-
expect(watir_definition.html).to eq('<h1>Page Section</h1>')
|
71
|
-
expect(watir_definition.html).to include('<h1>Page')
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'will be able to get the text of a page' do
|
75
|
-
expect(watir_browser).to receive(:text).exactly(3).times.and_return('some page text')
|
76
|
-
expect(watir_definition.page_text).to eq('some page text')
|
77
|
-
expect(watir_definition.text).to eq('some page text')
|
78
|
-
expect(watir_definition.text).to include('page text')
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'will be able to get the title of a page' do
|
82
|
-
expect(watir_browser).to receive(:title).exactly(3).times.and_return('Page Title')
|
83
|
-
expect(watir_definition.page_title).to eq('Page Title')
|
84
|
-
expect(watir_definition.title).to eq('Page Title')
|
85
|
-
expect(watir_definition.title).to include('Title')
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'will navigate to a specific url' do
|
89
|
-
expect(watir_browser).to receive(:goto).exactly(3).times.with('http://localhost:9292')
|
90
|
-
watir_definition.visit('http://localhost:9292')
|
91
|
-
watir_definition.navigate_to('http://localhost:9292')
|
92
|
-
watir_definition.goto('http://localhost:9292')
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'will be able to get a screenshot of the current page' do
|
96
|
-
expect(watir_browser).to receive(:wd).twice.and_return(watir_browser)
|
97
|
-
expect(watir_browser).to receive(:save_screenshot).twice
|
98
|
-
watir_definition.screenshot('testing.png')
|
99
|
-
watir_definition.save_screenshot('testing.png')
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'will run a script against the browser' do
|
103
|
-
expect(watir_browser).to receive(:execute_script).twice.and_return('input')
|
104
|
-
expect(watir_definition.run_script('return document.activeElement')).to eq('input')
|
105
|
-
expect(watir_definition.execute_script('return document.activeElement')).to eq('input')
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'will run a script, with arguments, against the browser' do
|
109
|
-
expect(watir_browser).to receive(:execute_script).with('return arguments[0].innerHTML', watir_element).and_return('testing')
|
110
|
-
expect(watir_definition.execute_script('return arguments[0].innerHTML', watir_element)).to eq('testing')
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'will be able to get a cookie value' do
|
114
|
-
cookie = [{:name => 'test', :value => 'cookie', :path => '/'}]
|
115
|
-
expect(watir_browser).to receive(:cookies).and_return(cookie)
|
116
|
-
expect(watir_definition.get_cookie('test')).to eq('cookie')
|
117
|
-
end
|
118
|
-
|
119
|
-
it 'will return nothing if a cookie value is not found' do
|
120
|
-
cookie = [{:name => 'test', :value =>'cookie', :path => '/'}]
|
121
|
-
expect(watir_browser).to receive(:cookies).and_return(nil)
|
122
|
-
expect(watir_definition.get_cookie('testing')).to be_nil
|
123
|
-
end
|
124
|
-
|
125
|
-
it 'will be able to clear all cookies from the browser' do
|
126
|
-
expect(watir_browser).to receive(:cookies).twice.and_return(watir_browser)
|
127
|
-
expect(watir_browser).to receive(:clear).twice
|
128
|
-
watir_definition.remove_cookies
|
129
|
-
watir_definition.clear_cookies
|
130
|
-
end
|
131
|
-
|
132
|
-
it 'will be able to refresh the page' do
|
133
|
-
expect(watir_browser).to receive(:refresh).twice.and_return(watir_browser)
|
134
|
-
watir_definition.refresh_page
|
135
|
-
watir_definition.refresh
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'will be able to handle JavaScript alert dialogs' do
|
139
|
-
expect(watir_browser).to receive(:alert).exactly(3).times.and_return(watir_browser)
|
140
|
-
expect(watir_browser).to receive(:exists?).and_return(true)
|
141
|
-
expect(watir_browser).to receive(:text)
|
142
|
-
expect(watir_browser).to receive(:ok)
|
143
|
-
watir_definition.will_alert {}
|
144
|
-
end
|
145
|
-
|
146
|
-
it 'will be able to handle JavaScript confirmation dialogs' do
|
147
|
-
expect(watir_browser).to receive(:alert).exactly(3).times.and_return(watir_browser)
|
148
|
-
expect(watir_browser).to receive(:exists?).and_return(true)
|
149
|
-
expect(watir_browser).to receive(:text)
|
150
|
-
expect(watir_browser).to receive(:ok)
|
151
|
-
watir_definition.will_confirm(true) {}
|
152
|
-
end
|
153
|
-
|
154
|
-
it 'will be able to handle JavaScript prompt dialogs' do
|
155
|
-
expect(watir_browser).to receive(:wd).twice.and_return(watir_browser)
|
156
|
-
expect(watir_browser).to receive(:execute_script).twice
|
157
|
-
watir_definition.will_prompt('Testing') {}
|
158
|
-
end
|
159
|
-
|
160
|
-
it 'will be able to attach to a window by using the title' do
|
161
|
-
allow(watir_browser).to receive(:window).with(:title => /Display\ Results/).and_return(watir_browser)
|
162
|
-
allow(watir_browser).to receive(:use)
|
163
|
-
watir_definition.within_window(title: 'Display Results')
|
164
|
-
end
|
165
|
-
|
166
|
-
it 'will be able to attach to a window by using the url' do
|
167
|
-
allow(watir_browser).to receive(:window).with(:url => /results\.html/).and_return(watir_browser)
|
168
|
-
allow(watir_browser).to receive(:use)
|
169
|
-
watir_definition.within_window(url: 'results.html')
|
170
|
-
end
|
171
|
-
|
172
|
-
it 'will be able to convert a modal popup to a window' do
|
173
|
-
allow(watir_browser).to receive(:execute_script)
|
174
|
-
watir_definition.within_modal {}
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|