rwebspec-mechanize 0.4 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +5 -1
- data/Rakefile +1 -1
- data/lib/rwebspec-mechanize/load_test_helper.rb +15 -1
- data/lib/rwebspec-mechanize/plugins/loadwise_plugin.rb +2 -0
- data/lib/rwebspec-mechanize/web_browser.rb +93 -54
- metadata +13 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2e82059519bfe2f589c8ca94821d7256cea41936
|
4
|
+
data.tar.gz: 8e005576ecbb203cf57440542857325c64c48001
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e12b204178627d3485f83e7adc04847121fc51574ba5477ced9c04270e9f08a0145810bcc5cf4a0c4dc01796018c6ffb6af70b4d73346498592f0ad693ce12f5
|
7
|
+
data.tar.gz: 994137c0db4c03b8cf650c1110143a02c63c591663ac7f56078b5abe4082bf7d03ba015901cb89ad68d6786497e33e9802415480f832b4c0e3b374988a065df3
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
0.4.1
|
2
|
+
- Support RWebSpec 5.0.2
|
3
|
+
- Support RSpec 2.14
|
4
|
+
|
1
5
|
0.3
|
2
6
|
- Support RSpec 2.13
|
3
7
|
|
@@ -14,7 +18,7 @@
|
|
14
18
|
- send different socket
|
15
19
|
|
16
20
|
0.1.3
|
17
|
-
- remove
|
21
|
+
- remove dependency on Santize, using Nokogiri for get html text view
|
18
22
|
|
19
23
|
0.1.2
|
20
24
|
- click_button_with_id default to submit the form if the button not found
|
data/Rakefile
CHANGED
@@ -74,7 +74,7 @@ end
|
|
74
74
|
spec = Gem::Specification.new do |s|
|
75
75
|
s.platform= Gem::Platform::RUBY
|
76
76
|
s.name = "rwebspec-mechanize"
|
77
|
-
s.version = "0.4"
|
77
|
+
s.version = "0.4.1"
|
78
78
|
s.summary = "Web application load testing specification in Ruby"
|
79
79
|
s.description = "Load test specification for web applications in RSpec syntax and Watir"
|
80
80
|
|
@@ -33,7 +33,9 @@ module RWebSpec
|
|
33
33
|
puts "loading RWEBSPEC..."
|
34
34
|
require 'rwebspec'
|
35
35
|
RWebSpec.framework = "Watir"
|
36
|
-
RWebSpec::WebBrowser.new(base_url, nil, options)
|
36
|
+
new_browser = RWebSpec::WebBrowser.new(base_url, nil, options)
|
37
|
+
# new_browser.goto_url(base_url)
|
38
|
+
return new_browser
|
37
39
|
else
|
38
40
|
require 'rwebspec'
|
39
41
|
RWebSpec.framework = "Selenium-WebDriver"
|
@@ -250,6 +252,15 @@ module RWebSpec
|
|
250
252
|
start_virtual_user_count = peak_virtual_user_count = 1
|
251
253
|
end
|
252
254
|
|
255
|
+
# HACK
|
256
|
+
#
|
257
|
+
#start_virtual_user_count = 10
|
258
|
+
#peak_virtual_user_count = 200
|
259
|
+
#delay_between_thread_start = 1
|
260
|
+
#virtual_user_count_per_rampup = 5
|
261
|
+
#for_how_long = 5 * 60
|
262
|
+
|
263
|
+
puts "[DEBUG] start_vu: #{start_virtual_user_count}, [peak] => #{peak_virtual_user_count}, for #{for_how_long}"
|
253
264
|
connect_to_loadwise("VU_START", "")
|
254
265
|
all_start_time = Time.now
|
255
266
|
|
@@ -281,6 +292,7 @@ module RWebSpec
|
|
281
292
|
# Looping finished
|
282
293
|
vu_reports[idx] = Thread.current[:log]
|
283
294
|
rescue => e
|
295
|
+
puts "[DELETE DEBUG] Error occured: #{e}"
|
284
296
|
vu_reports[idx] = Thread.current[:log] || []
|
285
297
|
vu_reports[idx] ||= []
|
286
298
|
vu_reports[idx] << { :error => e }
|
@@ -297,6 +309,8 @@ module RWebSpec
|
|
297
309
|
connect_to_loadwise("VU_END", Thread.current[:id].to_s)
|
298
310
|
# puts "VU[#{idx+1}] #{Time.now - start_time}s"
|
299
311
|
end
|
312
|
+
|
313
|
+
|
300
314
|
end
|
301
315
|
|
302
316
|
(start_virtual_user_count..peak_virtual_user_count).step(virtual_user_count_per_rampup) do |nidx|
|
@@ -17,12 +17,14 @@ module RWebSpec
|
|
17
17
|
|
18
18
|
attr_accessor :context
|
19
19
|
|
20
|
+
attr_accessor :current_form
|
21
|
+
|
20
22
|
def initialize(base_url = nil, existing_browser = nil, options = {})
|
21
23
|
default_options = {:go => false}
|
22
24
|
options = default_options.merge options
|
23
25
|
@context = Context.new base_url if base_url
|
24
26
|
@browser = ::Mechanize.new
|
25
|
-
|
27
|
+
puts "[DELETE DEBUG] => new Mechanize Brwoser with base_url => #{base_url}"
|
26
28
|
require 'logger'
|
27
29
|
# http://mechanize.rubyforge.org/Mechanize.html
|
28
30
|
# TODO option to turn off mechanize logging
|
@@ -292,12 +294,15 @@ module RWebSpec
|
|
292
294
|
|
293
295
|
# text fields
|
294
296
|
def enter_text_into_field_with_name(name, value)
|
295
|
-
the_form = identify_form
|
296
297
|
wait_before_and_after {
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
298
|
+
|
299
|
+
page.forms.each do |the_form|
|
300
|
+
the_form.fields_with(:name => name).each do |x|
|
301
|
+
next unless x.type == "text" || x.type == "password" || x.type == "hidden" || x.type == "textarea"
|
302
|
+
x.value = value
|
303
|
+
break
|
304
|
+
end
|
305
|
+
end
|
301
306
|
}
|
302
307
|
end
|
303
308
|
|
@@ -345,32 +350,37 @@ module RWebSpec
|
|
345
350
|
#
|
346
351
|
# Occasionaly, the button with ID exists, but now shown in the form (debug form.inspect), add efault to submit
|
347
352
|
#
|
353
|
+
# TODO button not in
|
348
354
|
def click_button_with_id(id, opts = {})
|
349
|
-
the_form = identify_form
|
350
355
|
the_button = nil
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
356
|
+
page.forms.each_with_index do |the_form, idx|
|
357
|
+
puts "[DEBUG] Click button with id => #{id}, #{the_form.buttons.inspect}, #{idx}"
|
358
|
+
# puts "[DEBUG] click button with id => #{id} | #{opts.inspect} | #{the_form.inspect}"
|
359
|
+
if opts && opts[:index]
|
360
|
+
wait_before_and_after {
|
361
|
+
the_button = the_form.buttons_with(:id => id)[opts[:index]]
|
362
|
+
}
|
363
|
+
else
|
364
|
+
wait_before_and_after {
|
365
|
+
the_button = the_form.button_with(:id => id)
|
366
|
+
}
|
367
|
+
end
|
361
368
|
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
369
|
+
if the_button.nil?
|
370
|
+
puts "[DEBUT button with id '#{id}' not found] #{idx}"
|
371
|
+
next
|
372
|
+
end
|
366
373
|
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
374
|
+
# raise "No button with id: #{id} found " unless the_button
|
375
|
+
# puts "[DEBUG] Submit the form #{the_form.inspect}"
|
376
|
+
if the_button.type == "submit"
|
377
|
+
@browser.submit(the_form, the_button)
|
378
|
+
else
|
379
|
+
@browser.submit(the_form, the_button)
|
380
|
+
end
|
381
|
+
end
|
373
382
|
|
383
|
+
@browser.click()
|
374
384
|
end
|
375
385
|
|
376
386
|
# Click a button with give name
|
@@ -399,34 +409,59 @@ module RWebSpec
|
|
399
409
|
|
400
410
|
end
|
401
411
|
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
412
|
+
#
|
413
|
+
# search_form = page.form_with :name => "f"
|
414
|
+
# page.form_with :id => new_client
|
415
|
+
def identify_form(opts = nil)
|
416
|
+
puts "[DEBUG] forms_size => #{page.forms.size}"
|
417
|
+
if opts
|
418
|
+
@current_form = page.form_with(opts)
|
419
|
+
@current_form = page.forms.last
|
420
|
+
puts "[DEBUG] select form #{opts} => #{@current_form}"
|
421
|
+
elsif @current_form.nil?
|
422
|
+
@current_form = page.forms.first
|
423
|
+
if @current_form.nil?
|
424
|
+
sleep 0.1
|
425
|
+
@current_form = page.forms.first
|
426
|
+
end
|
427
|
+
end
|
428
|
+
return @current_form
|
409
429
|
end
|
430
|
+
alias choose_form identify_form
|
410
431
|
|
411
432
|
# Click a button with caption
|
412
433
|
# Usage:
|
413
434
|
# click_button_with_caption("Confirm payment")
|
414
435
|
def click_button_with_caption(caption, opts={})
|
415
|
-
|
436
|
+
the_button = nil
|
437
|
+
found_in_form = nil
|
438
|
+
puts "[DEBUG clieck button] #{caption}"
|
439
|
+
page.forms.each do |the_form|
|
440
|
+
found_in_form = the_form
|
416
441
|
if opts && opts[:index]
|
417
|
-
wait_before_and_after {
|
418
|
-
the_form.button_with(:value => caption)[opts[:index]]
|
419
|
-
|
442
|
+
# wait_before_and_after {
|
443
|
+
the_button = the_form.button_with(:value => caption)[opts[:index]] rescue nil
|
444
|
+
break if the_button
|
445
|
+
# }
|
420
446
|
else
|
421
|
-
wait_before_and_after {
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
447
|
+
# wait_before_and_after {
|
448
|
+
# puts "Find button in form : #{the_form.inspect}"
|
449
|
+
the_button = the_form.button(:value => caption)
|
450
|
+
# puts "Find button => #{the_button.inspect}"
|
451
|
+
break if the_button
|
452
|
+
# }
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
found_in_form.submit
|
457
|
+
raise "No button found" if the_button.nil?
|
458
|
+
puts "the_button.type => #{the_button.inspect}"
|
459
|
+
if the_button.type == "submit"
|
460
|
+
@browser.submit(found_in_form, found_in_form.button(:value => caption))
|
461
|
+
else
|
462
|
+
found_in_form.button_with(:value => caption).click
|
463
|
+
end
|
464
|
+
|
430
465
|
end
|
431
466
|
alias click_button click_button_with_caption
|
432
467
|
alias click_button_with_text click_button_with_caption
|
@@ -503,9 +538,13 @@ module RWebSpec
|
|
503
538
|
# Usage:
|
504
539
|
# click_radio_option("country", "Australia")
|
505
540
|
def click_radio_option(radio_group, radio_option)
|
506
|
-
|
507
|
-
|
508
|
-
|
541
|
+
page.forms.each do |a_form|
|
542
|
+
matching_element = a_form.radiobutton_with(:name => radio_group, :value => radio_option)
|
543
|
+
if matching_element
|
544
|
+
matching_element.check
|
545
|
+
break
|
546
|
+
end
|
547
|
+
end
|
509
548
|
end
|
510
549
|
alias click_radio_button click_radio_option
|
511
550
|
|
@@ -563,11 +602,11 @@ module RWebSpec
|
|
563
602
|
ff = FireWatir::Firefox.attach(how, what)
|
564
603
|
return WebBrowser.new_from_existing(ff, site_context)
|
565
604
|
else
|
566
|
-
return WebBrowser.new_from_existing(Watir::
|
605
|
+
return WebBrowser.new_from_existing(Watir::Browser.attach(how, what), site_context)
|
567
606
|
end
|
568
607
|
end
|
569
608
|
|
570
|
-
# Attach a Watir::
|
609
|
+
# Attach a Watir::Browser instance to a popup window.
|
571
610
|
#
|
572
611
|
# Typical usage
|
573
612
|
# new_popup_window(:url => "http://www.google.com/a.pdf")
|
@@ -576,9 +615,9 @@ module RWebSpec
|
|
576
615
|
raise "not implemented"
|
577
616
|
else
|
578
617
|
if options[:url]
|
579
|
-
Watir::
|
618
|
+
Watir::Browser.attach(:url, options[:url])
|
580
619
|
elsif options[:title]
|
581
|
-
Watir::
|
620
|
+
Watir::Browser.attach(:title, options[:title])
|
582
621
|
else
|
583
622
|
raise 'Please specify title or url of new pop up window'
|
584
623
|
end
|
metadata
CHANGED
@@ -1,62 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rwebspec-mechanize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Zhimin Zhan
|
9
8
|
autorequire: rwebspec-mechanize
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-12-05 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 2.14.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 2.14.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: mechanize
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '2.7'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '2.7'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: nokogiri
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
description: Load test specification for web applications in RSpec syntax and Watir
|
@@ -83,27 +76,26 @@ files:
|
|
83
76
|
- lib/rwebspec-mechanize.rb
|
84
77
|
homepage: http://github.com/zhimin/rwebspec-mechanize/tree/master
|
85
78
|
licenses: []
|
79
|
+
metadata: {}
|
86
80
|
post_install_message:
|
87
81
|
rdoc_options: []
|
88
82
|
require_paths:
|
89
83
|
- lib
|
90
84
|
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
85
|
requirements:
|
93
|
-
- -
|
86
|
+
- - '>='
|
94
87
|
- !ruby/object:Gem::Version
|
95
88
|
version: '0'
|
96
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
90
|
requirements:
|
99
|
-
- -
|
91
|
+
- - '>='
|
100
92
|
- !ruby/object:Gem::Version
|
101
93
|
version: '0'
|
102
94
|
requirements:
|
103
95
|
- none
|
104
96
|
rubyforge_project: rwebspec-mechanize
|
105
|
-
rubygems_version: 1.
|
97
|
+
rubygems_version: 2.1.11
|
106
98
|
signing_key:
|
107
|
-
specification_version:
|
99
|
+
specification_version: 4
|
108
100
|
summary: Web application load testing specification in Ruby
|
109
101
|
test_files: []
|