forked from watir/watirspec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
form_spec.rb
77 lines (62 loc) · 2.57 KB
/
form_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
# encoding: utf-8
require File.expand_path("../spec_helper", __FILE__)
describe "Form" do
before :each do
browser.goto(WatirSpec.url_for("forms_with_input_elements.html"))
end
describe "#exists?" do
it "returns true if the form exists" do
expect(browser.form(:id, 'new_user')).to exist
expect(browser.form(:id, /new_user/)).to exist
expect(browser.form(:class, 'user')).to exist
expect(browser.form(:class, /user/)).to exist
expect(browser.form(:method, 'post')).to exist
expect(browser.form(:method, /post/)).to exist
deviates_on :internet_explorer8 do
expect(browser.form(:action, 'post_to_me')).to exist
end
deviates_on :internet_explorer9 do
expect(browser.form(:action, /post_to_me/)).to exist
end
expect(browser.form(:action, /to_me/)).to exist
expect(browser.form(:index, 0)).to exist
expect(browser.form(:xpath, "//form[@id='new_user']")).to exist
end
it "returns the first form if given no args" do
expect(browser.form).to exist
end
it "returns false if the form doesn't exist" do
expect(browser.form(:id, 'no_such_id')).to_not exist
expect(browser.form(:id, /no_such_id/)).to_not exist
expect(browser.form(:class, 'no_such_class')).to_not exist
expect(browser.form(:class, /no_such_class/)).to_not exist
expect(browser.form(:method, 'no_such_method')).to_not exist
expect(browser.form(:method, /no_such_method/)).to_not exist
expect(browser.form(:action, 'no_such_action')).to_not exist
expect(browser.form(:action, /no_such_action/)).to_not exist
expect(browser.form(:index, 1337)).to_not exist
expect(browser.form(:xpath, "//form[@id='no_such_id']")).to_not exist
end
it "raises TypeError when 'what' argument is invalid" do
expect { browser.form(:id, 3.14).exists? }.to raise_error(TypeError)
end
it "raises MissingWayOfFindingObjectException when 'how' argument is invalid" do
expect { browser.form(:no_such_how, 'some_value').exists? }.to raise_error(MissingWayOfFindingObjectException)
end
end
describe "#submit" do
not_compliant_on :celerity do
it "submits the form" do
browser.form(:id, "delete_user").submit
expect(browser.text).to include("Semantic table")
end
it "triggers onsubmit event and takes its result into account" do
form = browser.form(:name, "user_new")
form.submit
expect(form).to exist
expect(messages.size).to eq 1
expect(messages[0]).to eq "submit"
end
end
end
end