File: within_frame_spec.rb

package info (click to toggle)
ruby-capybara 2.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 948 kB
  • ctags: 516
  • sloc: ruby: 7,998; makefile: 4
file content (52 lines) | stat: -rw-r--r-- 2,116 bytes parent folder | download | duplicates (2)
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
Capybara::SpecHelper.spec '#within_frame', :requires => [:frames] do
  before(:each) do
    @session.visit('/within_frames')
  end

  it "should find the div in frameOne" do
    @session.within_frame("frameOne") do
      @session.find("//*[@id='divInFrameOne']").text.should eql 'This is the text of divInFrameOne'
    end
  end
  it "should find the div in FrameTwo" do
    @session.within_frame("frameTwo") do
      @session.find("//*[@id='divInFrameTwo']").text.should eql 'This is the text of divInFrameTwo'
    end
  end
  it "should find the text div in the main window after finding text in frameOne" do
    @session.within_frame("frameOne") do
      @session.find("//*[@id='divInFrameOne']").text.should eql 'This is the text of divInFrameOne'
    end
    @session.find("//*[@id='divInMainWindow']").text.should eql 'This is the text for divInMainWindow'
  end
  it "should find the text div in the main window after finding text in frameTwo" do
    @session.within_frame("frameTwo") do
      @session.find("//*[@id='divInFrameTwo']").text.should eql 'This is the text of divInFrameTwo'
    end
    @session.find("//*[@id='divInMainWindow']").text.should eql 'This is the text for divInMainWindow'
  end
  it "should return the result of executing the block" do
    @session.within_frame("frameOne") { "return value" }.should eql "return value"
  end
  it "should find the div given Element" do
    element = @session.find(:id, 'frameOne')
    @session.within_frame element do
      @session.find("//*[@id='divInFrameOne']").text.should eql 'This is the text of divInFrameOne'
    end
  end
  it "should find multiple nested frames" do
    @session.within_frame 'parentFrame' do
      @session.within_frame 'childFrame' do
        @session.within_frame 'grandchildFrame1' do end
        @session.within_frame 'grandchildFrame2' do end
      end    
    end
  end
  it "should reset scope when changing frames" do
    @session.within(:css, '#divInMainWindow') do
      @session.within_frame 'parentFrame' do
        @session.has_selector?(:css, "iframe#childFrame").should be_true
      end
    end
  end
end