regressy_common 1.0.1 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8bf6d29c1351156466a2c1481a8b021899bcbf1849b98da21879e8a992dccd5
4
- data.tar.gz: '02784907fa5f9ca07b439b63992726e02df1ecf43570f66cf22f8881705a3b49'
3
+ metadata.gz: 678d68815b068470da56c12fd7a2304842cc3325967377227c320cf35f7500a7
4
+ data.tar.gz: 0c2342d9381425827bc9c4f96f39477ccdb57b2812b6bedc8afe6518d3793bd4
5
5
  SHA512:
6
- metadata.gz: 7938a1b67421b8ca9ecd2059126f5665e60bf7723d427f381caa817eac9725649e95b079ae488d121414e74ea850d6d4904d033617098d745963124da50e9635
7
- data.tar.gz: 242b027a2339a3605a1eaf82ce94b6461d185617896e0e2cc9aae3e575cd60a656a6ca93fe2979f644befefc437b38829c69e6da915bd9eab17a9702f28253c8
6
+ metadata.gz: 43000dd2ce7e010419dcf974a0123dbc1d287bd58c02a2c9a9c7ae30aae0ca802f18cd13285169ca9e329656b1cdddc1a4a4a6c3443c1cf3c48fa96fe8a15f8e
7
+ data.tar.gz: e915abb8251428aaa1a3f71b0af463a2bc3f52b8367143b890f687231406bac0cc218b52c994e30af9ff88e6bc7c9a5116744fe67bc6862dc30b175204c4d35a
data/Gemfile.lock CHANGED
@@ -1,24 +1,36 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- regressy_common (1.0.0)
4
+ regressy_common (1.2.0)
5
+ activesupport (~> 6.0)
5
6
  httpclient (~> 2.8)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
11
+ activesupport (6.0.1)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 0.7, < 2)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ zeitwerk (~> 2.2)
10
17
  addressable (2.6.0)
11
18
  public_suffix (>= 2.0.2, < 4.0)
12
19
  byebug (11.0.1)
13
20
  childprocess (1.0.1)
14
21
  rake (< 13.0)
15
22
  coderay (1.1.2)
23
+ concurrent-ruby (1.1.5)
16
24
  crack (0.4.3)
17
25
  safe_yaml (~> 1.0.0)
18
26
  diff-lcs (1.3)
19
27
  hashdiff (1.0.0)
20
28
  httpclient (2.8.3)
29
+ i18n (1.7.0)
30
+ concurrent-ruby (~> 1.0)
21
31
  method_source (0.9.2)
32
+ minitest (5.13.0)
33
+ power_assert (1.1.5)
22
34
  pry (0.12.2)
23
35
  coderay (~> 1.1.0)
24
36
  method_source (~> 0.9.0)
@@ -45,10 +57,16 @@ GEM
45
57
  selenium-webdriver (3.142.3)
46
58
  childprocess (>= 0.5, < 2.0)
47
59
  rubyzip (~> 1.2, >= 1.2.2)
60
+ test-unit (3.3.4)
61
+ power_assert
62
+ thread_safe (0.3.6)
63
+ tzinfo (1.2.5)
64
+ thread_safe (~> 0.1)
48
65
  webmock (3.6.2)
49
66
  addressable (>= 2.3.6)
50
67
  crack (>= 0.3.2)
51
68
  hashdiff (>= 0.4.0, < 2.0.0)
69
+ zeitwerk (2.2.2)
52
70
 
53
71
  PLATFORMS
54
72
  ruby
@@ -60,6 +78,7 @@ DEPENDENCIES
60
78
  regressy_common!
61
79
  rspec (~> 3.0)
62
80
  selenium-webdriver (~> 3)
81
+ test-unit (~> 3)
63
82
  webmock (~> 3.6.2)
64
83
 
65
84
  BUNDLED WITH
@@ -0,0 +1,85 @@
1
+ require 'active_support/all'
2
+ module RegressyCommon
3
+ module Checker
4
+ def assert_element_exists(how, what, timeout_value=10)
5
+ assert_with_timeout(failure_message(how, what), timeout_value) do
6
+ (@driver.find_element(how, what))? true : false
7
+ end
8
+ end
9
+
10
+ def assert_element_present(how, what, timeout_value=10)
11
+ failure_message = failure_message(how, what)
12
+ assert_elements_present(how, what, 0, timeout_value, failure_message: failure_message)
13
+ end
14
+
15
+ def assert_elements_present(how, what, index, timeout_value=10, **options)
16
+ options = options&.symbolize_keys
17
+ failure_message = options[:failure_message] || failure_message(how, what, index)
18
+ assert_elements_check_method(how, what, index, :displayed?, failure_message, timeout_value)
19
+ end
20
+
21
+ def assert_element_enabled(how, what, timeout_value=10)
22
+ failure_message = failure_message(how, what)
23
+ assert_elements_enabled(how, what, 0, timeout_value, failure_message: failure_message)
24
+ end
25
+
26
+ def assert_elements_enabled(how, what, index, timeout_value=10, **options)
27
+ options = options.symbolize_keys
28
+ failure_message = options[:failure_message] || failure_message(how, what, index)
29
+ assert_elements_check_method(how, what, index, :enabled?, failure_message, timeout_value)
30
+ end
31
+
32
+ def element_exists_no_assert?(how, what, timeout_value=10)
33
+ timeout_value.times do |count|
34
+ elements = @driver.find_elements(how, what)
35
+ return true if (elements&.length > 0) ## success
36
+ sleep 1
37
+ end
38
+ false
39
+ end
40
+
41
+ def element_present_no_assert?(how, what, timeout_value=10)
42
+ timeout_value.times do |count|
43
+ elements = @driver.find_elements(how, what)
44
+ return true if (elements&.length > 0 && elements[0].displayed?) ## success
45
+ sleep 1
46
+ end
47
+ false
48
+ end
49
+
50
+ private
51
+
52
+ def assert_elements_check_method(how, what, index, check_method, failure_message, timeout_value=10)
53
+ assert_with_timeout(failure_message, timeout_value) do
54
+ result = false
55
+ timeout_value.times do
56
+ elements = @driver.find_elements(how, what)
57
+ (result = true) && break if elements[index]&.send(check_method)
58
+ sleep 1
59
+ end
60
+ result
61
+ end
62
+ end
63
+
64
+ def assert_with_timeout(message, timeout_value=10)
65
+ @test_case.instance_eval do # assert count 集計のため、test_case で実行する
66
+ assert_block message do
67
+ begin
68
+ @driver.manage.timeouts.implicit_wait = 0 # reset every
69
+ Selenium::WebDriver::Wait.new(timeout: timeout_value).until do
70
+ yield
71
+ end
72
+ rescue => e
73
+ logger.debug e.message
74
+ logger.debug "timeout_value: #{timeout_value}"
75
+ false
76
+ end
77
+ end
78
+ end
79
+ end
80
+
81
+ def failure_message(*params)
82
+ "#{caller[0][/`([^']*)'/, 1]} is failed. #{params}"
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,29 @@
1
+ module RegressyCommon
2
+ module Clicker
3
+ def retry_click(how, what, max=10)
4
+ max.times do |c|
5
+ if click_with_rescue(how, what)
6
+ break
7
+ end
8
+ yield if block_given?
9
+ if c >= max-1
10
+ message = "retry_click count is over. how:#{how}, what:#{what}, count:#{c}"
11
+ raise Selenium::WebDriver::Error::UnknownError, message
12
+ end
13
+ sleep 1
14
+ end
15
+ end
16
+
17
+ def click_with_rescue(how, what)
18
+ @driver.find_element(how, what).click
19
+ true
20
+ rescue => e
21
+ logger.info "#{e.inspect}, at click_with_rescue"
22
+ false
23
+ end
24
+
25
+ def failure_message(*params)
26
+ "#{caller[0][/`([^']*)'/, 1]} is failed. #{params}"
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,8 @@
1
+ module RegressyCommon
2
+ module Selector
3
+ def select_option_by_text (how, what, content)
4
+ element = @driver.find_element(how, what)
5
+ Selenium::WebDriver::Support::Select.new(element).select_by(:text, content)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,16 @@
1
+ module RegressyCommon
2
+ module Sender
3
+ def send_keys_with_enter (how, what, content)
4
+ target = @driver.find_element(how, what)
5
+ @driver.execute_script("arguments[0].value = arguments[1];", target, content)
6
+ # for application listen to key_up/down
7
+ target.send_keys(" ")
8
+ target.send_keys(:backspace)
9
+ end
10
+
11
+ def send_keys(how, what, content)
12
+ target = @driver.find_element(how, what)
13
+ @driver.execute_script("arguments[0].value = arguments[1];", target, content)
14
+ end
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module RegressyCommon
2
- VERSION = "1.0.1"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -1,5 +1,9 @@
1
1
  require "regressy_common/snap_shot"
2
2
  require "regressy_common/snap_storage"
3
+ require "regressy_common/checker"
4
+ require "regressy_common/clicker"
5
+ require "regressy_common/selector"
6
+ require "regressy_common/sender"
3
7
 
4
8
  module RegressyCommon
5
9
  class Error < StandardError; end
@@ -36,10 +36,12 @@ Gem::Specification.new do |spec|
36
36
  spec.require_paths = ["lib"]
37
37
 
38
38
  spec.add_dependency "httpclient", "~> 2.8"
39
+ spec.add_dependency "activesupport", "~> 6.0"
39
40
  spec.add_development_dependency "bundler", "~> 1.17"
40
41
  spec.add_development_dependency "rake", "~> 10.0"
41
42
  spec.add_development_dependency "rspec", "~> 3.0"
42
43
  spec.add_development_dependency "pry-byebug", "~> 3.7"
43
44
  spec.add_development_dependency "webmock", "~> 3.6.2"
44
45
  spec.add_development_dependency "selenium-webdriver", "~> 3"
46
+ spec.add_development_dependency "test-unit", "~> 3"
45
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: regressy_common
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - info@fluxware.co.jp
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-16 00:00:00.000000000 Z
11
+ date: 2019-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '6.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '6.0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +122,20 @@ dependencies:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
124
  version: '3'
125
+ - !ruby/object:Gem::Dependency
126
+ name: test-unit
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '3'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '3'
111
139
  description:
112
140
  email:
113
141
  - info@fluxware.co.jp
@@ -128,6 +156,10 @@ files:
128
156
  - docker/development/Dockerfile
129
157
  - docker/development/docker-compose.yml
130
158
  - lib/regressy_common.rb
159
+ - lib/regressy_common/checker.rb
160
+ - lib/regressy_common/clicker.rb
161
+ - lib/regressy_common/selector.rb
162
+ - lib/regressy_common/sender.rb
131
163
  - lib/regressy_common/snap_shot.rb
132
164
  - lib/regressy_common/snap_storage.rb
133
165
  - lib/regressy_common/version.rb