Sha256: a91db78f7c597035bbac85d81a311f9a2026ca83f61aa0879a84fa90336e47ec

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

module FindSpec
  shared_examples_for "find" do  
    describe '#find' do
      before do
        @session.visit('/with_html')
      end

      it "should find the first element using the given locator" do
        @session.find('//h1').text.should == 'This is a test'
        @session.find("//input[@id='test_field']")[:value].should == 'monkey'
      end

      it "should return nil when nothing was found" do
        @session.find('//div[@id="nosuchthing"]').should be_nil
      end

      it "should accept an XPath instance and respect the order of paths" do
        @session.visit('/form')
        @xpath = Capybara::XPath.text_field('Name')
        @session.find(@xpath).value.should == 'John Smith'
      end

      context "within a scope" do
        before do
          @session.visit('/with_scope')
        end

        it "should find the first element using the given locator" do
          @session.within(:xpath, "//div[@id='for_bar']") do
            @session.find('//li').text.should =~ /With Simple HTML/
          end
        end
      end
    end
  end
end  

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capybara-0.3.0 spec/dsl/find_spec.rb