selenium_statistics 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/selenium_statistics/statistics.rb +18 -36
- data/selenium_statistics.gemspec +1 -1
- data/spec/statistics_spec.rb +22 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1df0ba55ac95484c5cf9126981dedd382d5a18c6
|
4
|
+
data.tar.gz: 14b6123a561f4b73baceadc9a972f1249cfdf774
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 353be2c4469f9b7a8b3dbbdafd854f85e199b6e95faef14bb02707f2194c129fb734fa2903e6c9b0891002714d0f67aaf8b720c2e2a4cdcd789cc6cdb487856c
|
7
|
+
data.tar.gz: d41e8335e690a0965c82404f70299047c5ebba9692692b554b0ce3dbe0541edefd9aa905414357e0356bc188f623d026ca4ed6b938e4073c3bfb0577d6b33761
|
@@ -2,54 +2,36 @@ module SeleniumStatistics
|
|
2
2
|
|
3
3
|
extend self
|
4
4
|
|
5
|
-
attr_reader :time, :executions
|
5
|
+
attr_reader :time, :executions, :commands
|
6
6
|
|
7
7
|
@commands = {}
|
8
8
|
@executions = 0
|
9
9
|
@time = 0
|
10
|
+
@test_start = Time.now
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
def method_missing(command, time = nil)
|
13
|
+
command = command.to_s
|
14
|
+
command.gsub!('get_element_location_once_scrolled_into_view', 'get_element_location')
|
15
|
+
command.gsub!('get_element_value_of_css_property', 'get_element_css_value')
|
14
16
|
|
15
|
-
|
16
|
-
if command == :get_element_location_once_scrolled_into_view
|
17
|
-
command = :get_element_location
|
18
|
-
end
|
19
|
-
if command == :get_element_value_of_css_property
|
20
|
-
command = :get_element_css_value
|
21
|
-
end
|
22
|
-
|
23
|
-
define_method("#{command}=") do |time|
|
24
|
-
@commands[command] ||= {}
|
25
|
-
|
26
|
-
@commands[command][:time] ||= 0
|
27
|
-
@commands[command][:count] ||= 0
|
28
|
-
|
29
|
-
@commands[command][:time] += time
|
30
|
-
@commands[command][:count] += 1
|
31
|
-
@commands[command][:average] = @commands[command][:time] / @commands[command][:count]
|
17
|
+
return @commands[command] unless command =~ /=$/
|
32
18
|
|
33
|
-
|
34
|
-
@time += time
|
19
|
+
command = command.chomp('=')
|
35
20
|
|
36
|
-
|
37
|
-
SeleniumStatistics.logger.debug "#{command} executed total of #{@commands[command][:count]} times in #{ @commands[command][:time]} seconds"
|
38
|
-
end
|
21
|
+
@commands[command] ||= {}
|
39
22
|
|
40
|
-
|
41
|
-
|
42
|
-
end
|
23
|
+
@commands[command][:time] ||= 0
|
24
|
+
@commands[command][:count] ||= 0
|
43
25
|
|
44
|
-
@
|
45
|
-
|
26
|
+
@commands[command][:time] += time
|
27
|
+
@commands[command][:count] += 1
|
28
|
+
@commands[command][:average] = @commands[command][:time] / @commands[command][:count]
|
46
29
|
|
47
|
-
|
48
|
-
|
49
|
-
end
|
30
|
+
@executions += 1
|
31
|
+
@time += time
|
50
32
|
|
51
|
-
|
52
|
-
|
33
|
+
SeleniumStatistics.logger.info "Executed #{command} in #{time} sec"
|
34
|
+
SeleniumStatistics.logger.debug "#{command} executed total of #{@commands[command][:count]} times in #{ @commands[command][:time]} seconds"
|
53
35
|
end
|
54
36
|
|
55
37
|
def results(sort=nil)
|
data/selenium_statistics.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "selenium_statistics"
|
7
|
-
spec.version = "0.
|
7
|
+
spec.version = "0.3.0"
|
8
8
|
spec.authors = ["Titus Fortner"]
|
9
9
|
spec.email = ["titusfortner@gmail.com"]
|
10
10
|
spec.summary = %q{Generate information about Selenium commands}
|
data/spec/statistics_spec.rb
CHANGED
@@ -9,24 +9,39 @@ describe 'Selenium Statistics' do
|
|
9
9
|
driver.quit
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
it 'records total command count' do
|
13
13
|
driver.get "file://#{html}"
|
14
14
|
driver.title
|
15
|
-
expect(SeleniumStatistics.executions).to eql(
|
15
|
+
expect(SeleniumStatistics.executions).to eql(3)
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
it 'records total command time' do
|
19
19
|
driver.get "file://#{html}"
|
20
20
|
driver.title
|
21
|
-
expect(SeleniumStatistics.executions).to eql(
|
21
|
+
expect(SeleniumStatistics.executions).to eql(3)
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
it 'records time and count for each command' do
|
25
25
|
driver.get "file://#{html}"
|
26
26
|
driver.title
|
27
27
|
|
28
|
-
expect(SeleniumStatistics.
|
29
|
-
expect(SeleniumStatistics.
|
28
|
+
expect(SeleniumStatistics.get_title[:count]).to eql(1)
|
29
|
+
expect(SeleniumStatistics.get_title[:time]).to be > 0
|
30
30
|
end
|
31
31
|
|
32
|
+
it 'handles get_element_location' do
|
33
|
+
driver.get "file://#{html}"
|
34
|
+
element = driver.find_element(:tag_name, 'body')
|
35
|
+
element.location_once_scrolled_into_view
|
36
|
+
|
37
|
+
expect(SeleniumStatistics.commands).to have_key('get_element_location')
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'handles get_element_css_value' do
|
41
|
+
driver.get "file://#{html}"
|
42
|
+
element = driver.find_element(:tag_name, 'body')
|
43
|
+
element.css_value('whatever')
|
44
|
+
|
45
|
+
expect(SeleniumStatistics.commands).to have_key('get_element_css_value')
|
46
|
+
end
|
32
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selenium_statistics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Titus Fortner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.5.2.3
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: Generate information about Selenium commands
|