sparkling_watir 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/sparkling_watir/element.rb +12 -12
- data/lib/sparkling_watir/element_collection.rb +57 -0
- data/lib/sparkling_watir.rb +4 -0
- data/sparkling_watir.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d1718777f4727027f7138b2693954512a8f9ec34947923c544f04e4223dc9bc
|
4
|
+
data.tar.gz: c63f086a9ea7a9730c04a5339f6a4344748bcde91a3e51331bb071a629556b10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e84c10cf081151adcd7578d5de4133acf80366f96ee0b3b1b55f94691e94a990d2039b0c3d022c9e0e68c20de1cdafff1f71fc69b0c69292fca90685178ec211
|
7
|
+
data.tar.gz: 5199b89a3ad87ee8aeb84064f0ec1ae31f645818b19828d97fea5727e81dd2cd42959db657b20abda386319f4e9af9e5a82b9c467d37bc4bcdf6ee9d3cca152a
|
data/Gemfile.lock
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'gestures'
|
4
3
|
require_relative 'wait'
|
5
4
|
|
6
5
|
module SparklingWatir
|
@@ -8,17 +7,19 @@ module SparklingWatir
|
|
8
7
|
# This is a element in the native app context
|
9
8
|
#
|
10
9
|
class Element
|
11
|
-
attr_reader :driver
|
10
|
+
attr_reader :driver, :selector
|
11
|
+
attr_accessor :element
|
12
12
|
|
13
13
|
include Waitable
|
14
14
|
|
15
|
-
def initialize(driver, selector)
|
15
|
+
def initialize(driver = nil, selector = nil, element = nil)
|
16
16
|
@driver = driver
|
17
17
|
@selector = selector
|
18
|
+
@element = element
|
18
19
|
end
|
19
20
|
|
20
21
|
def wd
|
21
|
-
|
22
|
+
element || locate
|
22
23
|
end
|
23
24
|
|
24
25
|
def exists?
|
@@ -32,7 +33,7 @@ module SparklingWatir
|
|
32
33
|
|
33
34
|
def present?
|
34
35
|
assert_exists
|
35
|
-
|
36
|
+
element&.displayed?
|
36
37
|
rescue Watir::Exception::UnknownObjectException
|
37
38
|
false
|
38
39
|
end
|
@@ -41,21 +42,21 @@ module SparklingWatir
|
|
41
42
|
|
42
43
|
def enabled?
|
43
44
|
assert_exists
|
44
|
-
|
45
|
+
element&.enabled?
|
45
46
|
rescue Watir::Exception::UnknownObjectException
|
46
47
|
false
|
47
48
|
end
|
48
49
|
|
49
50
|
def coordinates
|
50
51
|
assert_exists
|
51
|
-
|
52
|
+
element&.location
|
52
53
|
end
|
53
54
|
|
54
55
|
alias location coordinates
|
55
56
|
|
56
57
|
def size
|
57
58
|
assert_exists
|
58
|
-
|
59
|
+
element&.size
|
59
60
|
end
|
60
61
|
|
61
62
|
def bounds
|
@@ -84,16 +85,15 @@ module SparklingWatir
|
|
84
85
|
private
|
85
86
|
|
86
87
|
def locate
|
87
|
-
@element
|
88
|
+
@element ||= driver&.find_element(selector)
|
88
89
|
rescue Selenium::WebDriver::Error::NoSuchElementError
|
89
90
|
nil
|
90
91
|
end
|
91
92
|
|
92
93
|
def assert_exists
|
93
|
-
locate unless
|
94
|
-
return if @element
|
94
|
+
locate unless element
|
95
95
|
|
96
|
-
raise Watir::Exception::UnknownObjectException
|
96
|
+
raise Watir::Exception::UnknownObjectException unless element
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require_relative 'element'
|
2
|
+
|
3
|
+
module SparklingWatir
|
4
|
+
class ElementCollection
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
attr_reader :driver, :selector
|
8
|
+
|
9
|
+
def initialize(driver, selector)
|
10
|
+
@driver = driver
|
11
|
+
@selector = selector
|
12
|
+
@collection = create_collection
|
13
|
+
end
|
14
|
+
|
15
|
+
def add(element)
|
16
|
+
@collection << element
|
17
|
+
end
|
18
|
+
|
19
|
+
def each
|
20
|
+
@collection.each do |element|
|
21
|
+
yield element
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
alias length count
|
26
|
+
alias size count
|
27
|
+
|
28
|
+
alias empty? none?
|
29
|
+
|
30
|
+
alias exist? any?
|
31
|
+
alias exists? any?
|
32
|
+
|
33
|
+
def to_a
|
34
|
+
@collection
|
35
|
+
end
|
36
|
+
|
37
|
+
def [](value)
|
38
|
+
@collection[value]
|
39
|
+
end
|
40
|
+
|
41
|
+
def first
|
42
|
+
@collection.first
|
43
|
+
end
|
44
|
+
|
45
|
+
def last
|
46
|
+
@collection.last
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def create_collection
|
52
|
+
elements = driver.find_elements selector
|
53
|
+
|
54
|
+
elements.map { |element| Element.new(driver, nil, element) }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/sparkling_watir.rb
CHANGED
data/sparkling_watir.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'sparkling_watir'
|
8
|
-
spec.version = '0.1.
|
8
|
+
spec.version = '0.1.1'
|
9
9
|
spec.authors = ['Agustin Pequeno']
|
10
10
|
spec.email = ['agustin.pe94@gmail.com']
|
11
11
|
spec.homepage = 'https://github.com/aguspe/sparkling_watir'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sparkling_watir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Agustin Pequeno
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- Rakefile
|
139
139
|
- lib/sparkling_watir.rb
|
140
140
|
- lib/sparkling_watir/element.rb
|
141
|
+
- lib/sparkling_watir/element_collection.rb
|
141
142
|
- lib/sparkling_watir/gestures.rb
|
142
143
|
- lib/sparkling_watir/logger.rb
|
143
144
|
- lib/sparkling_watir/screenshot.rb
|