gridium 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Dockerfile +8 -0
- data/Gemfile +2 -0
- data/bin/docker/cleanup.sh +8 -0
- data/bin/docker/start.sh +6 -0
- data/docker-compose.yml +24 -0
- data/lib/element.rb +100 -16
- data/lib/gridium/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29e8d042d90194d5cb0d830713509abedb474cec
|
4
|
+
data.tar.gz: c3537ff4382e97326165f66e4edf7ac68419dd02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc56831da6668d562e22913f10473f2799b2cc2d49401760f2b7b245e095d7f486ede71c480ff1c9e66e12d713476da658eeec0fbffabe82b20c1d49eb1937d1
|
7
|
+
data.tar.gz: dcbd1d15fe089126b536ee5ec65a12578620a89d1fe6bf06a729d7e0c192288e4a673fdf69aa5bee9919ede7b4ce8c5a6aab36f27b7cc69169adfbd31e6b36b0
|
data/.gitignore
CHANGED
data/Dockerfile
ADDED
data/Gemfile
CHANGED
data/bin/docker/start.sh
ADDED
data/docker-compose.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
version: '2'
|
2
|
+
services:
|
3
|
+
hub:
|
4
|
+
image: sethuster/selenium-hub
|
5
|
+
ports:
|
6
|
+
- "4444"
|
7
|
+
firefox:
|
8
|
+
image: sethuster/node-firefox-debugx
|
9
|
+
ports:
|
10
|
+
- "5900"
|
11
|
+
depends_on:
|
12
|
+
- hub
|
13
|
+
mustadio:
|
14
|
+
image: yetanotherlucas/mustadio
|
15
|
+
ports:
|
16
|
+
- "3000"
|
17
|
+
gridium:
|
18
|
+
build: .
|
19
|
+
environment:
|
20
|
+
- S3_ACCESS_KEY_ID=$S3_ACCESS_KEY_ID
|
21
|
+
- S3_SECRET_ACCESS_KEY=$S3_SECRET_ACCESS_KEY
|
22
|
+
- S3_DEFAULT_REGION=$S3_DEFAULT_REGION
|
23
|
+
- S3_ROOT_BUCKET=$S3_ROOT_BUCKET
|
24
|
+
command: "tail -f /dev/null"
|
data/lib/element.rb
CHANGED
@@ -5,6 +5,7 @@ require 'spec_data'
|
|
5
5
|
class Element
|
6
6
|
attr_reader :name, :by, :locator
|
7
7
|
|
8
|
+
|
8
9
|
def initialize(name, by, locator)
|
9
10
|
@name = name
|
10
11
|
@by = by
|
@@ -16,6 +17,9 @@ class Element
|
|
16
17
|
|
17
18
|
# selenium web element
|
18
19
|
@element = nil
|
20
|
+
|
21
|
+
#how long to wait between clearing an input and sending keys to it
|
22
|
+
@text_padding_time = 0.1
|
19
23
|
end
|
20
24
|
|
21
25
|
def to_s
|
@@ -100,6 +104,11 @@ class Element
|
|
100
104
|
|
101
105
|
def clear
|
102
106
|
element.clear
|
107
|
+
sleep @text_padding_time
|
108
|
+
end
|
109
|
+
|
110
|
+
def value
|
111
|
+
element.attribute "value"
|
103
112
|
end
|
104
113
|
|
105
114
|
def click
|
@@ -113,16 +122,43 @@ class Element
|
|
113
122
|
end
|
114
123
|
end
|
115
124
|
|
125
|
+
#
|
126
|
+
# add to what's already in the text field
|
127
|
+
# for cases when you don't want to stomp what's already in the text field
|
128
|
+
#
|
129
|
+
|
130
|
+
def append_keys(*args)
|
131
|
+
ElementExtensions.highlight(self) if Gridium.config.highlight_verifications
|
132
|
+
$verification_passes += 1
|
133
|
+
unless element.enabled?
|
134
|
+
raise "Browser Error: tried to enter #{args} but the input is disabled"
|
135
|
+
end
|
136
|
+
element.send_keys(*args)
|
137
|
+
sleep @text_padding_time
|
138
|
+
# when it's possible to validate for more than non-empty outcomes, do that here
|
139
|
+
end
|
140
|
+
|
141
|
+
#
|
142
|
+
# overwrite to what's already in the text field
|
143
|
+
# and validate afterward
|
144
|
+
#
|
145
|
+
|
116
146
|
def send_keys(*args)
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
147
|
+
ElementExtensions.highlight(self) if Gridium.config.highlight_verifications
|
148
|
+
$verification_passes += 1
|
149
|
+
unless element.enabled?
|
150
|
+
raise "Browser Error: tried to enter #{args} but the input is disabled"
|
151
|
+
end
|
152
|
+
if only_symbols? *args
|
153
|
+
append_keys *args
|
122
154
|
else
|
123
|
-
|
155
|
+
_stomp_input_text *args
|
156
|
+
field_empty_afterward?
|
124
157
|
end
|
125
158
|
end
|
159
|
+
alias_method :text=, :send_keys
|
160
|
+
|
161
|
+
|
126
162
|
|
127
163
|
def location
|
128
164
|
element.location
|
@@ -202,16 +238,6 @@ class Element
|
|
202
238
|
element.text
|
203
239
|
end
|
204
240
|
|
205
|
-
def text=(text)
|
206
|
-
element.clear
|
207
|
-
element.send_keys(text)
|
208
|
-
end
|
209
|
-
|
210
|
-
def value
|
211
|
-
#this is used for inputs and forms
|
212
|
-
element.attribute("value")
|
213
|
-
end
|
214
|
-
|
215
241
|
#
|
216
242
|
# Search for an element within this element
|
217
243
|
#
|
@@ -318,4 +344,62 @@ class Element
|
|
318
344
|
Log.warn("Stale element detected.... #{self.to_s}")
|
319
345
|
return true
|
320
346
|
end
|
347
|
+
|
348
|
+
#
|
349
|
+
# helper to clear input and put new text in
|
350
|
+
#
|
351
|
+
|
352
|
+
def _stomp_input_text(*args)
|
353
|
+
Log.debug("Clearing \"#{value}\" from element: (#{self})")
|
354
|
+
element.clear
|
355
|
+
sleep @text_padding_time
|
356
|
+
Log.debug("Typing: #{args} into element: (#{self}).")
|
357
|
+
element.send_keys(*args)
|
358
|
+
sleep @text_padding_time
|
359
|
+
end
|
360
|
+
|
361
|
+
#
|
362
|
+
# raise error if the field is empty after we sent it values
|
363
|
+
# TODO: verify if text correct afterward, but need to be able to handle cases
|
364
|
+
# of symbols like :space and :enter correctly
|
365
|
+
#
|
366
|
+
|
367
|
+
def field_empty_afterward?(*args)
|
368
|
+
check_again = (not args.empty? and no_symbols? *args)
|
369
|
+
field_is_empty_but_should_not_be = (check_again and field_empty?)
|
370
|
+
if field_is_empty_but_should_not_be
|
371
|
+
raise "Browser Error: tried to input #{args} but found an empty string afterward: #{actual_text}"
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
def field_empty?
|
376
|
+
value.empty?
|
377
|
+
end
|
378
|
+
|
379
|
+
#
|
380
|
+
# helper to check if *args to send_keys has any symbols
|
381
|
+
# if so, don't bother trying to validate the text afterward
|
382
|
+
#
|
383
|
+
|
384
|
+
def no_symbols?(*args)
|
385
|
+
symbols = args.select { |_| _.is_a? Symbol }
|
386
|
+
if symbols.length > 0
|
387
|
+
return false
|
388
|
+
end
|
389
|
+
true
|
390
|
+
end
|
391
|
+
|
392
|
+
#
|
393
|
+
# helper to check if *args to send_keys has only symbols
|
394
|
+
# if so, don't bother clearing the field first
|
395
|
+
#
|
396
|
+
|
397
|
+
def only_symbols?(*args)
|
398
|
+
symbols = args.select { |_| _.is_a? Symbol }
|
399
|
+
if symbols.length == args.length
|
400
|
+
return true
|
401
|
+
end
|
402
|
+
false
|
403
|
+
end
|
404
|
+
|
321
405
|
end
|
data/lib/gridium/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gridium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Urban
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -142,12 +142,16 @@ files:
|
|
142
142
|
- ".rspec"
|
143
143
|
- ".travis.yml"
|
144
144
|
- CODE_OF_CONDUCT.md
|
145
|
+
- Dockerfile
|
145
146
|
- Gemfile
|
146
147
|
- LICENSE.txt
|
147
148
|
- README.md
|
148
149
|
- Rakefile
|
149
150
|
- bin/console
|
151
|
+
- bin/docker/cleanup.sh
|
152
|
+
- bin/docker/start.sh
|
150
153
|
- bin/setup
|
154
|
+
- docker-compose.yml
|
151
155
|
- gridium.gemspec
|
152
156
|
- lib/driver.rb
|
153
157
|
- lib/driver_extensions.rb
|