forked from watir/watirspec
/
text_fields_spec.rb
38 lines (31 loc) · 1 KB
/
text_fields_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
# encoding: utf-8
require File.expand_path('spec_helper', File.dirname(__FILE__))
describe "TextFields" do
before :each do
browser.goto(WatirSpec.files + "/forms_with_input_elements.html")
end
describe "#length" do
it "returns the number of text fields" do
browser.text_fields.length.should == 9
end
end
describe "#[]" do
it "returns the text field at the given index" do
browser.text_fields[1].id.should == "new_user_first_name"
browser.text_fields[2].id.should == "new_user_last_name"
browser.text_fields[3].id.should == "new_user_email"
end
end
describe "#each" do
it "iterates through text fields correctly" do
index = 1
browser.text_fields.each do |r|
r.name.should == browser.text_field(:index, index).name
r.id.should == browser.text_field(:index, index).id
r.value.should == browser.text_field(:index, index).value
index += 1
end
browser.text_fields.length.should == index - 1
end
end
end