selenium-client 1.1 → 1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/nautilus/shell.rb +32 -0
- data/lib/selenium.rb +8 -0
- data/lib/selenium/client/base.rb +26 -5
- data/lib/selenium/client/driver.rb +1 -0
- data/lib/selenium/client/idiomatic.rb +179 -0
- data/lib/selenium/client/selenese_client.rb +5 -5
- data/lib/selenium/client/selenium_helper.rb +5 -5
- data/lib/selenium/rake/remote_control_start_task.rb +43 -0
- data/lib/selenium/rake/remote_control_stop_task.rb +28 -0
- data/lib/selenium/rake/tasks.rb +6 -0
- data/lib/selenium/remote_control/remote_control.rb +30 -0
- data/lib/selenium/rspec/reporting/file_path_strategy.rb +70 -0
- data/lib/selenium/rspec/reporting/html_report.rb +123 -0
- data/lib/selenium/rspec/reporting/selenium_test_report_formatter.rb +88 -0
- data/lib/selenium/rspec/reporting/system_capture.rb +72 -0
- data/lib/selenium/rspec/rspec_extensions.rb +43 -0
- data/lib/selenium/rspec/spec_helper.rb +22 -0
- data/lib/tcp_socket_extension.rb +23 -0
- metadata +16 -6
- data/lib/selenium/client/generated_driver.rb +0 -1621
- data/lib/selenium/rspec/screenshot_formatter.rb +0 -187
- data/lib/selenium/screenshot_saver.rb +0 -25
@@ -1,187 +0,0 @@
|
|
1
|
-
require "digest/md5"
|
2
|
-
require "base64"
|
3
|
-
require "rubygems"
|
4
|
-
require "spec"
|
5
|
-
require 'spec/runner/formatter/html_formatter'
|
6
|
-
|
7
|
-
module Selenium
|
8
|
-
module RSpec
|
9
|
-
class ScreenshotFormatter < Spec::Runner::Formatter::HtmlFormatter
|
10
|
-
PLACEHOLDER = "<<placeholder>>"
|
11
|
-
|
12
|
-
################### Hooks? ########
|
13
|
-
|
14
|
-
def start(example_count)
|
15
|
-
super
|
16
|
-
# ensure there's at least 1 example group header (normally 0 with deep_test)
|
17
|
-
# prevents js and html validity errors
|
18
|
-
example_group = Object.new
|
19
|
-
def example_group.description; ""; end
|
20
|
-
add_example_group(example_group)
|
21
|
-
end
|
22
|
-
|
23
|
-
def move_progress
|
24
|
-
# we don't have current_example_number, and we don't really care about the progress bar
|
25
|
-
end
|
26
|
-
|
27
|
-
def extra_failure_content(failure)
|
28
|
-
super + PLACEHOLDER
|
29
|
-
end
|
30
|
-
|
31
|
-
def example_passed(example)
|
32
|
-
include_example_group_description example
|
33
|
-
super
|
34
|
-
end
|
35
|
-
|
36
|
-
def example_pending(example_group_description, example, message)
|
37
|
-
include_example_group_description example
|
38
|
-
super
|
39
|
-
end
|
40
|
-
|
41
|
-
def example_failed(example, counter, failure)
|
42
|
-
include_example_group_description example
|
43
|
-
old_output = @output
|
44
|
-
@output = StringIO.new
|
45
|
-
super
|
46
|
-
result = @output.string
|
47
|
-
result.gsub! PLACEHOLDER, html_capture(example)
|
48
|
-
old_output.puts result
|
49
|
-
old_output.flush
|
50
|
-
ensure
|
51
|
-
@output = old_output
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
###### Called from After each ####
|
56
|
-
|
57
|
-
def self.capture_browser_state(selenium_driver, example)
|
58
|
-
# Selenium RC seems to 'freeze' every so often when calling getHTMLSource, especially when DeepTest timeout is low, I need to investigate...
|
59
|
-
# Set deeptest :timeout_in_seconds => 30 to see it happen
|
60
|
-
capture_html_snapshot selenium_driver, example
|
61
|
-
capture_screenshot selenium_driver, example
|
62
|
-
end
|
63
|
-
|
64
|
-
def self.capture_html_snapshot(selenium_driver, example)
|
65
|
-
html = selenium_driver.get_html_source
|
66
|
-
File.open(file_for_html_capture(example), "w") { |f| f.write html }
|
67
|
-
end
|
68
|
-
|
69
|
-
def self.capture_screenshot(selenium_driver, example)
|
70
|
-
selenium_driver.window_maximize
|
71
|
-
encodedImage = selenium_driver.capture_screenshot_to_string
|
72
|
-
pngImage = Base64.decode64(encodedImage)
|
73
|
-
File.open(file_for_screenshot_capture(example), "w") { |f| f.write pngImage }
|
74
|
-
end
|
75
|
-
|
76
|
-
################### Instrumentation ########
|
77
|
-
|
78
|
-
def html_capture(example)
|
79
|
-
dom_id = "example_" + self.class.hash_for_example(example)
|
80
|
-
screenshot_url = self.class.relative_file_for_png_capture(example)
|
81
|
-
snapshot_url = self.class.relative_file_for_html_capture(example)
|
82
|
-
<<-EOS
|
83
|
-
<div>[<a id="#{dom_id}_screenshot_link" href="javascript:toggleVisilibility('#{dom_id}_screenshot', 'Screenshot');">Show screenshot</a>]</div>
|
84
|
-
<br/>
|
85
|
-
<div id="#{dom_id}_screenshot" style="display: none">
|
86
|
-
<a href="#{screenshot_url}">
|
87
|
-
<img width="80%" src="#{screenshot_url}" />
|
88
|
-
</a>
|
89
|
-
</div>
|
90
|
-
<br/>
|
91
|
-
|
92
|
-
<div>[<a id="#{dom_id}_snapshot_link" href=\"javascript:toggleVisilibility('#{dom_id}_snapshot', 'Snapshot')\">Show snapshot</a>]</div>
|
93
|
-
<br/><br/>
|
94
|
-
<div id="#{dom_id}_snapshot" class="dyn-source">
|
95
|
-
<a href="#{snapshot_url}">Full screen</a><br/><br/>
|
96
|
-
<iframe src="#{snapshot_url}" width="100%" height="600px" ></iframe>
|
97
|
-
</div>
|
98
|
-
EOS
|
99
|
-
end
|
100
|
-
|
101
|
-
|
102
|
-
def self.relative_file_for_html_capture(example)
|
103
|
-
"resources/example_#{hash_for_example(example)}.html"
|
104
|
-
end
|
105
|
-
|
106
|
-
def self.relative_file_for_png_capture(example)
|
107
|
-
"resources/example_#{hash_for_example(example)}.png"
|
108
|
-
end
|
109
|
-
|
110
|
-
def self.file_for_html_capture(example)
|
111
|
-
file_name = capture_root_dir + "/example_#{hash_for_example(example)}.html"
|
112
|
-
FileUtils.mkdir_p(capture_root_dir) unless File.directory?(capture_root_dir)
|
113
|
-
file_name
|
114
|
-
end
|
115
|
-
|
116
|
-
def self.file_for_screenshot_capture(example)
|
117
|
-
file_name = capture_root_dir + "/example_#{hash_for_example(example)}.png"
|
118
|
-
FileUtils.mkdir_p(capture_root_dir) unless File.directory?(capture_root_dir)
|
119
|
-
file_name
|
120
|
-
end
|
121
|
-
|
122
|
-
def self.hash_for_example(example)
|
123
|
-
Digest::MD5.hexdigest example.implementation_backtrace.first
|
124
|
-
end
|
125
|
-
|
126
|
-
|
127
|
-
def self.capture_root_dir
|
128
|
-
root_dir + "/resources"
|
129
|
-
end
|
130
|
-
|
131
|
-
def self.root_dir
|
132
|
-
(ENV['CC_BUILD_ARTIFACTS'] || './tmp/rspec_report')
|
133
|
-
end
|
134
|
-
|
135
|
-
|
136
|
-
def include_example_group_description(example)
|
137
|
-
def example.description
|
138
|
-
self.class.description.to_s + " :: " + super
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
|
143
|
-
def report_header
|
144
|
-
super + "\n<script type=\"text/javascript\">moveProgressBar('100.0');</script>"
|
145
|
-
end
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
def global_scripts
|
150
|
-
super + <<-EOF
|
151
|
-
function toggleVisilibility(id, description) {
|
152
|
-
var section;
|
153
|
-
var link;
|
154
|
-
|
155
|
-
section = document.getElementById(id);
|
156
|
-
link = document.getElementById(id + "_link");
|
157
|
-
|
158
|
-
if (section.style.display == "block") {
|
159
|
-
section.style.display = "none"
|
160
|
-
link.innerHTML = description
|
161
|
-
} else {
|
162
|
-
section.style.display = "block"
|
163
|
-
link.innerHTML = "Hide " + description
|
164
|
-
}
|
165
|
-
}
|
166
|
-
EOF
|
167
|
-
end
|
168
|
-
|
169
|
-
def global_styles
|
170
|
-
super + <<-EOF
|
171
|
-
div.rspec-report textarea {
|
172
|
-
width: 100%;
|
173
|
-
}
|
174
|
-
|
175
|
-
div.rspec-report .dyn-source {
|
176
|
-
background: #FFFFEE none repeat scroll 0%;
|
177
|
-
border:1px dotted black;
|
178
|
-
color: #000000;
|
179
|
-
display: none;
|
180
|
-
margin: 0.5em 2em;
|
181
|
-
padding: 0.5em;
|
182
|
-
}
|
183
|
-
EOF
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module Selenium
|
2
|
-
module ScreenshotSaver
|
3
|
-
|
4
|
-
def save_screenshot_to(png_path)
|
5
|
-
dir = File.dirname(png_path)
|
6
|
-
FileUtils.mkdir_p(dir) unless File.directory?(dir)
|
7
|
-
if PLATFORM['darwin']
|
8
|
-
sh "screencapture '#{png_path}'"
|
9
|
-
elsif image_magick_support?
|
10
|
-
sh "import -window root '#{png_path}'"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def image_magick_support?
|
15
|
-
@image_magick_support ||= `import --version`.grep /"ImageMagick"/
|
16
|
-
end
|
17
|
-
|
18
|
-
def sh(command)
|
19
|
-
system command
|
20
|
-
STDERR.puts "Warning: Could not capture screenshot with '#{command}'" unless $? == 0
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|