mechanize 0.6.11 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of mechanize might be problematic. Click here for more details.
- data/CHANGELOG.txt +8 -0
- data/Manifest.txt +31 -22
- data/lib/mechanize.rb +2 -652
- data/lib/www/mechanize.rb +635 -0
- data/lib/www/mechanize/content_type_error.rb +16 -0
- data/lib/www/mechanize/cookie.rb +64 -0
- data/lib/{mechanize/cookie.rb → www/mechanize/cookie_jar.rb} +0 -60
- data/lib/www/mechanize/file.rb +73 -0
- data/lib/www/mechanize/file_saver.rb +39 -0
- data/lib/{mechanize → www/mechanize}/form.rb +119 -137
- data/lib/www/mechanize/form/button.rb +8 -0
- data/lib/www/mechanize/form/check_box.rb +13 -0
- data/lib/www/mechanize/form/field.rb +28 -0
- data/lib/www/mechanize/form/file_upload.rb +24 -0
- data/lib/www/mechanize/form/image_button.rb +23 -0
- data/lib/www/mechanize/form/multi_select_list.rb +69 -0
- data/lib/www/mechanize/form/option.rb +51 -0
- data/lib/www/mechanize/form/radio_button.rb +38 -0
- data/lib/www/mechanize/form/select_list.rb +41 -0
- data/lib/www/mechanize/headers.rb +12 -0
- data/lib/{mechanize → www/mechanize}/history.rb +0 -0
- data/lib/{mechanize → www/mechanize}/inspect.rb +21 -28
- data/lib/{mechanize → www/mechanize}/list.rb +0 -0
- data/lib/{mechanize → www/mechanize}/monkey_patch.rb +19 -0
- data/lib/www/mechanize/page.rb +121 -0
- data/lib/www/mechanize/page/base.rb +10 -0
- data/lib/www/mechanize/page/frame.rb +22 -0
- data/lib/www/mechanize/page/link.rb +50 -0
- data/lib/www/mechanize/page/meta.rb +10 -0
- data/lib/www/mechanize/pluggable_parsers.rb +93 -0
- data/lib/{mechanize/errors.rb → www/mechanize/response_code_error.rb} +1 -13
- data/test/{test_includes.rb → helper.rb} +4 -18
- data/test/{test_servlets.rb → servlets.rb} +0 -0
- data/test/tc_authenticate.rb +1 -8
- data/test/tc_bad_links.rb +3 -10
- data/test/tc_blank_form.rb +1 -8
- data/test/tc_checkboxes.rb +1 -8
- data/test/tc_cookie_class.rb +1 -6
- data/test/tc_cookie_jar.rb +1 -7
- data/test/tc_cookies.rb +10 -17
- data/test/tc_encoded_links.rb +5 -12
- data/test/tc_errors.rb +4 -11
- data/test/tc_follow_meta.rb +1 -8
- data/test/tc_form_action.rb +6 -14
- data/test/tc_form_as_hash.rb +1 -9
- data/test/tc_form_button.rb +5 -8
- data/test/tc_form_no_inputname.rb +1 -8
- data/test/tc_forms.rb +16 -24
- data/test/tc_frames.rb +3 -10
- data/test/tc_gzipping.rb +2 -9
- data/test/tc_history.rb +5 -12
- data/test/tc_html_unscape_forms.rb +8 -15
- data/test/tc_if_modified_since.rb +1 -6
- data/test/tc_keep_alive.rb +1 -8
- data/test/tc_links.rb +12 -19
- data/test/tc_mech.rb +26 -34
- data/test/{test_mechanize_file.rb → tc_mechanize_file.rb} +1 -6
- data/test/tc_multi_select.rb +10 -17
- data/test/tc_no_attributes.rb +1 -8
- data/test/tc_page.rb +3 -10
- data/test/tc_pluggable_parser.rb +8 -15
- data/test/tc_post_form.rb +3 -10
- data/test/tc_pretty_print.rb +3 -10
- data/test/tc_radiobutton.rb +2 -9
- data/test/tc_referer.rb +13 -20
- data/test/tc_relative_links.rb +1 -8
- data/test/tc_response_code.rb +14 -21
- data/test/tc_save_file.rb +1 -9
- data/test/tc_select.rb +3 -10
- data/test/tc_select_all.rb +2 -10
- data/test/tc_select_none.rb +2 -10
- data/test/tc_select_noopts.rb +2 -9
- data/test/tc_set_fields.rb +2 -9
- data/test/tc_ssl_server.rb +5 -12
- data/test/tc_subclass.rb +2 -9
- data/test/tc_textarea.rb +2 -9
- data/test/tc_upload.rb +2 -9
- data/test/test_all.rb +4 -43
- metadata +96 -80
- data/lib/mechanize/form_elements.rb +0 -254
- data/lib/mechanize/net-overrides/net/http.rb +0 -2107
- data/lib/mechanize/net-overrides/net/https.rb +0 -172
- data/lib/mechanize/net-overrides/net/protocol.rb +0 -380
- data/lib/mechanize/page.rb +0 -138
- data/lib/mechanize/page_elements.rb +0 -77
- data/lib/mechanize/parsers/rexml_page.rb +0 -35
- data/lib/mechanize/pluggable_parsers.rb +0 -204
- data/lib/mechanize/rexml.rb +0 -236
- data/setup.rb +0 -1585
- data/test/tc_proxy.rb +0 -25
- data/test/tc_watches.rb +0 -32
data/test/tc_cookie_class.rb
CHANGED
data/test/tc_cookie_jar.rb
CHANGED
@@ -1,10 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'mechanize/cookie'
|
5
|
-
require 'uri'
|
6
|
-
require 'test_includes'
|
7
|
-
require 'fileutils'
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
8
2
|
|
9
3
|
class CookieJarTest < Test::Unit::TestCase
|
10
4
|
def cookie_from_hash(hash)
|
data/test/tc_cookies.rb
CHANGED
@@ -1,27 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rubygems'
|
5
|
-
require 'mechanize'
|
6
|
-
require 'test_includes'
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
7
2
|
|
8
3
|
class CookiesMechTest < Test::Unit::TestCase
|
9
|
-
include TestMethods
|
10
|
-
|
11
4
|
def setup
|
12
5
|
@agent = WWW::Mechanize.new
|
13
6
|
end
|
14
7
|
|
15
8
|
def test_send_cookies
|
16
|
-
page = @agent.get("http://localhost
|
17
|
-
page = @agent.get("http://localhost
|
9
|
+
page = @agent.get("http://localhost/many_cookies")
|
10
|
+
page = @agent.get("http://localhost/send_cookies")
|
18
11
|
assert_equal(3, page.links.length)
|
19
12
|
assert_not_nil(page.links.find { |l| l.text == "name:Aaron" })
|
20
13
|
assert_not_nil(page.links.find { |l| l.text == "no_expires:nope" })
|
21
14
|
end
|
22
15
|
|
23
16
|
def test_no_space_cookies
|
24
|
-
page = @agent.get("http://localhost
|
17
|
+
page = @agent.get("http://localhost/one_cookie_no_space")
|
25
18
|
assert_equal(1, @agent.cookies.length)
|
26
19
|
foo_cookie = @agent.cookies.find { |k| k.name == 'foo' }
|
27
20
|
assert_not_nil(foo_cookie, 'Foo cookie was nil')
|
@@ -31,7 +24,7 @@ class CookiesMechTest < Test::Unit::TestCase
|
|
31
24
|
end
|
32
25
|
|
33
26
|
def test_many_cookies_as_string
|
34
|
-
page = @agent.get("http://localhost
|
27
|
+
page = @agent.get("http://localhost/many_cookies_as_string")
|
35
28
|
assert_equal(4, @agent.cookies.length)
|
36
29
|
|
37
30
|
name_cookie = @agent.cookies.find { |k| k.name == "name" }
|
@@ -62,7 +55,7 @@ class CookiesMechTest < Test::Unit::TestCase
|
|
62
55
|
end
|
63
56
|
|
64
57
|
def test_many_cookies
|
65
|
-
page = @agent.get("http://localhost
|
58
|
+
page = @agent.get("http://localhost/many_cookies")
|
66
59
|
assert_equal(4, @agent.cookies.length)
|
67
60
|
|
68
61
|
name_cookie = @agent.cookies.find { |k| k.name == "name" }
|
@@ -95,11 +88,11 @@ class CookiesMechTest < Test::Unit::TestCase
|
|
95
88
|
def test_get_cookie
|
96
89
|
assert_equal(true,
|
97
90
|
@agent.cookie_jar.empty?(
|
98
|
-
URI::parse("http://localhost
|
91
|
+
URI::parse("http://localhost/one_cookie")))
|
99
92
|
|
100
93
|
assert_equal(0, @agent.cookies.length)
|
101
94
|
|
102
|
-
page = @agent.get("http://localhost
|
95
|
+
page = @agent.get("http://localhost/one_cookie")
|
103
96
|
assert_equal(1, @agent.cookies.length)
|
104
97
|
|
105
98
|
cookie = @agent.cookies.first
|
@@ -110,8 +103,8 @@ class CookiesMechTest < Test::Unit::TestCase
|
|
110
103
|
|
111
104
|
assert_equal(false,
|
112
105
|
@agent.cookie_jar.empty?(
|
113
|
-
URI::parse("http://localhost
|
114
|
-
page = @agent.get("http://localhost
|
106
|
+
URI::parse("http://localhost/one_cookie")))
|
107
|
+
page = @agent.get("http://localhost/one_cookie")
|
115
108
|
|
116
109
|
assert_equal(1, @agent.cookies.length)
|
117
110
|
|
data/test/tc_encoded_links.rb
CHANGED
@@ -1,27 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rubygems'
|
5
|
-
require 'mechanize'
|
6
|
-
require 'test_includes'
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
7
2
|
|
8
3
|
class TestEncodedLinks < Test::Unit::TestCase
|
9
|
-
include TestMethods
|
10
|
-
|
11
4
|
def setup
|
12
5
|
@agent = WWW::Mechanize.new
|
13
|
-
@page = @agent.get("http://localhost
|
6
|
+
@page = @agent.get("http://localhost/tc_encoded_links.html")
|
14
7
|
end
|
15
8
|
|
16
9
|
def test_click_link
|
17
10
|
link = @page.links.first
|
18
|
-
assert_equal('/form_post?a=b&
|
11
|
+
assert_equal('/form_post?a=b&b=c', link.href)
|
19
12
|
page = @agent.click(link)
|
20
|
-
assert_equal("http://localhost
|
13
|
+
assert_equal("http://localhost/form_post?a=b&b=c", page.uri.to_s)
|
21
14
|
end
|
22
15
|
|
23
16
|
def test_hpricot_link
|
24
17
|
page = @agent.click(@page.search('a').first)
|
25
|
-
assert_equal("http://localhost
|
18
|
+
assert_equal("http://localhost/form_post?a=b&b=c", page.uri.to_s)
|
26
19
|
end
|
27
20
|
end
|
data/test/tc_errors.rb
CHANGED
@@ -1,19 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rubygems'
|
5
|
-
require 'mechanize'
|
6
|
-
require 'test_includes'
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
7
2
|
|
8
3
|
class MechErrorsTest < Test::Unit::TestCase
|
9
|
-
include TestMethods
|
10
|
-
|
11
4
|
def setup
|
12
5
|
@agent = WWW::Mechanize.new
|
13
6
|
end
|
14
7
|
|
15
8
|
def test_bad_form_method
|
16
|
-
page = @agent.get("http://localhost
|
9
|
+
page = @agent.get("http://localhost/bad_form_test.html")
|
17
10
|
assert_raise(RuntimeError) {
|
18
11
|
@agent.submit(page.forms.first)
|
19
12
|
}
|
@@ -21,14 +14,14 @@ class MechErrorsTest < Test::Unit::TestCase
|
|
21
14
|
|
22
15
|
def test_non_exist
|
23
16
|
begin
|
24
|
-
page = @agent.get("http://localhost
|
17
|
+
page = @agent.get("http://localhost/bad_form_test.html")
|
25
18
|
rescue RuntimeError => ex
|
26
19
|
assert_equal("404", ex.inspect)
|
27
20
|
end
|
28
21
|
end
|
29
22
|
|
30
23
|
def test_too_many_radio
|
31
|
-
page = @agent.get("http://localhost
|
24
|
+
page = @agent.get("http://localhost/form_test.html")
|
32
25
|
form = page.forms.name('post_form1').first
|
33
26
|
form.radiobuttons.each { |r| r.checked = true }
|
34
27
|
assert_raise(RuntimeError) {
|
data/test/tc_follow_meta.rb
CHANGED
@@ -1,13 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rubygems'
|
5
|
-
require 'mechanize'
|
6
|
-
require 'test_includes'
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
7
2
|
|
8
3
|
class FollowMetaTest < Test::Unit::TestCase
|
9
|
-
include TestMethods
|
10
|
-
|
11
4
|
def setup
|
12
5
|
@agent = WWW::Mechanize.new
|
13
6
|
end
|
data/test/tc_form_action.rb
CHANGED
@@ -1,17 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rubygems'
|
5
|
-
require 'mechanize'
|
6
|
-
require 'test_includes'
|
7
|
-
require 'logger'
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
8
2
|
|
9
3
|
class TestFormAction < Test::Unit::TestCase
|
10
|
-
include TestMethods
|
11
|
-
|
12
4
|
def setup
|
13
5
|
@agent = WWW::Mechanize.new
|
14
|
-
@page = @agent.get("http://localhost
|
6
|
+
@page = @agent.get("http://localhost/tc_form_action.html")
|
15
7
|
end
|
16
8
|
|
17
9
|
def test_post_encoded_action
|
@@ -20,7 +12,7 @@ class TestFormAction < Test::Unit::TestCase
|
|
20
12
|
}
|
21
13
|
assert_equal('/form_post?a=b&b=c', form.action)
|
22
14
|
page = form.submit
|
23
|
-
assert_equal("http://localhost
|
15
|
+
assert_equal("http://localhost/form_post?a=b&b=c", page.uri.to_s)
|
24
16
|
end
|
25
17
|
|
26
18
|
def test_get_encoded_action
|
@@ -29,7 +21,7 @@ class TestFormAction < Test::Unit::TestCase
|
|
29
21
|
}
|
30
22
|
assert_equal('/form_post?a=b&b=c', form.action)
|
31
23
|
page = form.submit
|
32
|
-
assert_equal("http://localhost
|
24
|
+
assert_equal("http://localhost/form_post?first_name=Aaron", page.uri.to_s)
|
33
25
|
end
|
34
26
|
|
35
27
|
def test_post_nonencoded_action
|
@@ -38,7 +30,7 @@ class TestFormAction < Test::Unit::TestCase
|
|
38
30
|
}
|
39
31
|
assert_equal('/form_post?a=b&b=c', form.action)
|
40
32
|
page = form.submit
|
41
|
-
assert_equal("http://localhost
|
33
|
+
assert_equal("http://localhost/form_post?a=b&b=c", page.uri.to_s)
|
42
34
|
end
|
43
35
|
|
44
36
|
def test_post_pound_sign
|
@@ -47,6 +39,6 @@ class TestFormAction < Test::Unit::TestCase
|
|
47
39
|
}
|
48
40
|
assert_equal('/form_post#1', form.action)
|
49
41
|
page = form.submit
|
50
|
-
assert_equal("http://localhost
|
42
|
+
assert_equal("http://localhost/form_post#1", page.uri.to_s)
|
51
43
|
end
|
52
44
|
end
|
data/test/tc_form_as_hash.rb
CHANGED
@@ -1,14 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'webrick'
|
4
|
-
require 'test/unit'
|
5
|
-
require 'rubygems'
|
6
|
-
require 'mechanize'
|
7
|
-
require 'test_includes'
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
8
2
|
|
9
3
|
class TestFormHash < Test::Unit::TestCase
|
10
|
-
include TestMethods
|
11
|
-
|
12
4
|
def setup
|
13
5
|
@agent = WWW::Mechanize.new
|
14
6
|
@page = @agent.get('http://localhost/form_multival.html')
|
data/test/tc_form_button.rb
CHANGED
@@ -1,13 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rubygems'
|
5
|
-
require 'mechanize'
|
6
|
-
require 'test_includes'
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
7
2
|
|
8
3
|
class TestFormButtons < Test::Unit::TestCase
|
9
|
-
include TestMethods
|
10
|
-
|
11
4
|
def setup
|
12
5
|
@agent = WWW::Mechanize.new
|
13
6
|
end
|
@@ -33,4 +26,8 @@ class TestFormButtons < Test::Unit::TestCase
|
|
33
26
|
assert_equal(1, page.forms.length)
|
34
27
|
assert_equal(1, page.forms.first.buttons.length)
|
35
28
|
end
|
29
|
+
|
30
|
+
def html_response
|
31
|
+
{ 'content-type' => 'text/html' }
|
32
|
+
end
|
36
33
|
end
|
@@ -1,13 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rubygems'
|
5
|
-
require 'mechanize'
|
6
|
-
require 'test_includes'
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
7
2
|
|
8
3
|
class FormNoInputNameTest < Test::Unit::TestCase
|
9
|
-
include TestMethods
|
10
|
-
|
11
4
|
def setup
|
12
5
|
@agent = WWW::Mechanize.new
|
13
6
|
@page = @agent.get('http://localhost/form_no_input_name.html')
|
data/test/tc_forms.rb
CHANGED
@@ -1,14 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'webrick'
|
4
|
-
require 'test/unit'
|
5
|
-
require 'rubygems'
|
6
|
-
require 'mechanize'
|
7
|
-
require 'test_includes'
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
8
2
|
|
9
3
|
class FormsMechTest < Test::Unit::TestCase
|
10
|
-
include TestMethods
|
11
|
-
|
12
4
|
def setup
|
13
5
|
@agent = WWW::Mechanize.new
|
14
6
|
end
|
@@ -21,7 +13,7 @@ class FormsMechTest < Test::Unit::TestCase
|
|
21
13
|
end
|
22
14
|
# Test submitting form with two fields of the same name
|
23
15
|
def test_post_multival
|
24
|
-
page = @agent.get("http://localhost
|
16
|
+
page = @agent.get("http://localhost/form_multival.html")
|
25
17
|
form = page.forms.name('post_form').first
|
26
18
|
|
27
19
|
assert_not_nil(form)
|
@@ -41,7 +33,7 @@ class FormsMechTest < Test::Unit::TestCase
|
|
41
33
|
|
42
34
|
# Test calling submit on the form object
|
43
35
|
def test_submit_on_form
|
44
|
-
page = @agent.get("http://localhost
|
36
|
+
page = @agent.get("http://localhost/form_multival.html")
|
45
37
|
form = page.forms.name('post_form').first
|
46
38
|
|
47
39
|
assert_not_nil(form)
|
@@ -61,7 +53,7 @@ class FormsMechTest < Test::Unit::TestCase
|
|
61
53
|
|
62
54
|
# Test submitting form with two fields of the same name
|
63
55
|
def test_get_multival
|
64
|
-
page = @agent.get("http://localhost
|
56
|
+
page = @agent.get("http://localhost/form_multival.html")
|
65
57
|
form = page.forms.name('get_form').first
|
66
58
|
|
67
59
|
assert_not_nil(form)
|
@@ -80,7 +72,7 @@ class FormsMechTest < Test::Unit::TestCase
|
|
80
72
|
end
|
81
73
|
|
82
74
|
def test_post
|
83
|
-
page = @agent.get("http://localhost
|
75
|
+
page = @agent.get("http://localhost/form_test.html")
|
84
76
|
post_form = page.forms.find { |f| f.name == "post_form1" }
|
85
77
|
assert_not_nil(post_form, "Post form is null")
|
86
78
|
assert_equal("post", post_form.method.downcase)
|
@@ -157,7 +149,7 @@ class FormsMechTest < Test::Unit::TestCase
|
|
157
149
|
end
|
158
150
|
|
159
151
|
def test_select_box
|
160
|
-
page = @agent.get("http://localhost
|
152
|
+
page = @agent.get("http://localhost/form_test.html")
|
161
153
|
post_form = page.forms.find { |f| f.name == "post_form1" }
|
162
154
|
assert_not_nil(post_form, "Post form is null")
|
163
155
|
assert_not_nil(page.header)
|
@@ -189,7 +181,7 @@ class FormsMechTest < Test::Unit::TestCase
|
|
189
181
|
end
|
190
182
|
|
191
183
|
def test_get
|
192
|
-
page = @agent.get("http://localhost
|
184
|
+
page = @agent.get("http://localhost/form_test.html")
|
193
185
|
get_form = page.forms.find { |f| f.name == "get_form1" }
|
194
186
|
assert_not_nil(get_form, "Get form is null")
|
195
187
|
assert_equal("get", get_form.method.downcase)
|
@@ -264,7 +256,7 @@ class FormsMechTest < Test::Unit::TestCase
|
|
264
256
|
end
|
265
257
|
|
266
258
|
def test_post_with_space_in_action
|
267
|
-
page = @agent.get("http://localhost
|
259
|
+
page = @agent.get("http://localhost/form_test.html")
|
268
260
|
post_form = page.forms.find { |f| f.name == "post_form2" }
|
269
261
|
assert_not_nil(post_form, "Post form is null")
|
270
262
|
assert_equal("post", post_form.method.downcase)
|
@@ -316,7 +308,7 @@ class FormsMechTest < Test::Unit::TestCase
|
|
316
308
|
end
|
317
309
|
|
318
310
|
def test_get_with_space_in_action
|
319
|
-
page = @agent.get("http://localhost
|
311
|
+
page = @agent.get("http://localhost/form_test.html")
|
320
312
|
get_form = page.forms.find { |f| f.name == "get_form2" }
|
321
313
|
assert_not_nil(get_form, "Get form is null")
|
322
314
|
assert_equal("get", get_form.method.downcase)
|
@@ -368,7 +360,7 @@ class FormsMechTest < Test::Unit::TestCase
|
|
368
360
|
end
|
369
361
|
|
370
362
|
def test_post_with_param_in_action
|
371
|
-
page = @agent.get("http://localhost
|
363
|
+
page = @agent.get("http://localhost/form_test.html")
|
372
364
|
post_form = page.forms.find { |f| f.name == "post_form3" }
|
373
365
|
assert_not_nil(post_form, "Post form is null")
|
374
366
|
assert_equal("post", post_form.method.downcase)
|
@@ -420,7 +412,7 @@ class FormsMechTest < Test::Unit::TestCase
|
|
420
412
|
end
|
421
413
|
|
422
414
|
def test_get_with_param_in_action
|
423
|
-
page = @agent.get("http://localhost
|
415
|
+
page = @agent.get("http://localhost/form_test.html")
|
424
416
|
get_form = page.forms.find { |f| f.name == "get_form3" }
|
425
417
|
assert_not_nil(get_form, "Get form is null")
|
426
418
|
assert_equal("get", get_form.method.downcase)
|
@@ -472,14 +464,14 @@ class FormsMechTest < Test::Unit::TestCase
|
|
472
464
|
end
|
473
465
|
|
474
466
|
def test_field_addition
|
475
|
-
page = @agent.get("http://localhost
|
467
|
+
page = @agent.get("http://localhost/form_test.html")
|
476
468
|
get_form = page.forms.find { |f| f.name == "get_form1" }
|
477
469
|
get_form.field("first_name").value = "Gregory"
|
478
470
|
assert_equal( "Gregory", get_form.field("first_name").value )
|
479
471
|
end
|
480
472
|
|
481
473
|
def test_fields_as_accessors
|
482
|
-
page = @agent.get("http://localhost
|
474
|
+
page = @agent.get("http://localhost/form_multival.html")
|
483
475
|
form = page.forms.name('post_form').first
|
484
476
|
|
485
477
|
assert_not_nil(form)
|
@@ -490,7 +482,7 @@ class FormsMechTest < Test::Unit::TestCase
|
|
490
482
|
end
|
491
483
|
|
492
484
|
def test_add_field
|
493
|
-
page = @agent.get("http://localhost
|
485
|
+
page = @agent.get("http://localhost/form_multival.html")
|
494
486
|
form = page.forms.name('post_form').first
|
495
487
|
|
496
488
|
assert_not_nil(form)
|
@@ -502,7 +494,7 @@ class FormsMechTest < Test::Unit::TestCase
|
|
502
494
|
end
|
503
495
|
|
504
496
|
def test_delete_field
|
505
|
-
page = @agent.get("http://localhost
|
497
|
+
page = @agent.get("http://localhost/form_multival.html")
|
506
498
|
form = page.forms.name('post_form').first
|
507
499
|
|
508
500
|
assert_not_nil(form)
|
@@ -514,7 +506,7 @@ class FormsMechTest < Test::Unit::TestCase
|
|
514
506
|
end
|
515
507
|
|
516
508
|
def test_has_field
|
517
|
-
page = @agent.get("http://localhost
|
509
|
+
page = @agent.get("http://localhost/form_multival.html")
|
518
510
|
form = page.forms.name('post_form').first
|
519
511
|
|
520
512
|
assert_not_nil(form)
|
data/test/tc_frames.rb
CHANGED
@@ -1,19 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'test/unit'
|
4
|
-
require 'rubygems'
|
5
|
-
require 'mechanize'
|
6
|
-
require 'test_includes'
|
1
|
+
require File.dirname(__FILE__) + "/helper"
|
7
2
|
|
8
3
|
class FramesMechTest < Test::Unit::TestCase
|
9
|
-
include TestMethods
|
10
|
-
|
11
4
|
def setup
|
12
5
|
@agent = WWW::Mechanize.new
|
13
6
|
end
|
14
7
|
|
15
8
|
def test_frames
|
16
|
-
page = @agent.get("http://localhost
|
9
|
+
page = @agent.get("http://localhost/frame_test.html")
|
17
10
|
assert_equal(3, page.frames.size)
|
18
11
|
assert_equal("frame1", page.frames[0].name)
|
19
12
|
assert_equal("frame2", page.frames[1].name)
|
@@ -24,7 +17,7 @@ class FramesMechTest < Test::Unit::TestCase
|
|
24
17
|
end
|
25
18
|
|
26
19
|
def test_iframes
|
27
|
-
page = @agent.get("http://localhost
|
20
|
+
page = @agent.get("http://localhost/iframe_test.html")
|
28
21
|
assert_equal(1, page.iframes.size)
|
29
22
|
assert_equal("frame4", page.iframes.first.name)
|
30
23
|
assert_equal("/file_upload.html", page.iframes.first.src)
|