rwebspec 3.1.4 → 4.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.
- data/CHANGELOG +453 -450
- data/MIT-LICENSE +0 -0
- data/README +0 -0
- data/Rakefile +109 -100
- data/lib/extensions/rspec_extensions.rb +0 -0
- data/lib/extensions/watir_extensions.rb +0 -0
- data/lib/extensions/webdriver_extensions.rb +9 -0
- data/lib/extensions/window_script_extensions.rb +0 -0
- data/lib/plugins/testwise_plugin.rb +16 -0
- data/lib/{rwebspec → rwebspec-common}/assert.rb +394 -386
- data/lib/{rwebspec → rwebspec-common}/clickJSDialog.rb +15 -15
- data/lib/{rwebspec → rwebspec-common}/context.rb +24 -24
- data/lib/{rwebspec → rwebspec-common}/database_checker.rb +0 -0
- data/lib/{rwebspec → rwebspec-common}/load_test_helper.rb +0 -0
- data/lib/{rwebspec → rwebspec-common}/matchers/contains_text.rb +0 -0
- data/lib/{rwebspec → rwebspec-common}/popup.rb +0 -0
- data/lib/{rwebspec → rwebspec-common}/rspec_helper.rb +96 -96
- data/lib/{rwebspec → rwebspec-common}/test_script.rb +0 -0
- data/lib/{rwebspec → rwebspec-common}/test_utils.rb +432 -432
- data/lib/{rwebspec → rwebspec-common}/using_pages.rb +0 -0
- data/lib/{rwebspec → rwebspec-common}/web_page.rb +107 -108
- data/lib/{rwebspec → rwebspec-common}/web_testcase.rb +38 -38
- data/lib/{rwebspec → rwebspec-watir}/driver.rb +759 -772
- data/lib/{rwebspec → rwebspec-watir}/web_browser.rb +611 -611
- data/lib/rwebspec-webdriver/driver.rb +745 -0
- data/lib/rwebspec-webdriver/element_locator.rb +86 -0
- data/lib/rwebspec-webdriver/web_browser.rb +735 -0
- data/lib/rwebspec.rb +99 -59
- metadata +85 -87
@@ -1,15 +1,15 @@
|
|
1
|
-
#
|
2
|
-
# clickJSDialog.rb
|
3
|
-
#
|
4
|
-
#
|
5
|
-
# This file contains the JS clicker when it runs as a separate process
|
6
|
-
require 'watir/winClicker'
|
7
|
-
|
8
|
-
button = "OK"
|
9
|
-
button = ARGV[0] unless ARGV[0] == nil
|
10
|
-
sleepTime = 0
|
11
|
-
sleepTime = ARGV[1] unless ARGV[1] == nil
|
12
|
-
|
13
|
-
clicker= WinClicker.new
|
14
|
-
result = clicker.clickJavaScriptDialog( button )
|
15
|
-
clicker = nil
|
1
|
+
#
|
2
|
+
# clickJSDialog.rb
|
3
|
+
#
|
4
|
+
#
|
5
|
+
# This file contains the JS clicker when it runs as a separate process
|
6
|
+
require 'watir/winClicker'
|
7
|
+
|
8
|
+
button = "OK"
|
9
|
+
button = ARGV[0] unless ARGV[0] == nil
|
10
|
+
sleepTime = 0
|
11
|
+
sleepTime = ARGV[1] unless ARGV[1] == nil
|
12
|
+
|
13
|
+
clicker= WinClicker.new
|
14
|
+
result = clicker.clickJavaScriptDialog( button )
|
15
|
+
clicker = nil
|
@@ -1,24 +1,24 @@
|
|
1
|
-
#***********************************************************
|
2
|
-
#* Copyright (c) 2006 - 2009 Zhimin Zhan.
|
3
|
-
#* Distributed open-source, see full license in MIT-LICENSE
|
4
|
-
#***********************************************************
|
5
|
-
|
6
|
-
module RWebSpec
|
7
|
-
|
8
|
-
##
|
9
|
-
# Store test optionns
|
10
|
-
#
|
11
|
-
class Context
|
12
|
-
attr_accessor :base_url
|
13
|
-
|
14
|
-
def initialize(base_url)
|
15
|
-
set_base_url(base_url)
|
16
|
-
end
|
17
|
-
|
18
|
-
def set_base_url(baseUrl)
|
19
|
-
@base_url = baseUrl
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
1
|
+
#***********************************************************
|
2
|
+
#* Copyright (c) 2006 - 2009 Zhimin Zhan.
|
3
|
+
#* Distributed open-source, see full license in MIT-LICENSE
|
4
|
+
#***********************************************************
|
5
|
+
|
6
|
+
module RWebSpec
|
7
|
+
|
8
|
+
##
|
9
|
+
# Store test optionns
|
10
|
+
#
|
11
|
+
class Context
|
12
|
+
attr_accessor :base_url
|
13
|
+
|
14
|
+
def initialize(base_url)
|
15
|
+
set_base_url(base_url)
|
16
|
+
end
|
17
|
+
|
18
|
+
def set_base_url(baseUrl)
|
19
|
+
@base_url = baseUrl
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,96 +1,96 @@
|
|
1
|
-
require 'uri'
|
2
|
-
|
3
|
-
# ZZ patches to RSpec 1.1.2 - 1.1.4
|
4
|
-
# - add to_s method to example_group
|
5
|
-
module Spec
|
6
|
-
module Example
|
7
|
-
class ExampleGroup
|
8
|
-
def to_s
|
9
|
-
@_defined_description
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
# example
|
16
|
-
# should link_by_text(text, options).size > 0
|
17
|
-
|
18
|
-
module RWebSpec
|
19
|
-
module RSpecHelper
|
20
|
-
include RWebSpec::Driver
|
21
|
-
include RWebSpec::Utils
|
22
|
-
include RWebSpec::Assert
|
23
|
-
|
24
|
-
# --
|
25
|
-
# Content
|
26
|
-
# --
|
27
|
-
|
28
|
-
def table_source(table_id)
|
29
|
-
table(:id, table_id).innerHTML
|
30
|
-
# elem = @web_browser.document.getElementById(table_id)
|
31
|
-
# raise "The element '#{table_id}' is not a table or there are multple elements with same id" unless elem.name.uppercase == "TABLE"
|
32
|
-
# elem.innerHTML
|
33
|
-
end
|
34
|
-
alias table_source_by_id table_source
|
35
|
-
|
36
|
-
def element_text(elem_id)
|
37
|
-
@web_browser.element_value(elem_id)
|
38
|
-
end
|
39
|
-
alias element_text_by_id element_text
|
40
|
-
|
41
|
-
#TODO: is it working?
|
42
|
-
def element_source(elem_id)
|
43
|
-
@web_browser.get_html_in_element(elem_id)
|
44
|
-
end
|
45
|
-
|
46
|
-
|
47
|
-
def button_by_id(button_id)
|
48
|
-
button(:id, button_id)
|
49
|
-
end
|
50
|
-
|
51
|
-
def buttons_by_caption(text)
|
52
|
-
button(:text, text)
|
53
|
-
end
|
54
|
-
alias buttons_by_text buttons_by_caption
|
55
|
-
|
56
|
-
def link_by_id(link_id)
|
57
|
-
link(:id, link_id)
|
58
|
-
end
|
59
|
-
|
60
|
-
# default options: exact => true
|
61
|
-
def links_by_text(link_text, options = {})
|
62
|
-
options.merge!({:exact=> true})
|
63
|
-
matching_links = []
|
64
|
-
links.each { |link|
|
65
|
-
matching_links << link if (options[:exact] ? link.text == link_text : link.text.include?(link_text))
|
66
|
-
}
|
67
|
-
return matching_links
|
68
|
-
end
|
69
|
-
alias links_with_text links_by_text
|
70
|
-
|
71
|
-
def save_page(file_name = nil)
|
72
|
-
@web_browser.save_page(file_name)
|
73
|
-
end
|
74
|
-
|
75
|
-
def save_content_to_file(content, file_name = nil)
|
76
|
-
file_name ||= Time.now.strftime("%Y%m%d%H%M%S") + ".html"
|
77
|
-
puts "about to save page: #{File.expand_path(file_name)}"
|
78
|
-
File.open(file_name, "w").puts content
|
79
|
-
end
|
80
|
-
|
81
|
-
# When running
|
82
|
-
def debugging?
|
83
|
-
($TESTWISE_DEBUGGING && $TESTWISE_RUNNING_AS == "test_case")
|
84
|
-
end
|
85
|
-
|
86
|
-
# RSpec Matchers
|
87
|
-
#
|
88
|
-
# Example,
|
89
|
-
# a_number.should be_odd_number
|
90
|
-
def be_odd_number
|
91
|
-
simple_matcher("must be odd number") { |actual| actual && actual.to_id % 2 == 1}
|
92
|
-
end
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
1
|
+
require 'uri'
|
2
|
+
|
3
|
+
# ZZ patches to RSpec 1.1.2 - 1.1.4
|
4
|
+
# - add to_s method to example_group
|
5
|
+
module Spec
|
6
|
+
module Example
|
7
|
+
class ExampleGroup
|
8
|
+
def to_s
|
9
|
+
@_defined_description
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# example
|
16
|
+
# should link_by_text(text, options).size > 0
|
17
|
+
|
18
|
+
module RWebSpec
|
19
|
+
module RSpecHelper
|
20
|
+
include RWebSpec::Driver
|
21
|
+
include RWebSpec::Utils
|
22
|
+
include RWebSpec::Assert
|
23
|
+
|
24
|
+
# --
|
25
|
+
# Content
|
26
|
+
# --
|
27
|
+
|
28
|
+
def table_source(table_id)
|
29
|
+
table(:id, table_id).innerHTML
|
30
|
+
# elem = @web_browser.document.getElementById(table_id)
|
31
|
+
# raise "The element '#{table_id}' is not a table or there are multple elements with same id" unless elem.name.uppercase == "TABLE"
|
32
|
+
# elem.innerHTML
|
33
|
+
end
|
34
|
+
alias table_source_by_id table_source
|
35
|
+
|
36
|
+
def element_text(elem_id)
|
37
|
+
@web_browser.element_value(elem_id)
|
38
|
+
end
|
39
|
+
alias element_text_by_id element_text
|
40
|
+
|
41
|
+
#TODO: is it working?
|
42
|
+
def element_source(elem_id)
|
43
|
+
@web_browser.get_html_in_element(elem_id)
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def button_by_id(button_id)
|
48
|
+
button(:id, button_id)
|
49
|
+
end
|
50
|
+
|
51
|
+
def buttons_by_caption(text)
|
52
|
+
button(:text, text)
|
53
|
+
end
|
54
|
+
alias buttons_by_text buttons_by_caption
|
55
|
+
|
56
|
+
def link_by_id(link_id)
|
57
|
+
link(:id, link_id)
|
58
|
+
end
|
59
|
+
|
60
|
+
# default options: exact => true
|
61
|
+
def links_by_text(link_text, options = {})
|
62
|
+
options.merge!({:exact=> true})
|
63
|
+
matching_links = []
|
64
|
+
links.each { |link|
|
65
|
+
matching_links << link if (options[:exact] ? link.text == link_text : link.text.include?(link_text))
|
66
|
+
}
|
67
|
+
return matching_links
|
68
|
+
end
|
69
|
+
alias links_with_text links_by_text
|
70
|
+
|
71
|
+
def save_page(file_name = nil)
|
72
|
+
@web_browser.save_page(file_name)
|
73
|
+
end
|
74
|
+
|
75
|
+
def save_content_to_file(content, file_name = nil)
|
76
|
+
file_name ||= Time.now.strftime("%Y%m%d%H%M%S") + ".html"
|
77
|
+
puts "about to save page: #{File.expand_path(file_name)}"
|
78
|
+
File.open(file_name, "w").puts content
|
79
|
+
end
|
80
|
+
|
81
|
+
# When running
|
82
|
+
def debugging?
|
83
|
+
($TESTWISE_DEBUGGING && $TESTWISE_RUNNING_AS == "test_case")
|
84
|
+
end
|
85
|
+
|
86
|
+
# RSpec Matchers
|
87
|
+
#
|
88
|
+
# Example,
|
89
|
+
# a_number.should be_odd_number
|
90
|
+
def be_odd_number
|
91
|
+
simple_matcher("must be odd number") { |actual| actual && actual.to_id % 2 == 1}
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
File without changes
|