rwebunit 1.0.3 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +68 -4
- data/README +32 -32
- data/Rakefile +38 -26
- data/lib/rspec_extensions.rb +22 -86
- data/lib/rwebunit/assert.rb +241 -130
- data/lib/rwebunit/context.rb +1 -1
- data/lib/rwebunit/driver.rb +436 -271
- data/lib/rwebunit/itest_plugin.rb +23 -2
- data/lib/rwebunit/popup.rb +147 -0
- data/lib/rwebunit/rspec_helper.rb +12 -56
- data/lib/rwebunit/test_script.rb +8 -0
- data/lib/rwebunit/test_utils.rb +96 -23
- data/lib/rwebunit/using_pages.rb +49 -0
- data/lib/rwebunit/web_browser.rb +27 -5
- data/lib/rwebunit/web_page.rb +13 -17
- data/lib/rwebunit.rb +4 -4
- metadata +17 -12
- data/docs/html/index.html +0 -129
- data/test/mock_page.rb +0 -8
- data/test/setup.rb +0 -10
- data/test/test.html +0 -129
- data/test/test_assert.rb +0 -64
- data/test/test_driver.rb +0 -57
- data/test/test_test_utils.rb +0 -76
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rwebunit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zhimin Zhan
|
@@ -9,7 +9,7 @@ autorequire: rwebunit
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-01
|
12
|
+
date: 2009-06-01 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - "="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.1.
|
23
|
+
version: 1.1.12
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: commonwatir
|
@@ -32,6 +32,16 @@ dependencies:
|
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 1.6.2
|
34
34
|
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: test-unit
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.0.2
|
44
|
+
version:
|
35
45
|
description:
|
36
46
|
email: zhimin@agileway.net
|
37
47
|
executables: []
|
@@ -54,23 +64,18 @@ files:
|
|
54
64
|
- lib/rwebunit/itest_plugin.rb
|
55
65
|
- lib/rwebunit/matchers
|
56
66
|
- lib/rwebunit/matchers/contains_text.rb
|
67
|
+
- lib/rwebunit/popup.rb
|
57
68
|
- lib/rwebunit/rspec_helper.rb
|
69
|
+
- lib/rwebunit/test_script.rb
|
58
70
|
- lib/rwebunit/test_utils.rb
|
71
|
+
- lib/rwebunit/using_pages.rb
|
59
72
|
- lib/rwebunit/web_browser.rb
|
60
73
|
- lib/rwebunit/web_page.rb
|
61
74
|
- lib/rwebunit/web_testcase.rb
|
62
75
|
- lib/rwebunit.rb
|
63
76
|
- lib/watir_extensions.rb
|
64
|
-
- test/mock_page.rb
|
65
|
-
- test/setup.rb
|
66
|
-
- test/test.html
|
67
|
-
- test/test_assert.rb
|
68
|
-
- test/test_driver.rb
|
69
|
-
- test/test_test_utils.rb
|
70
|
-
- docs/html
|
71
|
-
- docs/html/index.html
|
72
77
|
has_rdoc: true
|
73
|
-
homepage: http://
|
78
|
+
homepage: http://github.com/zhimin/rwebunit/tree/master
|
74
79
|
post_install_message:
|
75
80
|
rdoc_options: []
|
76
81
|
|
data/docs/html/index.html
DELETED
@@ -1,129 +0,0 @@
|
|
1
|
-
<html>
|
2
|
-
<head>
|
3
|
-
<title>rWebUnit </title>
|
4
|
-
</head>
|
5
|
-
<body>
|
6
|
-
<p></p>
|
7
|
-
|
8
|
-
<table class="bodyTable">
|
9
|
-
<tr class="a">
|
10
|
-
<th>Watir Test</th>
|
11
|
-
<th>rWebUnit Test</th>
|
12
|
-
</tr>
|
13
|
-
<tr class="b">
|
14
|
-
<td valign="top" nowrap="nowrap">
|
15
|
-
<div class="source">
|
16
|
-
<pre>
|
17
|
-
require 'watir'
|
18
|
-
require 'test/unit'
|
19
|
-
|
20
|
-
class WatirSearchExample < Test::Unit::TestCase
|
21
|
-
|
22
|
-
def test_search
|
23
|
-
ie= Watir::IE.new
|
24
|
-
ie.goto("http://www.google.com")
|
25
|
-
ie.text_field( :name, "q"). set("httpunit")
|
26
|
-
ie.button( :name, "btnG"). click
|
27
|
-
ie.link( :text, "HttpUnit Home"). click
|
28
|
-
assert_equal("HttpUnit Home", ie.document.title)
|
29
|
-
assert( ie.contains_text("User' s Manual"))
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
</pre>
|
34
|
-
</div>
|
35
|
-
</td>
|
36
|
-
<td valign="top" nowrap="nowrap">
|
37
|
-
<div class="source">
|
38
|
-
<pre>
|
39
|
-
|
40
|
-
require 'rwebunit'
|
41
|
-
|
42
|
-
class RWebUnitSearchExample < RWebUnit::WebTestCase
|
43
|
-
|
44
|
-
def test_search()
|
45
|
-
getTestContext().base_url="http://www.google.com"
|
46
|
-
beginAt("/")
|
47
|
-
setFormElement("q", "httpunit")
|
48
|
-
clickButtonWithValue("Google Search")
|
49
|
-
clickLinkWithText("HttpUnit Home")
|
50
|
-
assertTitleEquals("HttpUnit Home")
|
51
|
-
assertLinkPresentWithText("User' s Manual")
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
</pre>
|
56
|
-
</div>
|
57
|
-
</td>
|
58
|
-
</tr>
|
59
|
-
</table>
|
60
|
-
<br/>
|
61
|
-
<table class="bodyTable">
|
62
|
-
<tr class="a">
|
63
|
-
<th>jWebUnit TestCase</th>
|
64
|
-
<th>rWebUnit TestCase</th>
|
65
|
-
</tr>
|
66
|
-
<tr class="b">
|
67
|
-
<td valign="top" nowrap="nowrap">
|
68
|
-
<div class="source">
|
69
|
-
<pre>
|
70
|
-
import net.sourceforge.jwebunit.WebTestCase;
|
71
|
-
|
72
|
-
public class JWebUnitSearchExample extends WebTestCase {
|
73
|
-
|
74
|
-
public JWebUnitSearchExample(String name) {
|
75
|
-
super(name);
|
76
|
-
}
|
77
|
-
|
78
|
-
public void setUp() {
|
79
|
-
getTestContext().setBaseUrl("http://www.google.com");
|
80
|
-
}
|
81
|
-
|
82
|
-
public void testSearch() {
|
83
|
-
beginAt("/");
|
84
|
-
setFormElement("q", "httpunit");
|
85
|
-
submit("btnG");
|
86
|
-
clickLinkWithText("HttpUnit");
|
87
|
-
assertTitleEquals("HttpUnit");
|
88
|
-
assertLinkPresentWithText("User's Manual");
|
89
|
-
}
|
90
|
-
}
|
91
|
-
</pre>
|
92
|
-
</div>
|
93
|
-
</td>
|
94
|
-
|
95
|
-
<td valign="top" nowrap="nowrap">
|
96
|
-
|
97
|
-
<div class="source">
|
98
|
-
<pre>
|
99
|
-
require 'rwebunit'
|
100
|
-
|
101
|
-
class RWebUnitSearchExample < RWebUnit::WebTestCase
|
102
|
-
|
103
|
-
def initialize(name)
|
104
|
-
super(name)
|
105
|
-
end
|
106
|
-
|
107
|
-
def setup
|
108
|
-
getTestContext().setBaseUrl("http:// www.google.com")
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_search
|
112
|
-
beginAt("/")
|
113
|
-
setFormElement("q", "httpunit")
|
114
|
-
submit("btnG")
|
115
|
-
clickLinkWithText("HttpUnit Home")
|
116
|
-
assertTitleEquals("HttpUnit Home")
|
117
|
-
assertLinkPresentWithText("User' s Manual")
|
118
|
-
end
|
119
|
-
end
|
120
|
-
</pre>
|
121
|
-
</div>
|
122
|
-
|
123
|
-
</td>
|
124
|
-
</tr>
|
125
|
-
</table>
|
126
|
-
|
127
|
-
|
128
|
-
</body>
|
129
|
-
</html>
|
data/test/mock_page.rb
DELETED
data/test/setup.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'firewatir'
|
2
|
-
|
3
|
-
$loaded = false
|
4
|
-
unless $loaded
|
5
|
-
sample_html = "file://" + File.expand_path(File.dirname(__FILE__) + "/test.html")
|
6
|
-
$firefox = FireWatir::Firefox.new
|
7
|
-
$firefox.goto(sample_html)
|
8
|
-
$web_browser = RWebUnit::WebBrowser.new("test", $firefox, :firefox => true)
|
9
|
-
$loaded = true
|
10
|
-
end
|
data/test/test.html
DELETED
@@ -1,129 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>
|
5
|
-
For Testing Recorder
|
6
|
-
</title>
|
7
|
-
<style type="text/css">
|
8
|
-
body {
|
9
|
-
margin: 5px;
|
10
|
-
padding: 0;
|
11
|
-
font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Helvetica, Arial, sans-serif;
|
12
|
-
font-size: small;
|
13
|
-
background: #f4f4ed;
|
14
|
-
}
|
15
|
-
|
16
|
-
h1, h2, h3, h4, h5, h6 {
|
17
|
-
margin-top: 0;
|
18
|
-
color: black;
|
19
|
-
font-family: Georgia, "Times New Roman", Times, serif;
|
20
|
-
font-weight: normal
|
21
|
-
}
|
22
|
-
|
23
|
-
a:link {
|
24
|
-
color: #005f96
|
25
|
-
}
|
26
|
-
|
27
|
-
a:visited {
|
28
|
-
color: #484848
|
29
|
-
}
|
30
|
-
|
31
|
-
a:hover, a:active {
|
32
|
-
color: #c30
|
33
|
-
}
|
34
|
-
|
35
|
-
td {
|
36
|
-
font-size: small;
|
37
|
-
}
|
38
|
-
</style>
|
39
|
-
</head>
|
40
|
-
<body>
|
41
|
-
<form action="test">
|
42
|
-
<h1>
|
43
|
-
iTest2/Watir Recorder Test Page
|
44
|
-
</h1>
|
45
|
-
<h2>
|
46
|
-
Links
|
47
|
-
</h2>
|
48
|
-
<p>
|
49
|
-
<a href="http://www.itest2.com">iTest2</a> <a id="link_itest2" href="http://www.itest2.com" name="link_itest2">iTest2 with Id</a>
|
50
|
-
</p>
|
51
|
-
<h2>
|
52
|
-
Checkboxes
|
53
|
-
</h2>
|
54
|
-
<p>
|
55
|
-
<input name="checkbox1" type="checkbox"> No Value <input name="checkbox2" type="checkbox" value="true"> With value true <input id="checkbox3" type="checkbox"> Id but no name
|
56
|
-
</p>
|
57
|
-
<h2>
|
58
|
-
Buttons
|
59
|
-
</h2>
|
60
|
-
<p>
|
61
|
-
<input type="button" id="login-btn" value="Login"> <input type="button" value="Login"> <input type="submit" value="Submit without id">
|
62
|
-
</p>
|
63
|
-
<h2>
|
64
|
-
Radio buttons
|
65
|
-
</h2>
|
66
|
-
<p>
|
67
|
-
<input type="radio" checked="true" name="os" value="Apple"> Apple <input type="radio" name="os" value="Linux"> Linux
|
68
|
-
</p>
|
69
|
-
<h2>
|
70
|
-
Text fields
|
71
|
-
</h2>
|
72
|
-
<table>
|
73
|
-
<tr>
|
74
|
-
<td>
|
75
|
-
Text (single line):
|
76
|
-
</td>
|
77
|
-
<td>
|
78
|
-
<input type="text" name="text1" value="text already there"> <i>Right click to verify textfield</i>
|
79
|
-
</td>
|
80
|
-
</tr>
|
81
|
-
<tr>
|
82
|
-
<td>
|
83
|
-
Text (with name, just id):
|
84
|
-
</td>
|
85
|
-
<td>
|
86
|
-
<input type="text" id="text_without_id" value=""> <i>Right click to verify textfield</i>
|
87
|
-
</td>
|
88
|
-
</tr>
|
89
|
-
<tr>
|
90
|
-
<td>
|
91
|
-
Password:
|
92
|
-
</td>
|
93
|
-
<td>
|
94
|
-
<input type="password" name="password1">
|
95
|
-
</td>
|
96
|
-
</tr>
|
97
|
-
<tr>
|
98
|
-
<td valign="top">
|
99
|
-
TextArea:
|
100
|
-
</td>
|
101
|
-
<td>
|
102
|
-
<textarea name="textarea" cols="10" rows="2">
|
103
|
-
</textarea>
|
104
|
-
</td>
|
105
|
-
</tr>
|
106
|
-
</table>
|
107
|
-
<h2>
|
108
|
-
Select (combobox)
|
109
|
-
</h2>
|
110
|
-
<p>
|
111
|
-
By Name: <select name="testing_tool">
|
112
|
-
<option value="iTest2">
|
113
|
-
iTest2 display
|
114
|
-
</option>
|
115
|
-
<option value="Watir">
|
116
|
-
Watir
|
117
|
-
</option>
|
118
|
-
</select> By Id: <select id="methodology">
|
119
|
-
<option value="XP">
|
120
|
-
Agile way
|
121
|
-
</option>
|
122
|
-
<option value="Waterfall">
|
123
|
-
Water way
|
124
|
-
</option>
|
125
|
-
</select>
|
126
|
-
</p>
|
127
|
-
</form>
|
128
|
-
</body>
|
129
|
-
</html>
|
data/test/test_assert.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'firewatir'
|
3
|
-
|
4
|
-
$:.unshift File.join(File.dirname(__FILE__), "..", "lib/rwebunit")
|
5
|
-
$:.unshift File.dirname(__FILE__)
|
6
|
-
|
7
|
-
require "test_utils"
|
8
|
-
require "web_page"
|
9
|
-
require "assert"
|
10
|
-
require "itest_plugin"
|
11
|
-
require "web_browser"
|
12
|
-
require "driver"
|
13
|
-
require "context"
|
14
|
-
require "driver"
|
15
|
-
require "rspec_helper"
|
16
|
-
require 'test/unit'
|
17
|
-
require 'setup'
|
18
|
-
|
19
|
-
class TestDriver < Test::Unit::TestCase
|
20
|
-
include RWebUnit::Utils
|
21
|
-
include RWebUnit::RSpecHelper
|
22
|
-
|
23
|
-
def setup
|
24
|
-
@web_browser = $web_browser
|
25
|
-
end
|
26
|
-
|
27
|
-
def teardown
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_assert_text
|
31
|
-
assert_text_present("iTest2/Watir Recorder Test Page")
|
32
|
-
assert_text_not_present("iTest3/Watir Recorder Test Page")
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_assert_link
|
36
|
-
assert_link_present_with_text("iTest2 with Id")
|
37
|
-
assert_link_not_present_with_text("iTest2 with id")
|
38
|
-
assert_link_not_present_with_text("XX")
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_checkbox
|
42
|
-
assert_checkbox_not_selected("checkbox1")
|
43
|
-
check_checkbox("checkbox1")
|
44
|
-
assert_checkbox_selected("checkbox1")
|
45
|
-
uncheck_checkbox("checkbox1")
|
46
|
-
assert_checkbox_not_selected("checkbox1")
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_radiobutton
|
50
|
-
assert_radio_option_present("os", "Linux")
|
51
|
-
assert_radio_option_present("os","Apple")
|
52
|
-
assert_radio_option_not_present("os","Windows")
|
53
|
-
click_radio_option("os", "Linux")
|
54
|
-
assert_radio_option_selected("os", "Linux")
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_button
|
58
|
-
assert_button_present("login-btn")
|
59
|
-
assert_button_not_present("login-Btn")
|
60
|
-
assert_button_present_with_text("Login")
|
61
|
-
assert_button_not_present_with_text("login")
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
data/test/test_driver.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'firewatir'
|
2
|
-
|
3
|
-
$:.unshift File.join(File.dirname(__FILE__), "..", "lib/rwebunit")
|
4
|
-
$:.unshift File.dirname(__FILE__)
|
5
|
-
|
6
|
-
require "test_utils"
|
7
|
-
require "web_page"
|
8
|
-
require "assert"
|
9
|
-
require "itest_plugin"
|
10
|
-
require "web_browser"
|
11
|
-
require "driver"
|
12
|
-
require "context"
|
13
|
-
require "driver"
|
14
|
-
require "rspec_helper"
|
15
|
-
require 'test/unit'
|
16
|
-
require 'setup'
|
17
|
-
require 'mock_page'
|
18
|
-
|
19
|
-
class TestDriver < Test::Unit::TestCase
|
20
|
-
include RWebUnit::Driver
|
21
|
-
|
22
|
-
def setup
|
23
|
-
@web_browser = $web_browser
|
24
|
-
end
|
25
|
-
|
26
|
-
def teardown
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_fail_safe
|
30
|
-
fail_safe {raise "X"}
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_expect_page
|
34
|
-
new_page = expect_page MockPage
|
35
|
-
assert_equal("dummy", new_page)
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_on
|
39
|
-
page = []
|
40
|
-
on(page) do |i|
|
41
|
-
i << "0"
|
42
|
-
i << "1"
|
43
|
-
end
|
44
|
-
assert_equal(["0", "1"], page)
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_shall_not_allow
|
48
|
-
shall_not_allow {1 / 0}
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_symbol_to_sequence
|
52
|
-
assert_equal 1, symbol_to_sequence(:first)
|
53
|
-
assert_equal 2, symbol_to_sequence(:second)
|
54
|
-
assert_equal 11, symbol_to_sequence(11)
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
data/test/test_test_utils.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), "..", "lib/rwebunit")
|
2
|
-
$:.unshift File.dirname(__FILE__)
|
3
|
-
|
4
|
-
require "test_utils.rb"
|
5
|
-
require 'test/unit'
|
6
|
-
|
7
|
-
class TestWebTestCase < Test::Unit::TestCase
|
8
|
-
include RWebUnit::Utils
|
9
|
-
|
10
|
-
def setup
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_getToday
|
17
|
-
today_str = sprintf("%02d/%02d/%04d", Time.now.day, Time.now.month, Time.now.year)
|
18
|
-
assert_equal(today_str, getToday)
|
19
|
-
assert_equal(today_str, today)
|
20
|
-
assert_equal(sprintf("%04d-%02d-%02d", Time.now.year, Time.now.month, Time.now.day), today("blah"))
|
21
|
-
assert_equal(sprintf("%02d/%02d/%04d", Time.now.month, Time.now.day, Time.now.year), today("%m/%d/%Y"))
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_getDaysBefore
|
25
|
-
yesterday_date = Time.now - 24 * 3600 * 1
|
26
|
-
yesterday_str = sprintf("%02d/%02d/%04d", yesterday_date.day, yesterday_date.month, yesterday_date.year)
|
27
|
-
assert_equal(yesterday_str, days_before(1))
|
28
|
-
assert_equal(yesterday_str, yesterday)
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_future_date
|
32
|
-
tomorrow_date = Time.now + 24 * 3600 * 1
|
33
|
-
tomorrow_str = sprintf("%02d/%02d/%04d", tomorrow_date.day, tomorrow_date.month, tomorrow_date.year)
|
34
|
-
assert_equal(tomorrow_str, days_from_now(1))
|
35
|
-
assert_equal(tomorrow_str, tomorrow)
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_randomBoolean
|
39
|
-
true_count = 0
|
40
|
-
false_count = 0
|
41
|
-
100.times {
|
42
|
-
obj = random_boolean
|
43
|
-
assert(obj.instance_of?(TrueClass) || obj.instance_of?(FalseClass), "can only be true or false")
|
44
|
-
true_count += 1 if obj
|
45
|
-
false_count += 1 if !obj
|
46
|
-
}
|
47
|
-
assert(true_count > 0, "it is not random")
|
48
|
-
assert(false_count > 0, "it is not random")
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_random_number
|
52
|
-
tmp_array = []
|
53
|
-
1000.times {
|
54
|
-
num = random_number(1,10)
|
55
|
-
assert(num.instance_of?(Fixnum), "can only be number")
|
56
|
-
tmp_array << num
|
57
|
-
}
|
58
|
-
uniq_numbers = tmp_array.uniq.sort
|
59
|
-
assert_equal(10, uniq_numbers.length)
|
60
|
-
assert_equal(1, uniq_numbers[0])
|
61
|
-
assert_equal(10, uniq_numbers[9])
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_random_digit
|
65
|
-
tmp_array = []
|
66
|
-
1000.times {
|
67
|
-
dc = random_digit
|
68
|
-
tmp_array << dc
|
69
|
-
}
|
70
|
-
uniq_digits = tmp_array.uniq.sort
|
71
|
-
assert_equal(10, uniq_digits.length)
|
72
|
-
assert_equal('0', uniq_digits[0])
|
73
|
-
assert_equal('9', uniq_digits[9])
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|