page_magic 1.2.6 → 2.0.0.alpha1
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 +5 -5
- data/.rubocop.yml +19 -3
- data/.simplecov +5 -3
- data/.zsh_config +6 -0
- data/Dockerfile +10 -0
- data/Gemfile +12 -12
- data/Gemfile.lock +133 -126
- data/Makefile +13 -0
- data/README.md +78 -14
- data/Rakefile +12 -2
- data/VERSION +1 -1
- data/circle.yml +4 -2
- data/lib/active_support/core_ext/object/to_query.rb +84 -0
- data/lib/page_magic.rb +7 -4
- data/lib/page_magic/class_methods.rb +4 -1
- data/lib/page_magic/driver.rb +3 -0
- data/lib/page_magic/drivers.rb +6 -5
- data/lib/page_magic/drivers/poltergeist.rb +2 -0
- data/lib/page_magic/drivers/rack_test.rb +3 -1
- data/lib/page_magic/drivers/selenium.rb +4 -2
- data/lib/page_magic/element.rb +19 -10
- data/lib/page_magic/element/locators.rb +4 -1
- data/lib/page_magic/element/query.rb +33 -33
- data/lib/page_magic/element/query_builder.rb +61 -0
- data/lib/page_magic/element/selector.rb +3 -0
- data/lib/page_magic/element/selector_methods.rb +3 -0
- data/lib/page_magic/element_context.rb +9 -12
- data/lib/page_magic/element_definition_builder.rb +10 -4
- data/lib/page_magic/elements.rb +51 -8
- data/lib/page_magic/exceptions.rb +4 -33
- data/lib/page_magic/instance_methods.rb +6 -1
- data/lib/page_magic/matcher.rb +12 -3
- data/lib/page_magic/session.rb +7 -5
- data/lib/page_magic/session_methods.rb +2 -0
- data/lib/page_magic/utils/string.rb +14 -0
- data/lib/page_magic/wait_methods.rb +3 -0
- data/lib/page_magic/watcher.rb +2 -0
- data/lib/page_magic/watchers.rb +4 -1
- data/page_magic.gemspec +19 -13
- data/spec/element_spec.rb +2 -0
- data/spec/lib/active_support/core_ext/object/to_query_test.rb +78 -0
- data/spec/page_magic/class_methods_spec.rb +2 -0
- data/spec/page_magic/driver_spec.rb +2 -0
- data/spec/page_magic/drivers/poltergeist_spec.rb +2 -0
- data/spec/page_magic/drivers/rack_test_spec.rb +2 -0
- data/spec/page_magic/drivers/selenium_spec.rb +2 -0
- data/spec/page_magic/drivers_spec.rb +2 -0
- data/spec/page_magic/element/locators_spec.rb +2 -0
- data/spec/page_magic/element/query_builder_spec.rb +110 -0
- data/spec/page_magic/element/query_spec.rb +35 -77
- data/spec/page_magic/element/selector_spec.rb +14 -7
- data/spec/page_magic/element_context_spec.rb +5 -10
- data/spec/page_magic/element_definition_builder_spec.rb +3 -1
- data/spec/page_magic/elements_spec.rb +19 -5
- data/spec/page_magic/instance_methods_spec.rb +2 -0
- data/spec/page_magic/matcher_spec.rb +3 -1
- data/spec/page_magic/session_methods_spec.rb +2 -0
- data/spec/page_magic/session_spec.rb +3 -4
- data/spec/page_magic/utils/string_spec.rb +36 -0
- data/spec/page_magic/wait_methods_spec.rb +5 -3
- data/spec/page_magic/watchers_spec.rb +2 -0
- data/spec/page_magic_spec.rb +5 -7
- data/spec/spec_helper.rb +3 -0
- data/spec/support/shared_contexts.rb +3 -1
- data/spec/support/shared_contexts/files_context.rb +2 -0
- data/spec/support/shared_contexts/nested_elements_html_context.rb +2 -0
- data/spec/support/shared_contexts/rack_application_context.rb +2 -0
- data/spec/support/shared_contexts/webapp_fixture_context.rb +3 -1
- data/spec/support/shared_examples.rb +2 -0
- data/spec/watcher_spec.rb +3 -0
- metadata +62 -40
data/page_magic.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: page_magic 1.2.
|
5
|
+
# stub: page_magic 1.2.9 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "page_magic"
|
9
|
-
s.version = "1.2.
|
9
|
+
s.version = "1.2.9"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Leon Davis"]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2017-10-03"
|
15
15
|
s.description = "Framework for modeling and interacting with webpages which wraps capybara"
|
16
16
|
s.email = "info@lad-tech.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
"Rakefile",
|
31
31
|
"VERSION",
|
32
32
|
"circle.yml",
|
33
|
+
"lib/active_support/core_ext/object/to_query.rb",
|
33
34
|
"lib/page_magic.rb",
|
34
35
|
"lib/page_magic/class_methods.rb",
|
35
36
|
"lib/page_magic/driver.rb",
|
@@ -40,6 +41,7 @@ Gem::Specification.new do |s|
|
|
40
41
|
"lib/page_magic/element.rb",
|
41
42
|
"lib/page_magic/element/locators.rb",
|
42
43
|
"lib/page_magic/element/query.rb",
|
44
|
+
"lib/page_magic/element/query_builder.rb",
|
43
45
|
"lib/page_magic/element/selector.rb",
|
44
46
|
"lib/page_magic/element/selector_methods.rb",
|
45
47
|
"lib/page_magic/element_context.rb",
|
@@ -50,11 +52,13 @@ Gem::Specification.new do |s|
|
|
50
52
|
"lib/page_magic/matcher.rb",
|
51
53
|
"lib/page_magic/session.rb",
|
52
54
|
"lib/page_magic/session_methods.rb",
|
55
|
+
"lib/page_magic/utils/string.rb",
|
53
56
|
"lib/page_magic/wait_methods.rb",
|
54
57
|
"lib/page_magic/watcher.rb",
|
55
58
|
"lib/page_magic/watchers.rb",
|
56
59
|
"page_magic.gemspec",
|
57
60
|
"spec/element_spec.rb",
|
61
|
+
"spec/lib/active_support/core_ext/object/to_query_test.rb",
|
58
62
|
"spec/page_magic/class_methods_spec.rb",
|
59
63
|
"spec/page_magic/driver_spec.rb",
|
60
64
|
"spec/page_magic/drivers/poltergeist_spec.rb",
|
@@ -62,6 +66,7 @@ Gem::Specification.new do |s|
|
|
62
66
|
"spec/page_magic/drivers/selenium_spec.rb",
|
63
67
|
"spec/page_magic/drivers_spec.rb",
|
64
68
|
"spec/page_magic/element/locators_spec.rb",
|
69
|
+
"spec/page_magic/element/query_builder_spec.rb",
|
65
70
|
"spec/page_magic/element/query_spec.rb",
|
66
71
|
"spec/page_magic/element/selector_spec.rb",
|
67
72
|
"spec/page_magic/element_context_spec.rb",
|
@@ -71,6 +76,7 @@ Gem::Specification.new do |s|
|
|
71
76
|
"spec/page_magic/matcher_spec.rb",
|
72
77
|
"spec/page_magic/session_methods_spec.rb",
|
73
78
|
"spec/page_magic/session_spec.rb",
|
79
|
+
"spec/page_magic/utils/string_spec.rb",
|
74
80
|
"spec/page_magic/wait_methods_spec.rb",
|
75
81
|
"spec/page_magic/watchers_spec.rb",
|
76
82
|
"spec/page_magic_spec.rb",
|
@@ -86,37 +92,37 @@ Gem::Specification.new do |s|
|
|
86
92
|
s.homepage = "https://github.com/ladtech/page_magic"
|
87
93
|
s.licenses = ["ruby"]
|
88
94
|
s.required_ruby_version = Gem::Requirement.new(">= 2.1")
|
89
|
-
s.rubygems_version = "2.4.
|
95
|
+
s.rubygems_version = "2.4.6"
|
90
96
|
s.summary = "Framework for modeling and interacting with webpages"
|
91
97
|
|
92
98
|
if s.respond_to? :specification_version then
|
93
99
|
s.specification_version = 4
|
94
100
|
|
95
101
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
102
|
+
s.add_runtime_dependency(%q<activesupport-inflector>, [">= 0"])
|
96
103
|
s.add_runtime_dependency(%q<capybara>, [">= 2.5"])
|
97
|
-
s.
|
104
|
+
s.add_development_dependency(%q<github-markup>, ["~> 1.4"])
|
98
105
|
s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
|
106
|
+
s.add_development_dependency(%q<redcarpet>, ["~> 3.3"])
|
99
107
|
s.add_development_dependency(%q<rubocop>, ["~> 0.34"])
|
100
108
|
s.add_development_dependency(%q<yard>, ["~> 0.8"])
|
101
|
-
s.add_development_dependency(%q<redcarpet>, ["~> 3.3"])
|
102
|
-
s.add_development_dependency(%q<github-markup>, ["~> 1.4"])
|
103
109
|
else
|
110
|
+
s.add_dependency(%q<activesupport-inflector>, [">= 0"])
|
104
111
|
s.add_dependency(%q<capybara>, [">= 2.5"])
|
105
|
-
s.add_dependency(%q<
|
112
|
+
s.add_dependency(%q<github-markup>, ["~> 1.4"])
|
106
113
|
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
114
|
+
s.add_dependency(%q<redcarpet>, ["~> 3.3"])
|
107
115
|
s.add_dependency(%q<rubocop>, ["~> 0.34"])
|
108
116
|
s.add_dependency(%q<yard>, ["~> 0.8"])
|
109
|
-
s.add_dependency(%q<redcarpet>, ["~> 3.3"])
|
110
|
-
s.add_dependency(%q<github-markup>, ["~> 1.4"])
|
111
117
|
end
|
112
118
|
else
|
119
|
+
s.add_dependency(%q<activesupport-inflector>, [">= 0"])
|
113
120
|
s.add_dependency(%q<capybara>, [">= 2.5"])
|
114
|
-
s.add_dependency(%q<
|
121
|
+
s.add_dependency(%q<github-markup>, ["~> 1.4"])
|
115
122
|
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
123
|
+
s.add_dependency(%q<redcarpet>, ["~> 3.3"])
|
116
124
|
s.add_dependency(%q<rubocop>, ["~> 0.34"])
|
117
125
|
s.add_dependency(%q<yard>, ["~> 0.8"])
|
118
|
-
s.add_dependency(%q<redcarpet>, ["~> 3.3"])
|
119
|
-
s.add_dependency(%q<github-markup>, ["~> 1.4"])
|
120
126
|
end
|
121
127
|
end
|
122
128
|
|
data/spec/element_spec.rb
CHANGED
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'minitest'
|
4
|
+
Minitest.autorun
|
5
|
+
require 'active_support/core_ext/object/to_query'
|
6
|
+
|
7
|
+
class ToQueryTest < ::Minitest::Test
|
8
|
+
def test_simple_conversion
|
9
|
+
assert_query_equal 'a=10', a: 10
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_cgi_escaping
|
13
|
+
assert_query_equal 'a%3Ab=c+d', 'a:b' => 'c d'
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_nil_parameter_value
|
17
|
+
empty = Object.new
|
18
|
+
def empty.to_param
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
assert_query_equal 'a=', 'a' => empty
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_nested_conversion
|
25
|
+
assert_query_equal 'person%5Blogin%5D=seckar&person%5Bname%5D=Nicholas',
|
26
|
+
person: Hash[:login, 'seckar', :name, 'Nicholas']
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_multiple_nested
|
30
|
+
assert_query_equal 'account%5Bperson%5D%5Bid%5D=20&person%5Bid%5D=10',
|
31
|
+
Hash[:account, { person: { id: 20 } }, :person, { id: 10 }]
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_array_values
|
35
|
+
assert_query_equal 'person%5Bid%5D%5B%5D=10&person%5Bid%5D%5B%5D=20',
|
36
|
+
person: { id: [10, 20] }
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_array_values_are_not_sorted
|
40
|
+
assert_query_equal 'person%5Bid%5D%5B%5D=20&person%5Bid%5D%5B%5D=10',
|
41
|
+
person: { id: [20, 10] }
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_empty_array
|
45
|
+
assert_equal 'person%5B%5D=', [].to_query('person')
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_nested_empty_hash
|
49
|
+
assert_equal '',
|
50
|
+
{}.to_query
|
51
|
+
assert_query_equal 'a=1&b%5Bc%5D=3',
|
52
|
+
a: 1, b: { c: 3, d: {} }
|
53
|
+
assert_query_equal '',
|
54
|
+
a: { b: { c: {} } }
|
55
|
+
assert_query_equal 'b%5Bc%5D=false&b%5Be%5D=&b%5Bf%5D=&p=12',
|
56
|
+
p: 12, b: { c: false, e: nil, f: '' }
|
57
|
+
assert_query_equal 'b%5Bc%5D=3&b%5Bf%5D=',
|
58
|
+
b: { c: 3, k: {}, f: '' }
|
59
|
+
assert_query_equal 'b=3',
|
60
|
+
a: [], b: 3
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_hash_with_namespace
|
64
|
+
hash = { name: 'Nakshay', nationality: 'Indian' }
|
65
|
+
assert_equal 'user%5Bname%5D=Nakshay&user%5Bnationality%5D=Indian', hash.to_query('user')
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_hash_sorted_lexicographically
|
69
|
+
hash = { type: 'human', name: 'Nakshay' }
|
70
|
+
assert_equal 'name=Nakshay&type=human', hash.to_query
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def assert_query_equal(expected, actual)
|
76
|
+
assert_equal expected.split('&'), actual.to_query.split('&')
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PageMagic
|
4
|
+
class Element
|
5
|
+
describe QueryBuilder do
|
6
|
+
it 'has a predefined query for each element type' do
|
7
|
+
missing = PageMagic::Elements::TYPES.dup.delete_if { |type| type.to_s.end_with?('s') }.find_all do |type|
|
8
|
+
described_class.constants.include?(type)
|
9
|
+
end
|
10
|
+
expect(missing).to be_empty
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '.find' do
|
14
|
+
it 'finds the constant with the given name' do
|
15
|
+
expect(described_class.find(:button)).to be(described_class::BUTTON)
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'constant not found' do
|
19
|
+
it 'returns a default' do
|
20
|
+
expect(described_class.find(:billy)).to be(described_class::ELEMENT)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#build' do
|
26
|
+
let(:selector) { Selector.new }
|
27
|
+
before do
|
28
|
+
expect(Selector).to receive(:find).with(:css).and_return(selector)
|
29
|
+
end
|
30
|
+
let(:locator) { { css: '.css' } }
|
31
|
+
|
32
|
+
it 'builds a query using the correct selector' do
|
33
|
+
expected = Query.new(locator.values)
|
34
|
+
expect(subject.build(locator)).to eq(expected)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'adds options to the result' do
|
38
|
+
expected = Query.new(locator.values.concat([:options]))
|
39
|
+
expect(subject.build(locator, :options)).to eq(expected)
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'selector support element type' do
|
43
|
+
subject do
|
44
|
+
described_class.new(:field)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'passes element type through to the selector' do
|
48
|
+
expect(selector).to receive(:build).with(:field, '.css').and_call_original
|
49
|
+
subject.build(locator)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class QueryBuilder
|
56
|
+
describe BUTTON do
|
57
|
+
it 'has an element type' do
|
58
|
+
expect(described_class.type).to eq(:button)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe ELEMENT do
|
63
|
+
it ' does not has an element type' do
|
64
|
+
expect(described_class.type).to be_nil
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe LINK do
|
69
|
+
it 'has an element type' do
|
70
|
+
expect(described_class.type).to eq(:link)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe TEXT_FIELD do
|
75
|
+
it 'has an element type' do
|
76
|
+
expect(described_class.type).to eq(:field)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'the same as all form field types' do
|
80
|
+
expect(described_class).to eq(CHECKBOX).and eq(SELECT_LIST).and eq(RADIO).and eq(TEXTAREA).and eq(FILE_FIELD).and eq(FILLABLE_FIELD).and eq(RADIO_BUTTON)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'integration' do
|
86
|
+
include_context :webapp_fixture
|
87
|
+
let(:capybara_session) { Capybara::Session.new(:rack_test, rack_app).tap { |s| s.visit('/elements') } }
|
88
|
+
|
89
|
+
it 'finds fields' do
|
90
|
+
query = QueryBuilder.find(:text_field).build({ name: 'field_name' })
|
91
|
+
expect(query.execute(capybara_session).tag_name).to eq('input')
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'finds buttons' do
|
95
|
+
query = QueryBuilder.find(:button).build({ text: 'a button' })
|
96
|
+
expect(query.execute(capybara_session).tag_name).to eq('button')
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'finds links' do
|
100
|
+
query = QueryBuilder.find(:link).build({ text: 'a link' })
|
101
|
+
expect(query.execute(capybara_session).tag_name).to eq('a')
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'finds elements' do
|
105
|
+
query = QueryBuilder.find(:element).build({ name: 'field_name' })
|
106
|
+
expect(query.execute(capybara_session).tag_name).to eq('input')
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -1,101 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module PageMagic
|
2
4
|
class Element
|
3
5
|
describe Query do
|
4
|
-
|
5
|
-
missing = PageMagic::Elements::TYPES.find_all do |type|
|
6
|
-
!described_class.constants.include?(type.upcase.to_sym)
|
7
|
-
end
|
8
|
-
expect(missing).to be_empty
|
9
|
-
end
|
10
|
-
|
11
|
-
describe '.find' do
|
12
|
-
it 'finds the constant with the given name' do
|
13
|
-
expect(Query.find(:button)).to be(described_class::BUTTON)
|
14
|
-
end
|
6
|
+
include_context :webapp_fixture
|
15
7
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
8
|
+
let(:page) do
|
9
|
+
elements_page = Class.new do
|
10
|
+
include PageMagic
|
11
|
+
url '/elements'
|
20
12
|
end
|
13
|
+
elements_page.visit(application: rack_app).current_page
|
21
14
|
end
|
22
15
|
|
23
|
-
describe '#
|
24
|
-
|
25
|
-
before do
|
26
|
-
expect(Selector).to receive(:find).with(:css).and_return(selector)
|
27
|
-
end
|
28
|
-
let(:locator) { { css: '.css' } }
|
29
|
-
|
30
|
-
it 'uses the locator to find the correct selector builder' do
|
31
|
-
expect(subject.build(locator)).to eq(locator.values)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'adds options to the result' do
|
35
|
-
expect(subject.build(locator, :options)).to eq(locator.values.concat([:options]))
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'selector support element type' do
|
16
|
+
describe '#execute' do
|
17
|
+
context 'no results found' do
|
39
18
|
subject do
|
40
|
-
|
19
|
+
QueryBuilder.find(:link).build({ css: 'wrong' })
|
41
20
|
end
|
42
21
|
|
43
|
-
it '
|
44
|
-
|
45
|
-
subject.
|
22
|
+
it 'raises an error' do
|
23
|
+
expected_message = 'Unable to find css "wrong"'
|
24
|
+
expect { subject.execute(page.browser) }.to raise_exception(ElementMissingException, expected_message)
|
46
25
|
end
|
47
26
|
end
|
48
|
-
end
|
49
|
-
end
|
50
27
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
28
|
+
context 'to many results returned' do
|
29
|
+
subject do
|
30
|
+
QueryBuilder.find(:link).build({ css: 'a' })
|
31
|
+
end
|
57
32
|
|
58
|
-
|
59
|
-
|
60
|
-
|
33
|
+
it 'raises an error' do
|
34
|
+
expected_message = 'Ambiguous match, found 2 elements matching visible css "a"'
|
35
|
+
expect { subject.execute(page.browser) }.to raise_error AmbiguousQueryException, expected_message
|
36
|
+
end
|
61
37
|
end
|
62
|
-
end
|
63
38
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
end
|
39
|
+
context 'multiple results found' do
|
40
|
+
subject do
|
41
|
+
QueryBuilder.find(:link).build({ css: 'a' }, {}, multiple_results: true)
|
42
|
+
end
|
69
43
|
|
70
|
-
|
71
|
-
|
72
|
-
|
44
|
+
it 'returns an array' do
|
45
|
+
result = subject.execute(page.browser)
|
46
|
+
expect(result).to be_a(Array)
|
47
|
+
expect(result.size).to eq(2)
|
48
|
+
end
|
73
49
|
end
|
74
50
|
|
75
|
-
it 'the
|
76
|
-
|
51
|
+
it 'returns the result of the capybara query' do
|
52
|
+
query = QueryBuilder.find(:link).build({ id: 'form_link' })
|
53
|
+
result = query.execute(page.browser)
|
54
|
+
expect(result.text).to eq('link in a form')
|
77
55
|
end
|
78
56
|
end
|
79
57
|
end
|
80
|
-
|
81
|
-
context 'integration' do
|
82
|
-
include_context :webapp_fixture
|
83
|
-
let(:capybara_session) { Capybara::Session.new(:rack_test, rack_app).tap { |s| s.visit('/elements') } }
|
84
|
-
it 'finds fields' do
|
85
|
-
expect(capybara_session.all(*Query.find(:text_field).build(name: 'field_name')).size).to eq(1)
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'finds buttons' do
|
89
|
-
expect(capybara_session.all(*Query.find(:button).build(text: 'a button')).size).to eq(1)
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'finds links' do
|
93
|
-
expect(capybara_session.all(*Query.find(:link).build(text: 'a link')).size).to eq(1)
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'finds elements' do
|
97
|
-
expect(capybara_session.all(*Query.find(:element).build(name: 'field_name')).size).to eq(1)
|
98
|
-
end
|
99
|
-
end
|
100
58
|
end
|
101
59
|
end
|