Sha256: 5a8c950f526a8c65b054d7e7e3c9de8ccb60c79c225b4dfc7367d5c9d5282a9c

Contents?: true

Size: 895 Bytes

Versions: 17

Compression:

Stored size: 895 Bytes

Contents

Capybara::SpecHelper.spec '#find_by_id' do
  before do
    @session.visit('/with_html')
  end

  it "should find any element by id" do
    expect(@session.find_by_id('red').tag_name).to eq('a')
  end

  it "casts to string" do
    expect(@session.find_by_id(:'red').tag_name).to eq('a')
  end

  it "should raise error if no element with id is found" do
    expect do
      @session.find_by_id('nothing_with_this_id')
    end.to raise_error(Capybara::ElementNotFound)
  end

  context "with :visible option" do
    it "finds invisible elements when `false`" do
      expect(@session.find_by_id("hidden_via_ancestor", :visible => false).text(:all)).to match(/with hidden ancestor/)
    end

    it "finds invisible elements when `false`" do
      expect do
        @session.find_by_id("hidden_via_ancestor", :visible => true)
      end.to raise_error(Capybara::ElementNotFound)
    end
  end
end

Version data entries

17 entries across 17 versions & 4 rubygems

Version Path
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/capybara-2.4.4/lib/capybara/spec/session/find_by_id_spec.rb
capybara-2.6.2 lib/capybara/spec/session/find_by_id_spec.rb
capybara-2.6.1 lib/capybara/spec/session/find_by_id_spec.rb
capybara-2.6.0 lib/capybara/spec/session/find_by_id_spec.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/capybara-2.4.4/lib/capybara/spec/session/find_by_id_spec.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/capybara-2.4.4/lib/capybara/spec/session/find_by_id_spec.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/capybara-2.4.4/lib/capybara/spec/session/find_by_id_spec.rb
capybara-2.5.0 lib/capybara/spec/session/find_by_id_spec.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/capybara-2.4.4/lib/capybara/spec/session/find_by_id_spec.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/capybara-2.4.4/lib/capybara/spec/session/find_by_id_spec.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/capybara-2.4.4/lib/capybara/spec/session/find_by_id_spec.rb
capybara-2.4.4 lib/capybara/spec/session/find_by_id_spec.rb
capybara-2.4.3 lib/capybara/spec/session/find_by_id_spec.rb
capybara-2.4.2 lib/capybara/spec/session/find_by_id_spec.rb
capybara-2.4.1 lib/capybara/spec/session/find_by_id_spec.rb
capybara-2.4.0 lib/capybara/spec/session/find_by_id_spec.rb
capybara-2.3.0 lib/capybara/spec/session/find_by_id_spec.rb