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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46d996e7c1fc5e700bf68f655503ef6e2eb3c6fd
4
- data.tar.gz: b3c5bfdb542a3bcaa0b98723401a2fab985d6b98
3
+ metadata.gz: 29e8d042d90194d5cb0d830713509abedb474cec
4
+ data.tar.gz: c3537ff4382e97326165f66e4edf7ac68419dd02
5
5
  SHA512:
6
- metadata.gz: a89978028aed88aed4c75d2d379daed93fcb86b6b9f4fc74dfe5a58cfbf940827211b6125192d496ec88aec37c8704288a55c62ed0c167af31e47a8cd125c637
7
- data.tar.gz: f933eca0a1ad6bd394cf9f56228162550b5368d17eed12a7713798d9bcad3f8e065d19796ea9205201d695f402fcc9f2031f498cd5c7a5d52ee6f49474f67682
6
+ metadata.gz: dc56831da6668d562e22913f10473f2799b2cc2d49401760f2b7b245e095d7f486ede71c480ff1c9e66e12d713476da658eeec0fbffabe82b20c1d49eb1937d1
7
+ data.tar.gz: dcbd1d15fe089126b536ee5ec65a12578620a89d1fe6bf06a729d7e0c192288e4a673fdf69aa5bee9919ede7b4ce8c5a6aab36f27b7cc69169adfbd31e6b36b0
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
  /tmp/
10
10
  /.idea/
11
11
  *.gem
12
+ Dockerfile-e
data/Dockerfile ADDED
@@ -0,0 +1,8 @@
1
+ FROM ruby:2.3
2
+
3
+ WORKDIR /
4
+
5
+ COPY . /
6
+
7
+ CMD gem install bundle;
8
+ RUN bundle;
data/Gemfile CHANGED
@@ -4,3 +4,5 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'rspec-mocks'
7
+ gem 'rspec'
8
+ gem 'rake'
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+
3
+ #do normal docker cleanup
4
+ docker rm -fv $(docker ps -qa)
5
+
6
+ #purge any gridium images so docker-compose up will rebuild it
7
+ docker rmi $(docker images gridium_gridium --format "{{.ID}}")
8
+
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+
3
+ docker-compose up
4
+
5
+ #now shell into gridium container and execute tests you want to see run
6
+ # docker exec gridium_gridium_1 rspec /spec/element_spec.rb -e "text input"
@@ -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
- Log.debug("Typing: #{args} into element: (#{self}).")
118
- if element.enabled?
119
- ElementExtensions.highlight(self) if Gridium.config.highlight_verifications
120
- $verification_passes += 1
121
- element.send_keys(*args)
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
- Log.error('Cannot type into element. Element is not present.')
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
@@ -1,3 +1,3 @@
1
1
  module Gridium
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
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
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-01 00:00:00.000000000 Z
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