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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bfd50d16177bab19df682a46a843235397a11d09
4
- data.tar.gz: 439050e3a6be6601ddb0072a9ce71fede68657ca
3
+ metadata.gz: 1df0ba55ac95484c5cf9126981dedd382d5a18c6
4
+ data.tar.gz: 14b6123a561f4b73baceadc9a972f1249cfdf774
5
5
  SHA512:
6
- metadata.gz: 6719b9180e5ec5804a1a3168b11d5250cac8d2cd8083e272a6174bbbf5415ef00596cce9efb8b47069e5667cd715f657f047149cb681d250263894b7433e8217
7
- data.tar.gz: 176b6be46962d20f39f610d26175266979663759aec5235c255cf2402e64347e8e71d294353a887a1f8464198550b1b918e8fb683c5f72391aa49f14c8e4befc
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
- COMMANDS = Selenium::WebDriver::Remote::Bridge::COMMANDS.keys +
12
- Selenium::WebDriver::Remote::W3C::Bridge::COMMANDS.keys +
13
- Selenium::WebDriver::Remote::OSS::Bridge::COMMANDS.keys
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
- COMMANDS.each do |command|
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
- @executions += 1
34
- @time += time
19
+ command = command.chomp('=')
35
20
 
36
- SeleniumStatistics.logger.info "Executed #{command} in #{time} sec"
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
- define_method(command) do
41
- @commands[command]
42
- end
23
+ @commands[command][:time] ||= 0
24
+ @commands[command][:count] ||= 0
43
25
 
44
- @test_start = Time.now
45
- end
26
+ @commands[command][:time] += time
27
+ @commands[command][:count] += 1
28
+ @commands[command][:average] = @commands[command][:time] / @commands[command][:count]
46
29
 
47
- def get_element_location_once_scrolled_into_view=(*args)
48
- self.get_element_location= args.first
49
- end
30
+ @executions += 1
31
+ @time += time
50
32
 
51
- def get_element_value_of_css_property=(*args)
52
- self.get_element_css_value= args.first
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)
@@ -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.2.2"
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}
@@ -9,24 +9,39 @@ describe 'Selenium Statistics' do
9
9
  driver.quit
10
10
  end
11
11
 
12
- specify 'records total command count' do
12
+ it 'records total command count' do
13
13
  driver.get "file://#{html}"
14
14
  driver.title
15
- expect(SeleniumStatistics.executions).to eql(2)
15
+ expect(SeleniumStatistics.executions).to eql(3)
16
16
  end
17
17
 
18
- specify 'records total command time' do
18
+ it 'records total command time' do
19
19
  driver.get "file://#{html}"
20
20
  driver.title
21
- expect(SeleniumStatistics.executions).to eql(2)
21
+ expect(SeleniumStatistics.executions).to eql(3)
22
22
  end
23
23
 
24
- specify 'records time and count for each command' do
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.getTitle[:count]).to eql(1)
29
- expect(SeleniumStatistics.getTitle[:time]).to be > 0
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.2.2
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: 2017-09-08 00:00:00.000000000 Z
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.6.11
110
+ rubygems_version: 2.5.2.3
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: Generate information about Selenium commands