capybara 1.1.4 → 2.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/History.txt +100 -0
  2. data/License.txt +22 -0
  3. data/README.md +829 -0
  4. data/lib/capybara.rb +124 -6
  5. data/lib/capybara/cucumber.rb +2 -5
  6. data/lib/capybara/driver/base.rb +5 -5
  7. data/lib/capybara/driver/node.rb +2 -2
  8. data/lib/capybara/dsl.rb +3 -121
  9. data/lib/capybara/node/actions.rb +12 -28
  10. data/lib/capybara/node/base.rb +5 -13
  11. data/lib/capybara/node/element.rb +21 -21
  12. data/lib/capybara/node/finders.rb +27 -89
  13. data/lib/capybara/node/matchers.rb +107 -69
  14. data/lib/capybara/node/simple.rb +11 -13
  15. data/lib/capybara/query.rb +78 -0
  16. data/lib/capybara/rack_test/browser.rb +16 -27
  17. data/lib/capybara/rack_test/driver.rb +11 -1
  18. data/lib/capybara/rack_test/node.rb +17 -1
  19. data/lib/capybara/result.rb +84 -0
  20. data/lib/capybara/rspec/matchers.rb +28 -63
  21. data/lib/capybara/selector.rb +97 -33
  22. data/lib/capybara/selenium/driver.rb +14 -61
  23. data/lib/capybara/selenium/node.rb +6 -15
  24. data/lib/capybara/server.rb +32 -27
  25. data/lib/capybara/session.rb +54 -30
  26. data/lib/capybara/spec/public/jquery-ui.js +791 -0
  27. data/lib/capybara/spec/public/jquery.js +9046 -0
  28. data/lib/capybara/spec/public/test.js +4 -1
  29. data/lib/capybara/spec/session.rb +56 -27
  30. data/lib/capybara/spec/session/all_spec.rb +8 -4
  31. data/lib/capybara/spec/session/attach_file_spec.rb +12 -9
  32. data/lib/capybara/spec/session/check_spec.rb +6 -3
  33. data/lib/capybara/spec/session/choose_spec.rb +4 -1
  34. data/lib/capybara/spec/session/click_button_spec.rb +5 -14
  35. data/lib/capybara/spec/session/click_link_or_button_spec.rb +2 -1
  36. data/lib/capybara/spec/session/click_link_spec.rb +3 -17
  37. data/lib/capybara/spec/session/current_url_spec.rb +77 -9
  38. data/lib/capybara/spec/session/fill_in_spec.rb +8 -18
  39. data/lib/capybara/spec/session/find_spec.rb +19 -46
  40. data/lib/capybara/spec/session/first_spec.rb +2 -34
  41. data/lib/capybara/spec/session/has_css_spec.rb +1 -1
  42. data/lib/capybara/spec/session/has_field_spec.rb +28 -0
  43. data/lib/capybara/spec/session/has_select_spec.rb +84 -31
  44. data/lib/capybara/spec/session/has_table_spec.rb +7 -69
  45. data/lib/capybara/spec/session/has_text_spec.rb +168 -0
  46. data/lib/capybara/spec/session/javascript.rb +65 -81
  47. data/lib/capybara/spec/session/node_spec.rb +115 -0
  48. data/lib/capybara/spec/session/screenshot.rb +29 -0
  49. data/lib/capybara/spec/session/select_spec.rb +12 -12
  50. data/lib/capybara/spec/session/text_spec.rb +9 -4
  51. data/lib/capybara/spec/session/unselect_spec.rb +12 -6
  52. data/lib/capybara/spec/session/visit_spec.rb +76 -0
  53. data/lib/capybara/spec/session/within_frame_spec.rb +33 -0
  54. data/lib/capybara/spec/session/within_spec.rb +47 -58
  55. data/lib/capybara/spec/session/within_window_spec.rb +40 -0
  56. data/lib/capybara/spec/test_app.rb +27 -3
  57. data/lib/capybara/spec/views/form.erb +11 -10
  58. data/lib/capybara/spec/views/host_links.erb +2 -2
  59. data/lib/capybara/spec/views/tables.erb +6 -66
  60. data/lib/capybara/spec/views/with_html.erb +3 -3
  61. data/lib/capybara/spec/views/with_js.erb +11 -8
  62. data/lib/capybara/util/save_and_open_page.rb +4 -3
  63. data/lib/capybara/version.rb +1 -1
  64. data/spec/basic_node_spec.rb +15 -3
  65. data/spec/dsl_spec.rb +12 -10
  66. data/spec/rack_test_spec.rb +152 -0
  67. data/spec/rspec/features_spec.rb +0 -2
  68. data/spec/rspec/matchers_spec.rb +164 -89
  69. data/spec/rspec_spec.rb +0 -2
  70. data/spec/selenium_spec.rb +67 -0
  71. data/spec/server_spec.rb +35 -23
  72. data/spec/spec_helper.rb +18 -2
  73. metadata +30 -30
  74. data/README.rdoc +0 -722
  75. data/lib/capybara/spec/driver.rb +0 -301
  76. data/lib/capybara/spec/session/current_host_spec.rb +0 -68
  77. data/lib/capybara/spec/session/has_content_spec.rb +0 -106
  78. data/lib/capybara/util/timeout.rb +0 -27
  79. data/spec/driver/rack_test_driver_spec.rb +0 -89
  80. data/spec/driver/selenium_driver_spec.rb +0 -37
  81. data/spec/session/rack_test_session_spec.rb +0 -55
  82. data/spec/session/selenium_session_spec.rb +0 -26
  83. data/spec/string_spec.rb +0 -77
  84. data/spec/timeout_spec.rb +0 -28
@@ -0,0 +1,29 @@
1
+ shared_examples_for "session with screenshot support" do
2
+ describe "#save_screenshot" do
3
+ let(:image_path) { File.join(Dir.tmpdir, 'capybara-screenshot.png') }
4
+
5
+ before do
6
+ @session.visit '/'
7
+ @session.save_screenshot image_path
8
+ end
9
+
10
+ it "should generate PNG file" do
11
+ magic = File.read(image_path, 4)
12
+ magic.should eq "\x89PNG"
13
+ end
14
+ end
15
+ end
16
+
17
+ shared_examples_for "session without screenshot support" do
18
+ describe "#save_screenshot" do
19
+ before do
20
+ @session.visit('/')
21
+ end
22
+
23
+ it "should raise an error" do
24
+ running {
25
+ @session.save_screenshot 'raise_error.png'
26
+ }.should raise_error(Capybara::NotSupportedByDriverError)
27
+ end
28
+ end
29
+ end
@@ -30,15 +30,9 @@ shared_examples_for "select" do
30
30
  end
31
31
 
32
32
  it "should select an option without giving a select box" do
33
- @session.select("Mr")
33
+ @session.select("Swedish")
34
34
  @session.click_button('awesome')
35
- extract_results(@session)['title'].should == 'Mr'
36
- end
37
-
38
- it "should favour exact matches to option labels" do
39
- @session.select("Mr", :from => 'Title')
40
- @session.click_button('awesome')
41
- extract_results(@session)['title'].should == 'Mr'
35
+ extract_results(@session)['locale'].should == 'sv'
42
36
  end
43
37
 
44
38
  it "should escape quotes" do
@@ -63,13 +57,19 @@ shared_examples_for "select" do
63
57
 
64
58
  context "with a locator that doesn't exist" do
65
59
  it "should raise an error" do
66
- running { @session.select('foo', :from => 'does not exist') }.should raise_error(Capybara::ElementNotFound)
60
+ msg = "Unable to find select box \"does not exist\""
61
+ running do
62
+ @session.select('foo', :from => 'does not exist')
63
+ end.should raise_error(Capybara::ElementNotFound, msg)
67
64
  end
68
65
  end
69
66
 
70
67
  context "with an option that doesn't exist" do
71
68
  it "should raise an error" do
72
- running { @session.select('Does not Exist', :from => 'form_locale') }.should raise_error(Capybara::ElementNotFound)
69
+ msg = "Unable to find option \"Does not Exist\""
70
+ running do
71
+ @session.select('Does not Exist', :from => 'form_locale')
72
+ end.should raise_error(Capybara::ElementNotFound, msg)
73
73
  end
74
74
  end
75
75
 
@@ -96,7 +96,7 @@ shared_examples_for "select" do
96
96
  @session.click_button('awesome')
97
97
  extract_results(@session)['languages'].should include('Ruby', 'Javascript')
98
98
  end
99
-
99
+
100
100
  it "should remain selected if already selected" do
101
101
  @session.select("Ruby", :from => 'Language')
102
102
  @session.select("Javascript", :from => 'Language')
@@ -104,7 +104,7 @@ shared_examples_for "select" do
104
104
  @session.click_button('awesome')
105
105
  extract_results(@session)['languages'].should include('Ruby', 'Javascript')
106
106
  end
107
-
107
+
108
108
  it "should return value attribute rather than content if present" do
109
109
  @session.find_field('Underwear').value.should include('thermal')
110
110
  end
@@ -1,19 +1,24 @@
1
1
  shared_examples_for "text" do
2
2
  describe '#text' do
3
- before do
4
- @session.visit('/with_simple_html')
5
- end
6
-
7
3
  it "should print the text of the page" do
4
+ @session.visit('/with_simple_html')
8
5
  @session.text.should == 'Bar'
9
6
  end
10
7
 
11
8
  context "with css as default selector" do
12
9
  before { Capybara.default_selector = :css }
13
10
  it "should print the text of the page" do
11
+ @session.visit('/with_simple_html')
14
12
  @session.text.should == 'Bar'
15
13
  end
16
14
  after { Capybara.default_selector = :xpath }
17
15
  end
16
+
17
+ it "should strip whitespace" do
18
+ @session.visit('/with_html')
19
+ n = @session.find(:css, '#second')
20
+ @session.find(:css, '#second').text.should =~ \
21
+ /\ADuis aute .* text with whitespace .* est laborum\.\z/
22
+ end
18
23
  end
19
24
  end
@@ -8,28 +8,28 @@ shared_examples_for "unselect" do
8
8
  it "should unselect an option from a select box by id" do
9
9
  @session.unselect('Commando', :from => 'form_underwear')
10
10
  @session.click_button('awesome')
11
- extract_results(@session)['underwear'].should include('Briefs', 'Boxer Briefs')
11
+ extract_results(@session)['underwear'].should include('Briefs', 'Boxerbriefs')
12
12
  extract_results(@session)['underwear'].should_not include('Commando')
13
13
  end
14
14
 
15
15
  it "should unselect an option without a select box" do
16
16
  @session.unselect('Commando')
17
17
  @session.click_button('awesome')
18
- extract_results(@session)['underwear'].should include('Briefs', 'Boxer Briefs')
18
+ extract_results(@session)['underwear'].should include('Briefs', 'Boxerbriefs')
19
19
  extract_results(@session)['underwear'].should_not include('Commando')
20
20
  end
21
21
 
22
22
  it "should unselect an option from a select box by label" do
23
23
  @session.unselect('Commando', :from => 'Underwear')
24
24
  @session.click_button('awesome')
25
- extract_results(@session)['underwear'].should include('Briefs', 'Boxer Briefs')
25
+ extract_results(@session)['underwear'].should include('Briefs', 'Boxerbriefs')
26
26
  extract_results(@session)['underwear'].should_not include('Commando')
27
27
  end
28
28
 
29
29
  it "should favour exact matches to option labels" do
30
30
  @session.unselect("Briefs", :from => 'Underwear')
31
31
  @session.click_button('awesome')
32
- extract_results(@session)['underwear'].should include('Commando', 'Boxer Briefs')
32
+ extract_results(@session)['underwear'].should include('Commando', 'Boxerbriefs')
33
33
  extract_results(@session)['underwear'].should_not include('Briefs')
34
34
  end
35
35
 
@@ -48,13 +48,19 @@ shared_examples_for "unselect" do
48
48
 
49
49
  context "with a locator that doesn't exist" do
50
50
  it "should raise an error" do
51
- running { @session.unselect('foo', :from => 'does not exist') }.should raise_error(Capybara::ElementNotFound)
51
+ msg = "Unable to find select box \"does not exist\""
52
+ running do
53
+ @session.unselect('foo', :from => 'does not exist')
54
+ end.should raise_error(Capybara::ElementNotFound, msg)
52
55
  end
53
56
  end
54
57
 
55
58
  context "with an option that doesn't exist" do
56
59
  it "should raise an error" do
57
- running { @session.unselect('Does not Exist', :from => 'form_underwear') }.should raise_error(Capybara::ElementNotFound)
60
+ msg = "Unable to find option \"Does not Exist\""
61
+ running do
62
+ @session.unselect('Does not Exist', :from => 'form_underwear')
63
+ end.should raise_error(Capybara::ElementNotFound, msg)
58
64
  end
59
65
  end
60
66
  end
@@ -0,0 +1,76 @@
1
+ shared_examples_for "visit" do
2
+ describe '#visit' do
3
+ it "should fetch a response from the driver with a relative url" do
4
+ @session.visit('/')
5
+ @session.body.should include('Hello world!')
6
+ @session.visit('/foo')
7
+ @session.body.should include('Another World')
8
+ end
9
+
10
+ it "should fetch a response from the driver with an absolute url with a port" do
11
+ # Preparation
12
+ @session.visit('/')
13
+ root_uri = URI.parse(@session.current_url)
14
+
15
+ @session.visit("http://#{root_uri.host}:#{root_uri.port}/")
16
+ @session.body.should include('Hello world!')
17
+ @session.visit("http://#{root_uri.host}:#{root_uri.port}/foo")
18
+ @session.body.should include('Another World')
19
+ end
20
+
21
+ context "when Capybara.always_include_port is true" do
22
+
23
+ let(:root_uri) do
24
+ @session.visit('/')
25
+ URI.parse(@session.current_url)
26
+ end
27
+
28
+ before(:each) do
29
+ Capybara.always_include_port = true
30
+ end
31
+
32
+ after(:each) do
33
+ Capybara.always_include_port = false
34
+ end
35
+
36
+ it "should fetch a response from the driver with an absolute url without a port" do
37
+ @session.visit("http://#{root_uri.host}/")
38
+ URI.parse(@session.current_url).port.should == root_uri.port
39
+ @session.body.should include('Hello world!')
40
+
41
+ @session.visit("http://#{root_uri.host}/foo")
42
+ URI.parse(@session.current_url).port.should == root_uri.port
43
+ @session.body.should include('Another World')
44
+ end
45
+ end
46
+
47
+ it "should send no referer when visiting a page" do
48
+ @session.visit '/get_referer'
49
+ @session.body.should include 'No referer'
50
+ end
51
+
52
+ it "should send no referer when visiting a second page" do
53
+ @session.visit '/get_referer'
54
+ @session.visit '/get_referer'
55
+ @session.body.should include 'No referer'
56
+ end
57
+
58
+ it "should send a referer when following a link" do
59
+ @session.visit '/referer_base'
60
+ @session.find('//a[@href="/get_referer"]').click
61
+ @session.body.should match %r{http://.*/referer_base}
62
+ end
63
+
64
+ it "should preserve the original referer URL when following a redirect" do
65
+ @session.visit('/referer_base')
66
+ @session.find('//a[@href="/redirect_to_get_referer"]').click
67
+ @session.body.should match %r{http://.*/referer_base}
68
+ end
69
+
70
+ it "should send a referer when submitting a form" do
71
+ @session.visit '/referer_base'
72
+ @session.find('//input').click
73
+ @session.body.should match %r{http://.*/referer_base}
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,33 @@
1
+ shared_examples_for "session with frame support" do
2
+ describe '#within_frame' do
3
+ before(:each) do
4
+ @session.visit('/within_frames')
5
+ end
6
+
7
+ it "should find the div in frameOne" do
8
+ @session.within_frame("frameOne") do
9
+ @session.find("//*[@id='divInFrameOne']").text.should eql 'This is the text of divInFrameOne'
10
+ end
11
+ end
12
+ it "should find the div in FrameTwo" do
13
+ @session.within_frame("frameTwo") do
14
+ @session.find("//*[@id='divInFrameTwo']").text.should eql 'This is the text of divInFrameTwo'
15
+ end
16
+ end
17
+ it "should find the text div in the main window after finding text in frameOne" do
18
+ @session.within_frame("frameOne") do
19
+ @session.find("//*[@id='divInFrameOne']").text.should eql 'This is the text of divInFrameOne'
20
+ end
21
+ @session.find("//*[@id='divInMainWindow']").text.should eql 'This is the text for divInMainWindow'
22
+ end
23
+ it "should find the text div in the main window after finding text in frameTwo" do
24
+ @session.within_frame("frameTwo") do
25
+ @session.find("//*[@id='divInFrameTwo']").text.should eql 'This is the text of divInFrameTwo'
26
+ end
27
+ @session.find("//*[@id='divInMainWindow']").text.should eql 'This is the text for divInMainWindow'
28
+ end
29
+ it "should return the result of executing the block" do
30
+ @session.within_frame("frameOne") { "return value" }.should eql "return value"
31
+ end
32
+ end
33
+ end
@@ -6,7 +6,7 @@ shared_examples_for "within" do
6
6
 
7
7
  context "with CSS selector" do
8
8
  it "should click links in the given scope" do
9
- @session.within(:css, "ul li[contains('With Simple HTML')]") do
9
+ @session.within(:css, "#for_bar li[contains('With Simple HTML')]") do
10
10
  @session.click_link('Go')
11
11
  end
12
12
  @session.body.should include('Bar')
@@ -20,7 +20,7 @@ shared_examples_for "within" do
20
20
  end
21
21
 
22
22
  it "should accept additional options" do
23
- @session.within(:css, "ul li", :text => 'With Simple HTML') do
23
+ @session.within(:css, "#for_bar li", :text => 'With Simple HTML') do
24
24
  @session.click_link('Go')
25
25
  end
26
26
  @session.body.should include('Bar')
@@ -29,7 +29,7 @@ shared_examples_for "within" do
29
29
 
30
30
  context "with XPath selector" do
31
31
  it "should click links in the given scope" do
32
- @session.within(:xpath, "//li[contains(.,'With Simple HTML')]") do
32
+ @session.within(:xpath, "//div[@id='for_bar']//li[contains(.,'With Simple HTML')]") do
33
33
  @session.click_link('Go')
34
34
  end
35
35
  @session.body.should include('Bar')
@@ -38,7 +38,7 @@ shared_examples_for "within" do
38
38
 
39
39
  context "with the default selector" do
40
40
  it "should use XPath" do
41
- @session.within("//li[contains(., 'With Simple HTML')]") do
41
+ @session.within("//div[@id='for_bar']//li[contains(.,'With Simple HTML')]") do
42
42
  @session.click_link('Go')
43
43
  end
44
44
  @session.body.should include('Bar')
@@ -47,9 +47,9 @@ shared_examples_for "within" do
47
47
 
48
48
  context "with Node rather than selector" do
49
49
  it "should click links in the given scope" do
50
- node_of_interest = @session.find(:css, "ul li[contains('With Simple HTML')]")
50
+ node_of_interest = @session.find(:css, "#for_bar li[contains('With Simple HTML')]")
51
51
 
52
- @session.within(node_of_interest) do
52
+ @session.within(node_of_interest) do
53
53
  @session.click_link('Go')
54
54
  end
55
55
  @session.body.should include('Bar')
@@ -59,7 +59,7 @@ shared_examples_for "within" do
59
59
  context "with the default selector set to CSS" do
60
60
  before { Capybara.default_selector = :css }
61
61
  it "should use CSS" do
62
- @session.within("ul li[contains('With Simple HTML')]") do
62
+ @session.within("#for_bar li[contains('With Simple HTML')]") do
63
63
  @session.click_link('Go')
64
64
  end
65
65
  @session.body.should include('Bar')
@@ -67,68 +67,57 @@ shared_examples_for "within" do
67
67
  after { Capybara.default_selector = :xpath }
68
68
  end
69
69
 
70
- context "with click_link" do
71
- it "should click links in the given scope" do
72
- @session.within("//li[contains(.,'With Simple HTML')]") do
73
- @session.click_link('Go')
74
- end
75
- @session.body.should include('Bar')
76
- end
77
-
78
- context "with nested scopes" do
79
- it "should respect the inner scope" do
80
- @session.within("//div[@id='for_bar']") do
81
- @session.within(".//li[contains(.,'Bar')]") do
82
- @session.click_link('Go')
83
- end
70
+ context "with nested scopes" do
71
+ it "should respect the inner scope" do
72
+ @session.within("//div[@id='for_bar']") do
73
+ @session.within(".//li[contains(.,'Bar')]") do
74
+ @session.click_link('Go')
84
75
  end
85
- @session.body.should include('Another World')
86
- end
87
-
88
- it "should respect the outer scope" do
89
- @session.within("//div[@id='another_foo']") do
90
- @session.within(".//li[contains(.,'With Simple HTML')]") do
91
- @session.click_link('Go')
92
- end
93
- end
94
- @session.body.should include('Hello world')
95
76
  end
77
+ @session.body.should include('Another World')
96
78
  end
97
79
 
98
- it "should raise an error if the scope is not found on the page" do
99
- running {
100
- @session.within("//div[@id='doesnotexist']") do
80
+ it "should respect the outer scope" do
81
+ @session.within("//div[@id='another_foo']") do
82
+ @session.within(".//li[contains(.,'With Simple HTML')]") do
83
+ @session.click_link('Go')
101
84
  end
102
- }.should raise_error(Capybara::ElementNotFound)
103
- end
104
-
105
- it "should restore the scope when an error is raised" do
106
- running {
107
- @session.within("//div[@id='for_bar']") do
108
- running {
109
- running {
110
- @session.within(".//div[@id='doesnotexist']") do
111
- end
112
- }.should raise_error(Capybara::ElementNotFound)
113
- }.should_not change { @session.has_xpath?(".//div[@id='another_foo']") }.from(false)
114
- end
115
- }.should_not change { @session.has_xpath?(".//div[@id='another_foo']") }.from(true)
85
+ end
86
+ @session.body.should include('Hello world')
116
87
  end
117
88
  end
118
89
 
119
- context "with forms" do
120
- it "should fill in a field and click a button" do
121
- @session.within("//li[contains(.,'Bar')]") do
122
- @session.click_button('Go')
90
+ it "should raise an error if the scope is not found on the page" do
91
+ running do
92
+ @session.within("//div[@id='doesnotexist']") do
123
93
  end
124
- extract_results(@session)['first_name'].should == 'Peter'
125
- @session.visit('/with_scope')
126
- @session.within("//li[contains(.,'Bar')]") do
127
- @session.fill_in('First Name', :with => 'Dagobert')
128
- @session.click_button('Go')
94
+ end.should raise_error(Capybara::ElementNotFound)
95
+ end
96
+
97
+ it "should restore the scope when an error is raised" do
98
+ running do
99
+ @session.within("//div[@id='for_bar']") do
100
+ running do
101
+ running do
102
+ @session.within(".//div[@id='doesnotexist']") do
103
+ end
104
+ end.should raise_error(Capybara::ElementNotFound)
105
+ end.should_not change { @session.has_xpath?(".//div[@id='another_foo']") }.from(false)
129
106
  end
130
- extract_results(@session)['first_name'].should == 'Dagobert'
107
+ end.should_not change { @session.has_xpath?(".//div[@id='another_foo']") }.from(true)
108
+ end
109
+
110
+ it "should fill in a field and click a button" do
111
+ @session.within("//li[contains(.,'Bar')]") do
112
+ @session.click_button('Go')
113
+ end
114
+ extract_results(@session)['first_name'].should == 'Peter'
115
+ @session.visit('/with_scope')
116
+ @session.within("//li[contains(.,'Bar')]") do
117
+ @session.fill_in('First Name', :with => 'Dagobert')
118
+ @session.click_button('Go')
131
119
  end
120
+ extract_results(@session)['first_name'].should == 'Dagobert'
132
121
  end
133
122
  end
134
123
 
@@ -0,0 +1,40 @@
1
+ shared_examples_for "session with window support" do
2
+ describe '#within_window' do
3
+ before(:each) do
4
+ @session.visit('/within_popups')
5
+ end
6
+ after(:each) do
7
+ @session.within_window("firstPopup") do
8
+ @session.evaluate_script('window.close()')
9
+ end
10
+ @session.within_window("secondPopup") do
11
+ @session.evaluate_script('window.close()')
12
+ end
13
+ end
14
+
15
+ it "should find the div in firstPopup" do
16
+ @session.within_window("firstPopup") do
17
+ @session.find("//*[@id='divInPopupOne']").text.should eql 'This is the text of divInPopupOne'
18
+ end
19
+ end
20
+ it "should find the div in secondPopup" do
21
+ @session.within_window("secondPopup") do
22
+ @session.find("//*[@id='divInPopupTwo']").text.should eql 'This is the text of divInPopupTwo'
23
+ end
24
+ end
25
+ it "should find the divs in both popups" do
26
+ @session.within_window("secondPopup") do
27
+ @session.find("//*[@id='divInPopupTwo']").text.should eql 'This is the text of divInPopupTwo'
28
+ end
29
+ @session.within_window("firstPopup") do
30
+ @session.find("//*[@id='divInPopupOne']").text.should eql 'This is the text of divInPopupOne'
31
+ end
32
+ end
33
+ it "should find the div in the main window after finding a div in a popup" do
34
+ @session.within_window("secondPopup") do
35
+ @session.find("//*[@id='divInPopupTwo']").text.should eql 'This is the text of divInPopupTwo'
36
+ end
37
+ @session.find("//*[@id='divInMainWindow']").text.should eql 'This is the text for divInMainWindow'
38
+ end
39
+ end
40
+ end