rwebspec 3.1.4 → 4.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
File without changes
|
@@ -1,108 +1,107 @@
|
|
1
|
-
#***********************************************************
|
2
|
-
#* Copyright (c) 2006, Zhimin Zhan.
|
3
|
-
#* Distributed open-source, see full license in MIT-LICENSE
|
4
|
-
#***********************************************************
|
5
|
-
require File.join(File.dirname(__FILE__), 'assert')
|
6
|
-
require
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
# @web_browser.
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
# login_page
|
20
|
-
#
|
21
|
-
#
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
include RWebSpec::
|
26
|
-
include RWebSpec::
|
27
|
-
|
28
|
-
|
29
|
-
#
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
@
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
delay
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
#
|
99
|
-
#
|
100
|
-
#
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
end
|
1
|
+
#***********************************************************
|
2
|
+
#* Copyright (c) 2006, Zhimin Zhan.
|
3
|
+
#* Distributed open-source, see full license in MIT-LICENSE
|
4
|
+
#***********************************************************
|
5
|
+
require File.join(File.dirname(__FILE__), 'assert')
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
module RWebSpec
|
9
|
+
|
10
|
+
# WebPage (children of AbstractWebPage) encapsulates a real web page.
|
11
|
+
# For example,
|
12
|
+
# beginAt("/home")
|
13
|
+
# @web_browser.clickLinkWithText("/login")
|
14
|
+
# @web_browser.setFormElement("username", "sa")
|
15
|
+
# Can be rewritten to
|
16
|
+
# begin_at("/home")
|
17
|
+
# home_page = HomePage.new
|
18
|
+
# login_page = home_page.clickLoginLink
|
19
|
+
# login_page.enterUserName("sa")
|
20
|
+
#
|
21
|
+
# So you only need change in LoingPage class if UI changes, which happen quite often.
|
22
|
+
class AbstractWebPage
|
23
|
+
|
24
|
+
include RWebSpec::Assert
|
25
|
+
include RWebSpec::Driver
|
26
|
+
include RWebSpec::Utils
|
27
|
+
|
28
|
+
# browser: passed to do assertion within the page
|
29
|
+
# page_text: text used to identify the page, title will be the first candidate
|
30
|
+
attr_accessor :page_specific_text
|
31
|
+
|
32
|
+
def initialize(the_browser, page_specific_text = nil)
|
33
|
+
@web_browser = @browser = @web_tester = the_browser
|
34
|
+
@page_specific_text = page_specific_text
|
35
|
+
begin
|
36
|
+
snapshot if $TESTWISE_DUMP_PAGE || $TESTWISE_DUMP_PAGE
|
37
|
+
delay = $TESTWISE_PAGE_DELAY || $TESTWISE_PAGE_DELAY
|
38
|
+
sleep(delay)
|
39
|
+
rescue => e
|
40
|
+
end
|
41
|
+
assert_on_page
|
42
|
+
end
|
43
|
+
|
44
|
+
# return the browser instance in page objects
|
45
|
+
def browser
|
46
|
+
@web_browser
|
47
|
+
end
|
48
|
+
|
49
|
+
# Assert is on current page
|
50
|
+
# Example
|
51
|
+
# home_page = HomePage.new("Welcome to iTest2")
|
52
|
+
# ....
|
53
|
+
# home_page.assert_on_page # will check the text 'Welcome to iTest2' still present on the page
|
54
|
+
def assert_on_page()
|
55
|
+
assert_text_present(@page_specific_text) if @page_specific_text
|
56
|
+
end
|
57
|
+
|
58
|
+
def assert_not_on_page()
|
59
|
+
assert_text_not_present(@page_specific_text) if @page_specific_text
|
60
|
+
end
|
61
|
+
|
62
|
+
def dump(stream = nil)
|
63
|
+
@web_browser.dump_response(stream)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Page source (html)
|
67
|
+
def source
|
68
|
+
@web_browser.page_source
|
69
|
+
end
|
70
|
+
alias html source
|
71
|
+
|
72
|
+
# return current page title
|
73
|
+
def title
|
74
|
+
@web_browser.page_title
|
75
|
+
end
|
76
|
+
|
77
|
+
# return current page text
|
78
|
+
def text
|
79
|
+
@web_browser.text
|
80
|
+
end
|
81
|
+
|
82
|
+
def url
|
83
|
+
@web_browser.url
|
84
|
+
end
|
85
|
+
|
86
|
+
# TO validate
|
87
|
+
def contains?(ary)
|
88
|
+
return true if ary.nil?
|
89
|
+
the_page_source = source
|
90
|
+
found = false
|
91
|
+
ary.each_line do |str|
|
92
|
+
found ||= the_page_source.include?(str)
|
93
|
+
end
|
94
|
+
return found
|
95
|
+
end
|
96
|
+
|
97
|
+
# Will save current page source to a file
|
98
|
+
# home_page = HomePage.new("Welcome to iTest2")
|
99
|
+
# ...
|
100
|
+
# home_page.snapshot() # => save to 20090830100102_HomePage.html
|
101
|
+
def snapshot(replace_css = false)
|
102
|
+
save_current_page(:filename => Time.now.strftime("%m%d%H%M%S") + "_" + self.class.name.gsub(" ", "") + ".html" )
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
@@ -1,38 +1,38 @@
|
|
1
|
-
#***********************************************************
|
2
|
-
#* Copyright (c) 2006, Zhimin Zhan.
|
3
|
-
#* Distributed open-source, see full license in MIT-LICENSE
|
4
|
-
#***********************************************************
|
5
|
-
|
6
|
-
# Deprecated, use RSpec syntax instead
|
7
|
-
|
8
|
-
require 'test/unit'
|
9
|
-
require File.join(File.dirname(__FILE__), 'assert')
|
10
|
-
require File.join(File.dirname(__FILE__), 'driver')
|
11
|
-
|
12
|
-
module RWebSpec
|
13
|
-
|
14
|
-
class WebTestCase < Test::Unit::TestCase
|
15
|
-
include RWebSpec::Driver
|
16
|
-
include RWebSpec::Assert
|
17
|
-
include RWebSpec::Utils
|
18
|
-
|
19
|
-
attr_reader :web_tester
|
20
|
-
|
21
|
-
def initialize(name=nil)
|
22
|
-
super(name) if name
|
23
|
-
@web_browser = WebBrowser.new
|
24
|
-
end
|
25
|
-
|
26
|
-
def default_test
|
27
|
-
super unless (self.class == WebTestCase)
|
28
|
-
end
|
29
|
-
|
30
|
-
def open_browser(baseUrl, relativeUrl)
|
31
|
-
context.base_url = baseUrl
|
32
|
-
begin_at(relativeUrl)
|
33
|
-
end
|
34
|
-
alias open_ie open_browser
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
1
|
+
#***********************************************************
|
2
|
+
#* Copyright (c) 2006, Zhimin Zhan.
|
3
|
+
#* Distributed open-source, see full license in MIT-LICENSE
|
4
|
+
#***********************************************************
|
5
|
+
|
6
|
+
# Deprecated, use RSpec syntax instead
|
7
|
+
|
8
|
+
require 'test/unit'
|
9
|
+
require File.join(File.dirname(__FILE__), 'assert')
|
10
|
+
require File.join(File.dirname(__FILE__), 'driver')
|
11
|
+
|
12
|
+
module RWebSpec
|
13
|
+
|
14
|
+
class WebTestCase < Test::Unit::TestCase
|
15
|
+
include RWebSpec::Driver
|
16
|
+
include RWebSpec::Assert
|
17
|
+
include RWebSpec::Utils
|
18
|
+
|
19
|
+
attr_reader :web_tester
|
20
|
+
|
21
|
+
def initialize(name=nil)
|
22
|
+
super(name) if name
|
23
|
+
@web_browser = WebBrowser.new
|
24
|
+
end
|
25
|
+
|
26
|
+
def default_test
|
27
|
+
super unless (self.class == WebTestCase)
|
28
|
+
end
|
29
|
+
|
30
|
+
def open_browser(baseUrl, relativeUrl)
|
31
|
+
context.base_url = baseUrl
|
32
|
+
begin_at(relativeUrl)
|
33
|
+
end
|
34
|
+
alias open_ie open_browser
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|