rwebspec 6.3 → 7.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
- SHA1:
3
- metadata.gz: ee167834e0e28e4c2af11a4e0b2dfcb57b69a103
4
- data.tar.gz: ff5108c71f7da3b77605ae72be537ce8261bf041
2
+ SHA256:
3
+ metadata.gz: 13001af912d404bb47f5efea617edbc01f637b94c97c145a052e291e45a6bef6
4
+ data.tar.gz: 5224b41222e04f2b8d25d5538fd8b76204380b593560f5309df0d2bb2be31f28
5
5
  SHA512:
6
- metadata.gz: e7b8a12119b985e1838c4a348f8a7457a63b5e24cb56c02398d87aa205c61f7807fd846b4e75b47075a01f8e1a866a37fb5c010c23c21a949113f4be5af81cd5
7
- data.tar.gz: 6ee5a1dbfaaecd49fbf0e57d3dae9d8f16e1b6784f50db2b2da38842ae500d206da70a960406908ea0c6b541ca0cdfdc1029f805605933292093de5f4fa7bf81
6
+ metadata.gz: bf773632474e2ea5fcbd488cad11e63b7d653107894fad7004a6e9b298f4af186bc43e8d5d6ac26c8a555f50a4a3bf395f320f1a3851837cd0f4b58834c855a7
7
+ data.tar.gz: b5bbee1f39db72beaa58d2941e4411d2065dd6a22b7dd9ceef748fc9660213e98a7317702c9dfaaffcab573e8e10aa90589e5b91186729cdce6f497217a31a75
data/CHANGELOG CHANGED
@@ -1,8 +1,5 @@
1
1
  CHANGELOG
2
2
  =========
3
- 6.3
4
-
5
- [Enhancement] Support Selenium-WebDriver 6.3
6
3
 
7
4
  6.2.5
8
5
 
data/Rakefile CHANGED
@@ -77,7 +77,7 @@ end
77
77
  spec = Gem::Specification.new do |s|
78
78
  s.platform= Gem::Platform::RUBY
79
79
  s.name = "rwebspec"
80
- s.version = "6.3"
80
+ s.version = "7.0"
81
81
  s.summary = "Web application functional specification in Ruby"
82
82
  s.description = "Executable functional specification for web applications in RSpec syntax with Watir or Selenium WebDriver"
83
83
 
@@ -86,8 +86,6 @@ spec = Gem::Specification.new do |s|
86
86
  s.homepage= "http://github.com/zhimin/rwebspec/tree/master"
87
87
  s.rubyforge_project = "rwebspec"
88
88
  s.licenses = ["MIT"]
89
-
90
- s.has_rdoc = true
91
89
  s.requirements << 'none'
92
90
  s.require_path = "lib"
93
91
  s.autorequire = "rwebspec"
@@ -107,11 +105,7 @@ spec = Gem::Specification.new do |s|
107
105
  s.add_dependency("activesupport", ">= 3.2.17")
108
106
  # s.add_dependency("ci_reporter", "~> 1.9.2")
109
107
 
110
- unless RUBY_PLATFORM =~ /mingw/
111
- s.add_dependency("selenium-webdriver", ">= 2.42")
112
- else
113
- s.add_dependency("watir-classic", ">= 4.0.1")
114
- end
108
+ s.add_dependency("selenium-webdriver", "~> 3.142")
115
109
  end
116
110
 
117
111
  Gem::PackageTask.new(spec) do |pkg|
@@ -17,8 +17,6 @@ require 'uri'
17
17
 
18
18
  module RWebSpec
19
19
  module Driver
20
- include RWebSpec::TestWisePlugin
21
- include RWebSpec::Popup
22
20
 
23
21
  # open a browser, and set base_url via hash, but does not acually
24
22
  #
@@ -13,9 +13,6 @@ require 'uri'
13
13
 
14
14
  module RWebSpec
15
15
  module Driver
16
- include RWebSpec::TestWisePlugin
17
- include RWebSpec::Popup
18
-
19
16
  # open a browser, and set base_url via hash, but does not acually
20
17
  #
21
18
  # example:
@@ -62,13 +59,12 @@ module RWebSpec
62
59
 
63
60
  options = default_options.merge options
64
61
 
65
- if $TESTWISE_BROWSER
66
- options[:browser] = $TESTWISE_BROWSER.downcase
62
+ if ENV["BROWSER"] && !ENV["BROWSER"].empty?
63
+ options[:browser] = ENV["BROWSER"].downcase
67
64
  end
68
65
 
69
- if (RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/) &&
70
- (options[:browser].nil? || options[:browser].to_s == "ie")
71
- options[:browser] = "firefox"
66
+ if options[:browser].nil?
67
+ options[:browser] = "chrome"
72
68
  end
73
69
 
74
70
  if base_url =~ /^file:/
@@ -162,7 +158,10 @@ module RWebSpec
162
158
  # Example:
163
159
  # begin_at("http://www.itest2.com")
164
160
  def begin_at(url)
165
- dump_caller_stack
161
+ if respond_to?(:dump_caller_stack)
162
+ dump_caller_stack()
163
+ end
164
+
166
165
  @web_browser.begin_at(url)
167
166
  end
168
167
 
@@ -345,10 +344,10 @@ module RWebSpec
345
344
 
346
345
  def perform_operation(& block)
347
346
  begin
348
- dump_caller_stack
349
- operation_delay
350
- if defined? TestWiseRuntimeSupport
351
- check_for_pause
347
+ if defined? TestWiseRuntimeSupport
348
+ dump_caller_stack() if respond_to?(:dump_caller_stack)
349
+ operation_delay() if respond_to?(:operation_delay)
350
+ check_for_pause if respond_to?(:check_for_pause)
352
351
  end
353
352
 
354
353
  yield
@@ -71,11 +71,24 @@ module RWebSpec
71
71
  return
72
72
  end
73
73
 
74
- if options[:prefs]
75
- @browser = Selenium::WebDriver.for :chrome, :prefs => options[:prefs]
74
+ the_chrome_options = Selenium::WebDriver::Chrome::Options.new
75
+ # make the same behaviour as Python/JS
76
+ # leave browser open until calls 'driver.quit'
77
+ the_chrome_options.add_option("detach", true)
78
+
79
+ if ENV["BROWSER_HEADLESS"] == "true"
80
+ the_chrome_options.add_argument("--headless")
81
+ end
82
+
83
+ if defined?(TestWiseRuntimeSupport) && defined?(debugging?) && debugging?
84
+ browser_debugging_port = get_browser_debugging_port() rescue 19218 # default port
85
+ puts("Enabled chrome browser debug port: #{browser_debugging_port}")
86
+ the_chrome_options.add_argument("--remote-debugging-port=#{browser_debugging_port}")
76
87
  else
77
- @browser = Selenium::WebDriver.for :chrome
88
+ # puts("Chrome debugging port not enabled.")
78
89
  end
90
+
91
+ @browser = Selenium::WebDriver.for(:chrome, :options => the_chrome_options)
79
92
  @browser.navigate.to base_url
80
93
  end
81
94
 
@@ -38,14 +38,8 @@ if ::RSpec::Version::STRING && ::RSpec::Version::STRING =~ /^3/
38
38
  end
39
39
  =end
40
40
 
41
- unless defined? RWEBSPEC_VERSION
42
- RWEBSPEC_VERSION = RWEBUNIT_VERSION = "6.0.2"
43
- end
44
-
45
- $testwise_polling_interval = 1 # seconds
46
-
47
- $testwise_polling_timeout = 30 # seconds
48
41
 
42
+ RWEBSPEC_VERSION = "7.0"
49
43
 
50
44
  if RUBY_PLATFORM =~ /mingw/
51
45
  $screenshot_supported = false
@@ -128,8 +122,6 @@ module RWebSpec
128
122
  end
129
123
  end
130
124
 
131
- require File.dirname(__FILE__) + "/plugins/testwise_plugin.rb"
132
-
133
125
  # Changed in v4.3, the framework is loaded when initliating or reuse browser
134
126
  #RWebSpec.load_framework
135
127
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rwebspec
3
3
  version: !ruby/object:Gem::Version
4
- version: '6.3'
4
+ version: '7.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zhimin Zhan
8
8
  autorequire: rwebspec
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-14 00:00:00.000000000 Z
11
+ date: 2020-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -98,16 +98,16 @@ dependencies:
98
98
  name: selenium-webdriver
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '2.42'
103
+ version: '3.142'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '2.42'
110
+ version: '3.142'
111
111
  description: Executable functional specification for web applications in RSpec syntax
112
112
  with Watir or Selenium WebDriver
113
113
  email: zhimin@agileway.com.au
@@ -123,7 +123,6 @@ files:
123
123
  - lib/extensions/watir_extensions.rb
124
124
  - lib/extensions/webdriver_extensions.rb
125
125
  - lib/extensions/window_script_extensions.rb
126
- - lib/plugins/testwise_plugin.rb
127
126
  - lib/rwebspec-common/assert.rb
128
127
  - lib/rwebspec-common/clickJSDialog.rb
129
128
  - lib/rwebspec-common/context.rb
@@ -163,8 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
162
  version: '0'
164
163
  requirements:
165
164
  - none
166
- rubyforge_project: rwebspec
167
- rubygems_version: 2.6.6
165
+ rubygems_version: 3.1.2
168
166
  signing_key:
169
167
  specification_version: 4
170
168
  summary: Web application functional specification in Ruby
@@ -1,150 +0,0 @@
1
- require 'socket'
2
-
3
- MAX_MESSAGE_LENGTH = 8192 # < 10K
4
-
5
- $testwise_support = true
6
-
7
- module RWebSpec
8
- module TestWisePlugin
9
-
10
- def debugging?
11
- if ENV["TESTWISE_DEBUGGING"].to_s == "true" && ENV["TESTWISE_RUNNING_AS"] == "test_case"
12
- return true
13
- end
14
- return $TESTWISE_DEBUGGING && $TESTWISE_RUNNING_AS == "test_case"
15
- end
16
-
17
- def write_to_console(message)
18
- Thread.pass
19
- if (ENV["RUN_IN_TESTWISE"] && ENV["RUN_IN_TESTWISE"].to_s == "true" || $RUN_IN_TESTWISE) && message
20
- the_sent_msg = message.to_s
21
- if the_sent_msg.size > MAX_MESSAGE_LENGTH
22
- the_sent_msg = the_sent_msg[0..MAX_MESSAGE_LENGTH] + "..."
23
- end
24
- connect_to_testwise(" DEBUG", the_sent_msg + "\r\n")
25
- else
26
- puts message
27
- end
28
- end
29
- alias debug write_to_console
30
-
31
-
32
- # Support of TestWise to ajust the intervals between keystroke/mouse operations
33
- def operation_delay
34
- begin
35
- $TESTWISE_OPERATION_DELAY = ENV["TESTWISE_OPERATION_DELAY"] if ENV["TESTWISE_OPERATION_DELAY"] && ENV["TESTWISE_OPERATION_DELAY"].to_i > 0
36
- if $TESTWISE_OPERATION_DELAY && $TESTWISE_OPERATION_DELAY > 0 &&
37
- $TESTWISE_OPERATION_DELAY < 30000 then # max 30 seconds
38
- Thread.pass
39
- sleep($TESTWISE_OPERATION_DELAY / 1000)
40
- end
41
-
42
- while (ENV["TESTWISE_PAUSE"] && ENV["TESTWISE_PAUSE"].to_s == "true") || $TESTWISE_PAUSE
43
- Thread.pass
44
- debug("Paused, waiting ...")
45
- sleep 1
46
- end
47
- rescue => e
48
- puts "Error on delaying: #{e}"
49
- # ignore
50
- end
51
- end
52
-
53
-
54
- def notify_screenshot_location(image_file_path)
55
- connect_to_testwise(" SHOT", image_file_path)
56
- end
57
-
58
- # find out the line (and file) the execution is on, and notify iTest via Socket
59
- def dump_caller_stack
60
- return unless (ENV["TESTWISE_TRACE_EXECUTION"].to_s == "true" || $TESTWISE_TRACE_EXECUTION)
61
- begin
62
- trace_lines = []
63
- trace_file = nil
64
- found_first_spec_reference = false
65
- caller.each_with_index do |position, idx|
66
- next unless position =~ /\A(.*?):(\d+)/
67
- trace_file = $1
68
- if trace_file =~ /(_spec|_test|_rwebspec)\.rb\s*$/ || trace_file =~ /\.feature$/
69
- found_first_spec_reference = true
70
- trace_lines << position
71
- break
72
- end
73
- trace_lines << position
74
- break if trace_file =~ /example\/example_methods\.rb$/ or trace_file =~ /example\/example_group_methods\.rb$/
75
- break if trace_lines.size > 10
76
- # TODO: send multiple trace to be parse with pages.rb
77
- # break if trace_file =~ /example\/example_methods\.rb$/ or trace_file =~ /example\/example_group_methods\.rb$/ or trace_file =~ /driver\.rb$/ or trace_file =~ /timeout\.rb$/ # don't include rspec or ruby trace
78
- end
79
-
80
- # (trace_file.include?("_spec.rb") || trace_file.include?("_rwebspec.rb") || trace_file.include?("_test.rb") || trace_file.include?("_cmd.rb"))
81
- if !trace_lines.empty?
82
- connect_to_testwise(" TRACE", trace_lines.reverse.join("|"))
83
- end
84
-
85
- rescue => e
86
- puts "failed to capture log: #{e}"
87
- end
88
- end
89
-
90
-
91
- def connect_to_testwise(message_type, body)
92
- Thread.pass
93
- testwise_port = $TESTWISE_TRACE_PORT || ENV["TESTWISE_TRACE_PORT"].to_i || 7025
94
- testwise_socket = nil
95
- begin
96
- the_message = message_type + "|" + body
97
- if @last_message == the_message then # ignore the message same as preivous one
98
- return
99
- end
100
- testwise_socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)
101
- testwise_socket.connect(Socket.pack_sockaddr_in(testwise_port, '127.0.0.1'))
102
- testwise_socket.puts(the_message)
103
- @last_message = the_message
104
- rescue => e
105
- puts "Failed to connect to TestWise on port #{testwise_port}, #{e}, #{e.backtrace}"
106
- ensure
107
- if testwise_socket
108
- testwise_socket.close();
109
- end
110
- end
111
- end
112
-
113
- def check_for_pause
114
-
115
- json_data = fetch_debug_server_status
116
-
117
- if json_data["testwise_ready_to_pause"]
118
- # Already executed the the line immedately above,
119
- # give some buffer time for TW to set $TESTWISE_PAUSE flag
120
- sleep 0.5
121
- end
122
-
123
- # If the executed line no change, ignore
124
- while json_data["testwise_pause"] || $TESTWISE_PAUSE
125
- Thread.pass
126
- write_to_console("[rwebspec] Paused, waiting ...")
127
- sleep 1
128
- json_data = fetch_debug_server_status
129
- end
130
-
131
- end
132
-
133
- def fetch_debug_server_status
134
- testwise_debug_server_port = ENV["TESTWISE_DEBUG_PORT"].to_i
135
- if testwise_debug_server_port <= 0 # invalid
136
- testwise_debug_server_port = $TESTWISE_DEBUG_PORT || 7035
137
- end
138
-
139
- if testwise_debug_server_port
140
- # puts "debug server port: #{testwise_debug_server_port}"
141
- server = TCPSocket.open("127.0.0.1", testwise_debug_server_port)
142
- server.puts("debug_status")
143
- msg = server.gets.chomp
144
- server.close
145
- json_data = JSON.parse(msg)
146
- end
147
- end
148
-
149
- end
150
- end