celerity 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/History.txt +10 -0
  2. data/README.txt +8 -11
  3. data/Rakefile +5 -3
  4. data/benchmark/bm_2000_spans.rb +48 -0
  5. data/benchmark/bm_digg.rb +26 -0
  6. data/benchmark/bm_google_images.rb +36 -0
  7. data/benchmark/bm_input_locator.rb +69 -0
  8. data/benchmark/loader.rb +9 -0
  9. data/lib/celerity.rb +3 -1
  10. data/lib/celerity/container.rb +23 -171
  11. data/lib/celerity/disabled_element.rb +1 -1
  12. data/lib/celerity/element.rb +78 -47
  13. data/lib/celerity/element_collections.rb +16 -32
  14. data/lib/celerity/element_locator.rb +135 -0
  15. data/lib/celerity/elements/button.rb +15 -0
  16. data/lib/celerity/elements/file_field.rb +1 -1
  17. data/lib/celerity/elements/form.rb +2 -1
  18. data/lib/celerity/elements/frame.rb +18 -21
  19. data/lib/celerity/elements/image.rb +2 -8
  20. data/lib/celerity/elements/label.rb +1 -3
  21. data/lib/celerity/elements/link.rb +1 -1
  22. data/lib/celerity/elements/option.rb +16 -0
  23. data/lib/celerity/elements/radio_check.rb +18 -7
  24. data/lib/celerity/elements/select_list.rb +1 -17
  25. data/lib/celerity/elements/table.rb +4 -4
  26. data/lib/celerity/elements/table_body.rb +6 -8
  27. data/lib/celerity/elements/table_cell.rb +3 -14
  28. data/lib/celerity/elements/table_row.rb +4 -10
  29. data/lib/celerity/elements/text_field.rb +16 -4
  30. data/lib/celerity/extra/method_generator.rb +144 -0
  31. data/lib/celerity/identifier.rb +10 -0
  32. data/lib/celerity/ie.rb +28 -13
  33. data/lib/celerity/input_element.rb +0 -4
  34. data/lib/celerity/non_control_elements.rb +12 -12
  35. data/lib/celerity/version.rb +1 -1
  36. data/spec/area_spec.rb +41 -41
  37. data/spec/areas_spec.rb +11 -11
  38. data/spec/button_spec.rb +73 -68
  39. data/spec/buttons_spec.rb +10 -10
  40. data/spec/checkbox_spec.rb +102 -96
  41. data/spec/checkboxes_spec.rb +10 -10
  42. data/spec/div_spec.rb +78 -73
  43. data/spec/divs_spec.rb +10 -10
  44. data/spec/element_spec.rb +20 -11
  45. data/spec/filefield_spec.rb +36 -41
  46. data/spec/filefields_spec.rb +10 -10
  47. data/spec/form_spec.rb +29 -29
  48. data/spec/forms_spec.rb +11 -11
  49. data/spec/frame_spec.rb +54 -49
  50. data/spec/hidden_spec.rb +43 -43
  51. data/spec/hiddens_spec.rb +10 -10
  52. data/spec/html/2000_spans.html +2009 -0
  53. data/spec/html/forms_with_input_elements.html +15 -9
  54. data/spec/html/non_control_elements.html +4 -2
  55. data/spec/ie_spec.rb +82 -48
  56. data/spec/image_spec.rb +83 -100
  57. data/spec/images_spec.rb +10 -10
  58. data/spec/label_spec.rb +29 -29
  59. data/spec/labels_spec.rb +10 -10
  60. data/spec/li_spec.rb +41 -41
  61. data/spec/link_spec.rb +65 -59
  62. data/spec/links_spec.rb +11 -11
  63. data/spec/lis_spec.rb +10 -10
  64. data/spec/map_spec.rb +30 -30
  65. data/spec/maps_spec.rb +10 -10
  66. data/spec/p_spec.rb +49 -49
  67. data/spec/pre_spec.rb +41 -41
  68. data/spec/pres_spec.rb +10 -10
  69. data/spec/ps_spec.rb +10 -10
  70. data/spec/radio_spec.rb +104 -97
  71. data/spec/radios_spec.rb +11 -11
  72. data/spec/select_list_spec.rb +118 -106
  73. data/spec/select_lists_spec.rb +15 -15
  74. data/spec/span_spec.rb +54 -54
  75. data/spec/spans_spec.rb +11 -11
  76. data/spec/spec.opts +1 -1
  77. data/spec/spec_helper.rb +23 -3
  78. data/spec/table_bodies.rb +8 -8
  79. data/spec/table_bodies_spec.rb +9 -9
  80. data/spec/table_body_spec.rb +28 -27
  81. data/spec/table_cell_spec.rb +25 -25
  82. data/spec/table_cells_spec.rb +16 -16
  83. data/spec/table_row_spec.rb +16 -16
  84. data/spec/table_rows_spec.rb +12 -12
  85. data/spec/table_spec.rb +36 -36
  86. data/spec/tables_spec.rb +12 -12
  87. data/spec/text_field_spec.rb +111 -92
  88. data/spec/text_fields_spec.rb +13 -13
  89. data/tasks/benchmark.rake +3 -0
  90. data/tasks/rspec.rake +2 -2
  91. data/tasks/testserver.rake +15 -0
  92. metadata +58 -46
  93. data/tasks/simple_ci.rake +0 -94
data/spec/images_spec.rb CHANGED
@@ -2,38 +2,38 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
3
  describe "Images" do
4
4
  before :all do
5
- @ie = IE.new
6
- add_spec_checker(@ie)
5
+ @browser = IE.new
6
+ add_spec_checker(@browser)
7
7
  end
8
8
 
9
9
  before :each do
10
- @ie.goto(TEST_HOST + "/images.html")
10
+ @browser.goto(TEST_HOST + "/images.html")
11
11
  end
12
12
 
13
13
  describe "#length" do
14
14
  it "should return the number of images" do
15
- @ie.images.length.should == 8
15
+ @browser.images.length.should == 8
16
16
  end
17
17
  end
18
18
 
19
19
  describe "#[]" do
20
20
  it "should return the image at the given index" do
21
- @ie.images[6].id.should == "square"
21
+ @browser.images[6].id.should == "square"
22
22
  end
23
23
  end
24
24
 
25
25
  describe "#each" do
26
26
  it "should iterate through images correctly" do
27
- @ie.images.each_with_index do |c, index|
28
- c.name.should == @ie.image(:index, index+1).name
29
- c.id.should == @ie.image(:index, index+1).id
30
- c.value.should == @ie.image(:index, index+1).value
27
+ @browser.images.each_with_index do |c, index|
28
+ c.name.should == @browser.image(:index, index+1).name
29
+ c.id.should == @browser.image(:index, index+1).id
30
+ c.value.should == @browser.image(:index, index+1).value
31
31
  end
32
32
  end
33
33
  end
34
34
 
35
35
  after :all do
36
- @ie.close
36
+ @browser.close
37
37
  end
38
38
 
39
39
  end
data/spec/label_spec.rb CHANGED
@@ -2,64 +2,64 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
3
  # TODO: specs for exceptions
4
4
 
5
- describe "TextField" do
5
+ describe "Label" do
6
6
 
7
7
  before :all do
8
- @ie = IE.new
9
- add_spec_checker(@ie)
8
+ @browser = IE.new
9
+ add_spec_checker(@browser)
10
10
  end
11
11
 
12
12
  before :each do
13
- @ie.goto(TEST_HOST + "/forms_with_input_elements.html")
13
+ @browser.goto(TEST_HOST + "/forms_with_input_elements.html")
14
14
  end
15
15
 
16
16
  # Exists method
17
17
  describe "#exists?" do
18
18
  it "should return true if the element exists" do
19
- @ie.label(:id, 'first_label').should exist
20
- @ie.label(:id, /first_label/).should exist
21
- @ie.label(:text, 'First name').should exist
22
- @ie.label(:text, /First name/).should exist
23
- @ie.label(:index, 1).should exist
24
- @ie.label(:xpath, "//label[@id='first_label']").should exist
19
+ @browser.label(:id, 'first_label').should exist
20
+ @browser.label(:id, /first_label/).should exist
21
+ @browser.label(:text, 'First name').should exist
22
+ @browser.label(:text, /First name/).should exist
23
+ @browser.label(:index, 1).should exist
24
+ @browser.label(:xpath, "//label[@id='first_label']").should exist
25
25
  end
26
26
  it "should return false if the element does not exist" do
27
- @ie.label(:id, 'no_such_id').should_not exist
28
- @ie.label(:id, /no_such_id/).should_not exist
29
- @ie.label(:text, 'no_such_text').should_not exist
30
- @ie.label(:text, /no_such_text/).should_not exist
31
- @ie.label(:index, 1337).should_not exist
32
- @ie.label(:xpath, "//input[@id='no_such_id']").should_not exist
27
+ @browser.label(:id, 'no_such_id').should_not exist
28
+ @browser.label(:id, /no_such_id/).should_not exist
29
+ @browser.label(:text, 'no_such_text').should_not exist
30
+ @browser.label(:text, /no_such_text/).should_not exist
31
+ @browser.label(:index, 1337).should_not exist
32
+ @browser.label(:xpath, "//input[@id='no_such_id']").should_not exist
33
33
  end
34
- it "should raise ArgumentError when what argument is invalid" do
35
- lambda { @ie.label(:id, 3.14).exists? }.should raise_error(ArgumentError)
34
+ it "should raise ArgumentError when 'what' argument is invalid" do
35
+ lambda { @browser.label(:id, 3.14).exists? }.should raise_error(ArgumentError)
36
36
  end
37
- it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
38
- lambda { @ie.label(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
37
+ it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
38
+ lambda { @browser.label(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
39
39
  end
40
40
  end
41
41
 
42
42
  # Attribute methods
43
43
  describe "#id" do
44
- it "should return the id attribute if the text field exists" do
45
- @ie.label(:index, 1).id.should == "first_label"
44
+ it "should return the id attribute if the label exists" do
45
+ @browser.label(:index, 1).id.should == "first_label"
46
46
  end
47
- it "should raise UnknownObjectException if the text field doesn't exist" do
48
- lambda { @ie.label(:index, 1337).id }.should raise_error(UnknownObjectException)
47
+ it "should raise UnknownObjectException if the label doesn't exist" do
48
+ lambda { @browser.label(:index, 1337).id }.should raise_error(UnknownObjectException)
49
49
  end
50
50
  end
51
51
 
52
52
  describe "#for" do
53
- it "should return the id attribute if the text field exists" do
54
- @ie.label(:index, 1).for.should == "new_user_first_name"
53
+ it "should return the 'for' attribute if the label exists" do
54
+ @browser.label(:index, 1).for.should == "new_user_first_name"
55
55
  end
56
- it "should raise UnknownObjectException if the text field doesn't exist" do
57
- lambda { @ie.label(:index, 1337).for }.should raise_error(UnknownObjectException)
56
+ it "should raise UnknownObjectException if the label doesn't exist" do
57
+ lambda { @browser.label(:index, 1337).for }.should raise_error(UnknownObjectException)
58
58
  end
59
59
  end
60
60
 
61
61
  after :all do
62
- @ie.close
62
+ @browser.close
63
63
  end
64
64
  end
65
65
 
data/spec/labels_spec.rb CHANGED
@@ -3,38 +3,38 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
3
3
  describe "Labels" do
4
4
 
5
5
  before :all do
6
- @ie = IE.new
7
- add_spec_checker(@ie)
6
+ @browser = IE.new
7
+ add_spec_checker(@browser)
8
8
  end
9
9
 
10
10
  before :each do
11
- @ie.goto(TEST_HOST + "/forms_with_input_elements.html")
11
+ @browser.goto(TEST_HOST + "/forms_with_input_elements.html")
12
12
  end
13
13
 
14
14
  describe "#length" do
15
15
  it "should return the number of labels" do
16
- @ie.labels.length.should == 25
16
+ @browser.labels.length.should == 26 # changed this from 25 - Jari
17
17
  end
18
18
  end
19
19
 
20
20
  describe "#[]" do
21
21
  it "should return the pre at the given index" do
22
- @ie.labels[1].id.should == "first_label"
22
+ @browser.labels[1].id.should == "first_label"
23
23
  end
24
24
  end
25
25
 
26
26
  describe "#each" do
27
27
  it "should iterate through labels correctly" do
28
- @ie.labels.each_with_index do |l, index|
29
- l.name.should == @ie.label(:index, index+1).name
30
- l.id.should == @ie.label(:index, index+1).id
31
- l.value.should == @ie.label(:index, index+1).value
28
+ @browser.labels.each_with_index do |l, index|
29
+ l.name.should == @browser.label(:index, index+1).name
30
+ l.id.should == @browser.label(:index, index+1).id
31
+ l.value.should == @browser.label(:index, index+1).value
32
32
  end
33
33
  end
34
34
  end
35
35
 
36
36
  after :all do
37
- @ie.close
37
+ @browser.close
38
38
  end
39
39
 
40
40
  end
data/spec/li_spec.rb CHANGED
@@ -3,112 +3,112 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
3
3
  describe "Li" do
4
4
 
5
5
  before :all do
6
- @ie = IE.new
7
- add_spec_checker(@ie)
6
+ @browser = IE.new
7
+ add_spec_checker(@browser)
8
8
  end
9
9
 
10
10
  before :each do
11
- @ie.goto(TEST_HOST + "/non_control_elements.html")
11
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
12
12
  end
13
13
 
14
14
  # Exists method
15
15
  describe "#exist?" do
16
16
  it "should return true if the 'p' exists" do
17
- @ie.li(:id, "non_link_1").should exist
18
- @ie.li(:id, /non_link_1/).should exist
19
- @ie.li(:text, "Non-link 3").should exist
20
- @ie.li(:text, /Non-link 3/).should exist
21
- @ie.li(:class, "nonlink").should exist
22
- @ie.li(:class, /nonlink/).should exist
23
- @ie.li(:index, 1).should exist
24
- @ie.li(:xpath, "//li[@id='non_link_1']").should exist
17
+ @browser.li(:id, "non_link_1").should exist
18
+ @browser.li(:id, /non_link_1/).should exist
19
+ @browser.li(:text, "Non-link 3").should exist
20
+ @browser.li(:text, /Non-link 3/).should exist
21
+ @browser.li(:class, "nonlink").should exist
22
+ @browser.li(:class, /nonlink/).should exist
23
+ @browser.li(:index, 1).should exist
24
+ @browser.li(:xpath, "//li[@id='non_link_1']").should exist
25
25
  end
26
26
  it "should return false if the 'p' doesn't exist" do
27
- @ie.li(:id, "no_such_id").should_not exist
28
- @ie.li(:id, /no_such_id/).should_not exist
29
- @ie.li(:text, "no_such_text").should_not exist
30
- @ie.li(:text, /no_such_text/).should_not exist
31
- @ie.li(:class, "no_such_class").should_not exist
32
- @ie.li(:class, /no_such_class/).should_not exist
33
- @ie.li(:index, 1337).should_not exist
34
- @ie.li(:xpath, "//li[@id='no_such_id']").should_not exist
27
+ @browser.li(:id, "no_such_id").should_not exist
28
+ @browser.li(:id, /no_such_id/).should_not exist
29
+ @browser.li(:text, "no_such_text").should_not exist
30
+ @browser.li(:text, /no_such_text/).should_not exist
31
+ @browser.li(:class, "no_such_class").should_not exist
32
+ @browser.li(:class, /no_such_class/).should_not exist
33
+ @browser.li(:index, 1337).should_not exist
34
+ @browser.li(:xpath, "//li[@id='no_such_id']").should_not exist
35
35
  end
36
- it "should raise ArgumentError when what argument is invalid" do
37
- lambda { @ie.li(:id, 3.14).exists? }.should raise_error(ArgumentError)
36
+ it "should raise ArgumentError when 'what' argument is invalid" do
37
+ lambda { @browser.li(:id, 3.14).exists? }.should raise_error(ArgumentError)
38
38
  end
39
- it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
40
- lambda { @ie.li(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
39
+ it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
40
+ lambda { @browser.li(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
41
41
  end
42
42
  end
43
43
 
44
44
  # Attribute methods
45
45
  describe "#class_name" do
46
46
  it "should return the class attribute" do
47
- @ie.li(:id, 'non_link_1').class_name.should == 'nonlink'
47
+ @browser.li(:id, 'non_link_1').class_name.should == 'nonlink'
48
48
  end
49
49
  it "should return an empty string if the element exists and the attribute doesn't" do
50
- @ie.li(:index, 1).class_name.should == ''
50
+ @browser.li(:index, 1).class_name.should == ''
51
51
  end
52
52
  it "should raise UnknownObjectException if the p doesn't exist" do
53
- lambda { @ie.li(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
53
+ lambda { @browser.li(:id, 'no_such_id').class_name }.should raise_error(UnknownObjectException)
54
54
  end
55
55
  end
56
56
 
57
57
  describe "#id" do
58
58
  it "should return the id attribute" do
59
- @ie.li(:class, 'nonlink').id.should == "non_link_1"
59
+ @browser.li(:class, 'nonlink').id.should == "non_link_1"
60
60
  end
61
61
  it "should return an empty string if the element exists and the attribute doesn't" do
62
- @ie.li(:index, 1).id.should == ''
62
+ @browser.li(:index, 1).id.should == ''
63
63
  end
64
64
  it "should raise UnknownObjectException if the p doesn't exist" do
65
- lambda { @ie.li(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
66
- lambda { @ie.li(:index, 1337).id }.should raise_error(UnknownObjectException)
65
+ lambda { @browser.li(:id, "no_such_id").id }.should raise_error(UnknownObjectException)
66
+ lambda { @browser.li(:index, 1337).id }.should raise_error(UnknownObjectException)
67
67
  end
68
68
  end
69
69
 
70
70
  describe "#title" do
71
71
  it "should return the title attribute" do
72
- @ie.li(:id, 'non_link_1').title.should == 'This is not a link!'
72
+ @browser.li(:id, 'non_link_1').title.should == 'This is not a link!'
73
73
  end
74
74
  it "should return an empty string if the element exists and the attribute doesn't" do
75
- @ie.li(:index, 1).title.should == ''
75
+ @browser.li(:index, 1).title.should == ''
76
76
  end
77
77
  it "should raise UnknownObjectException if the p doesn't exist" do
78
- lambda { @ie.li(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
79
- lambda { @ie.li(:xpath, "//li[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
78
+ lambda { @browser.li(:id, 'no_such_id').title }.should raise_error( UnknownObjectException)
79
+ lambda { @browser.li(:xpath, "//li[@id='no_such_id']").title }.should raise_error( UnknownObjectException)
80
80
  end
81
81
  end
82
82
 
83
83
  describe "#text" do
84
84
  it "should return the text of the p" do
85
- @ie.li(:id, 'non_link_1').text.should == 'Non-link 1'
85
+ @browser.li(:id, 'non_link_1').text.should == 'Non-link 1'
86
86
  end
87
87
  it "should return an empty string if the element doesn't contain any text" do
88
- @ie.li(:index, 1).text.should == ''
88
+ @browser.li(:index, 1).text.should == ''
89
89
  end
90
90
  it "should raise UnknownObjectException if the p doesn't exist" do
91
- lambda { @ie.li(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
92
- lambda { @ie.li(:xpath , "//li[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
91
+ lambda { @browser.li(:id, 'no_such_id').text }.should raise_error( UnknownObjectException)
92
+ lambda { @browser.li(:xpath , "//li[@id='no_such_id']").text }.should raise_error( UnknownObjectException)
93
93
  end
94
94
  end
95
95
 
96
96
  # Other
97
97
  describe "#to_s" do
98
98
  it "should return a human readable representation of the element" do
99
- @ie.li(:id, 'non_link_1').to_s.should == "tag: li\n" +
99
+ @browser.li(:id, 'non_link_1').to_s.should == "tag: li\n" +
100
100
  " id: non_link_1\n" +
101
101
  " class: nonlink\n" +
102
102
  " title: This is not a link!\n" +
103
103
  " text: Non-link 1"
104
104
  end
105
105
  it "should raise UnknownObjectException if the p doesn't exist" do
106
- lambda { @ie.li(:xpath, "//li[@id='no_such_id']").to_s }.should raise_error( UnknownObjectException)
106
+ lambda { @browser.li(:xpath, "//li[@id='no_such_id']").to_s }.should raise_error( UnknownObjectException)
107
107
  end
108
108
  end
109
109
 
110
110
  after :all do
111
- @ie.close
111
+ @browser.close
112
112
  end
113
113
 
114
114
  end
data/spec/link_spec.rb CHANGED
@@ -2,146 +2,152 @@ require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
3
  describe "Link" do
4
4
  before :all do
5
- @ie = IE.new
6
- add_spec_checker(@ie)
5
+ @browser = IE.new
6
+ add_spec_checker(@browser)
7
7
  end
8
8
 
9
9
  before :each do
10
- @ie.goto(TEST_HOST + "/non_control_elements.html")
10
+ @browser.goto(TEST_HOST + "/non_control_elements.html")
11
11
  end
12
12
 
13
13
  # Exists method
14
14
  describe "#exist?" do
15
15
  it "should return true if the link exists" do
16
- @ie.link(:id, 'link_2').should exist
17
- @ie.link(:id, /link_2/).should exist
18
- @ie.link(:name, 'bad_attribute').should exist
19
- @ie.link(:name, /bad_attribute/).should exist
20
- @ie.link(:title, "link_title_2").should exist
21
- @ie.link(:title, /link_title_2/).should exist
22
- @ie.link(:text, "Link 2").should exist
23
- @ie.link(:text, /Link 2/i).should exist
24
- @ie.link(:url, 'non_control_elements.html').should exist
25
- @ie.link(:url, /non_control_elements.html/).should exist
26
- @ie.link(:index, 2).should exist
27
- @ie.link(:xpath, "//a[@id='link_2']").should exist
16
+ @browser.link(:id, 'link_2').should exist
17
+ @browser.link(:id, /link_2/).should exist
18
+ @browser.link(:name, 'bad_attribute').should exist
19
+ @browser.link(:name, /bad_attribute/).should exist
20
+ @browser.link(:title, "link_title_2").should exist
21
+ @browser.link(:title, /link_title_2/).should exist
22
+ @browser.link(:text, "Link 2").should exist
23
+ @browser.link(:text, /Link 2/i).should exist
24
+ @browser.link(:url, 'non_control_elements.html').should exist
25
+ @browser.link(:url, /non_control_elements.html/).should exist
26
+ @browser.link(:index, 2).should exist
27
+ @browser.link(:xpath, "//a[@id='link_2']").should exist
28
28
  end
29
29
  it "should return false if the link doesn't exist" do
30
- @ie.link(:id, 'no_such_id').should_not exist
31
- @ie.link(:id, /no_such_id/).should_not exist
32
- @ie.link(:name, 'no_such_name').should_not exist
33
- @ie.link(:name, /no_such_name/).should_not exist
34
- @ie.link(:title, "no_such_title").should_not exist
35
- @ie.link(:title, /no_such_title/).should_not exist
36
- @ie.link(:text, "no_such_text").should_not exist
37
- @ie.link(:text, /no_such_text/i).should_not exist
38
- @ie.link(:url, 'no_such_href').should_not exist
39
- @ie.link(:url, /no_such_href/).should_not exist
40
- @ie.link(:index, 1337).should_not exist
41
- @ie.link(:xpath, "//a[@id='no_such_id']").should_not exist
42
- end
43
- it "should raise ArgumentError when what argument is invalid" do
44
- lambda { @ie.link(:id, 3.14).exists? }.should raise_error(ArgumentError)
45
- end
46
- it "should raise MissingWayOfFindingObjectException when how argument is invalid" do
47
- lambda { @ie.link(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
30
+ @browser.link(:id, 'no_such_id').should_not exist
31
+ @browser.link(:id, /no_such_id/).should_not exist
32
+ @browser.link(:name, 'no_such_name').should_not exist
33
+ @browser.link(:name, /no_such_name/).should_not exist
34
+ @browser.link(:title, "no_such_title").should_not exist
35
+ @browser.link(:title, /no_such_title/).should_not exist
36
+ @browser.link(:text, "no_such_text").should_not exist
37
+ @browser.link(:text, /no_such_text/i).should_not exist
38
+ @browser.link(:url, 'no_such_href').should_not exist
39
+ @browser.link(:url, /no_such_href/).should_not exist
40
+ @browser.link(:index, 1337).should_not exist
41
+ @browser.link(:xpath, "//a[@id='no_such_id']").should_not exist
42
+ end
43
+ it "should raise ArgumentError when 'what' argument is invalid" do
44
+ lambda { @browser.link(:id, 3.14).exists? }.should raise_error(ArgumentError)
45
+ end
46
+ it "should raise MissingWayOfFindingObjectException when 'how' argument is invalid" do
47
+ lambda { @browser.link(:no_such_how, 'some_value').exists? }.should raise_error(MissingWayOfFindingObjectException)
48
48
  end
49
49
  end
50
50
 
51
51
  # Attribute methods
52
52
  describe "#class_name" do
53
53
  it "should return the type attribute if the link exists" do
54
- @ie.link(:index, 2).class_name.should == "external"
54
+ @browser.link(:index, 2).class_name.should == "external"
55
55
  end
56
56
  it "should return an empty string if the link exists and the attribute doesn't" do
57
- @ie.link(:index, 1).class_name.should == ''
57
+ @browser.link(:index, 1).class_name.should == ''
58
58
  end
59
59
  it "should raise an UnknownObjectException if the link doesn't exist" do
60
- lambda { @ie.link(:index, 1337).class_name }.should raise_error(UnknownObjectException)
60
+ lambda { @browser.link(:index, 1337).class_name }.should raise_error(UnknownObjectException)
61
61
  end
62
62
  end
63
63
 
64
64
  describe "#href" do
65
65
  it "should return the href attribute if the link exists" do
66
- @ie.link(:index, 2).href.should match(/non_control_elements/)
66
+ @browser.link(:index, 2).href.should match(/non_control_elements/)
67
67
  end
68
68
  it "should return an empty string if the link exists and the attribute doesn't" do
69
- @ie.link(:index, 1).href.should == ""
69
+ @browser.link(:index, 1).href.should == ""
70
70
  end
71
71
  it "should raise an UnknownObjectException if the link doesn't exist" do
72
- lambda { @ie.link(:index, 1337).href }.should raise_error(UnknownObjectException)
72
+ lambda { @browser.link(:index, 1337).href }.should raise_error(UnknownObjectException)
73
73
  end
74
74
  end
75
75
 
76
+ describe "#url" do
77
+ it "should return the href attribute" do
78
+ @browser.link(:index, 2).url.should match(/non_control_elements/)
79
+ end
80
+ end
81
+
76
82
  describe "#id" do
77
83
  it "should return the id attribute if the link exists" do
78
- @ie.link(:index, 2).id.should == "link_2"
84
+ @browser.link(:index, 2).id.should == "link_2"
79
85
  end
80
86
  it "should return an empty string if the link exists and the attribute doesn't" do
81
- @ie.link(:index, 1).id.should == ""
87
+ @browser.link(:index, 1).id.should == ""
82
88
  end
83
89
  it "should raise an UnknownObjectException if the link doesn't exist" do
84
- lambda { @ie.link(:index, 1337).id }.should raise_error(UnknownObjectException)
90
+ lambda { @browser.link(:index, 1337).id }.should raise_error(UnknownObjectException)
85
91
  end
86
92
  end
87
93
 
88
94
  describe "#name" do
89
95
  it "should return the name attribute if the link exists" do
90
- @ie.link(:index, 3).name.should == "bad_attribute"
96
+ @browser.link(:index, 3).name.should == "bad_attribute"
91
97
  end
92
98
  it "should return an empty string if the link exists and the attribute doesn't" do
93
- @ie.link(:index, 1).name.should == ''
99
+ @browser.link(:index, 1).name.should == ''
94
100
  end
95
101
  it "should raise an UnknownObjectException if the link doesn't exist" do
96
- lambda { @ie.link(:index, 1337).name }.should raise_error(UnknownObjectException)
102
+ lambda { @browser.link(:index, 1337).name }.should raise_error(UnknownObjectException)
97
103
  end
98
104
  end
99
105
 
100
106
  describe "#text" do
101
107
  it "should return the link text" do
102
- @ie.link(:index, 2).text.should == "Link 2"
108
+ @browser.link(:index, 2).text.should == "Link 2"
103
109
  end
104
110
  it "should return an empty string if the link exists and contains no text" do
105
- @ie.link(:index, 1).text.should == ""
111
+ @browser.link(:index, 1).text.should == ""
106
112
  end
107
113
  it "should raise an UnknownObjectException if the link doesn't exist" do
108
- lambda { @ie.link(:index, 1337).text }.should raise_error(UnknownObjectException)
114
+ lambda { @browser.link(:index, 1337).text }.should raise_error(UnknownObjectException)
109
115
  end
110
116
  end
111
117
 
112
118
  describe "#title" do
113
119
  it "should return the type attribute if the link exists" do
114
- @ie.link(:index, 2).title.should == "link_title_2"
120
+ @browser.link(:index, 2).title.should == "link_title_2"
115
121
  end
116
122
  it "should return an empty string if the link exists and the attribute doesn't" do
117
- @ie.link(:index, 1).title.should == ""
123
+ @browser.link(:index, 1).title.should == ""
118
124
  end
119
125
  it "should raise an UnknownObjectException if the link doesn't exist" do
120
- lambda { @ie.link(:index, 1337).title }.should raise_error(UnknownObjectException)
126
+ lambda { @browser.link(:index, 1337).title }.should raise_error(UnknownObjectException)
121
127
  end
122
128
  end
123
129
 
124
130
  # Manipulation methods
125
131
  describe "#click" do
126
132
  it "should find an existing link by (:text, String) and click it" do
127
- @ie.link(:text, "Link 3").click
128
- @ie.text.include?("User administration").should be_true
133
+ @browser.link(:text, "Link 3").click
134
+ @browser.text.include?("User administration").should be_true
129
135
  end
130
136
  it "should find an existing link by (:text, Regexp) and click it" do
131
- @ie.link(:url, /forms_with_input_elements/).click
132
- @ie.text.include?("User administration").should be_true
137
+ @browser.link(:url, /forms_with_input_elements/).click
138
+ @browser.text.include?("User administration").should be_true
133
139
  end
134
140
  it "should find an existing link by (:index, Integer) and click it" do
135
- @ie.link(:index, 3).click
136
- @ie.text.include?("User administration").should be_true
141
+ @browser.link(:index, 3).click
142
+ @browser.text.include?("User administration").should be_true
137
143
  end
138
144
  it "should raise an UnknownObjectException if the link doesn't exist" do
139
- lambda { @ie.link(:index, 1337).click }.should raise_error(UnknownObjectException)
145
+ lambda { @browser.link(:index, 1337).click }.should raise_error(UnknownObjectException)
140
146
  end
141
147
  end
142
148
 
143
149
  after :all do
144
- @ie.close
150
+ @browser.close
145
151
  end
146
152
 
147
153
  end