Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9133865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:33:35+00:00 2026-06-17T08:33:35+00:00

Here’s my complete spec: require ‘spec_helper’ describe Idea page, js: true do subject {

  • 0

Here’s my complete spec:

require 'spec_helper'

describe "Idea page", js: true do

  subject { page }

  before(:all) do
    create(:idea)
    visit root_path
    click_link "Log In"
  end

  context "Single idea" do
    before do
      page.find(:xpath, '//*[@id="accordion"]/div/div[1]/a').click
    end

    it { should have_selector('a',text:'Claim') }
    it "should have a button for reporting the idea"
    it "should have a button for opening all links"

    describe "Claiming" do
      before do
        click_link "Claim"
      end
      it {should have_selector('a', text:'Claimed')}
    end

  end
end

Without (:all) (i.e, when it’s just before in the first block), the browser opens, clicks on the Login link, goes to the right page, and clicks on the link. Nice.

But then it does it all over again before it tries clicking the second link (“Claim”), which is both time-consuming and error-prone. So I tried to fix this with before(:all).

But now, it just pops open Firefox, waits for a moment, and closes it again without doing anything. Test fails say:

Failures:

  1) Idea page Single idea 
     Failure/Error: page.find(:xpath, '//*[@id="accordion"]/div/div[1]/a').click
     Capybara::ElementNotFound:
       Unable to find xpath "//*[@id=\"accordion\"]/div/div[1]/a"
     # ./spec/features/ideas_spec.rb:15:in `block (3 levels) in <top (required)>'

  2) Idea page Single idea Claiming 
     Failure/Error: page.find(:xpath, '//*[@id="accordion"]/div/div[1]/a').click
     Capybara::ElementNotFound:
       Unable to find xpath "//*[@id=\"accordion\"]/div/div[1]/a"
     # ./spec/features/ideas_spec.rb:15:in `block (3 levels) in <top (required)>'

Obviously, since the browser page was blank.

What am I missing? Thank you.

Edit: Maybe there’s something basic I don’t understand. With before(:each) here’s what the test tries to do:

1) Log in to the webapp, make sure there’s a ‘Claim’ button.

2) Log in to the webapp again, open the accordion again, and now click that ‘Claim` button to see what’s going to happen.

So the beginning of every step is exactly the same, the browser doing the same thing again and again. Is that how it’s supposed to be?

If so, why do I get errors when I do this? Specifically, with before(:each) I get this:

Failures:

  1) Idea page Single idea Claiming 
     Failure/Error: it {should have_selector('a', text:'Claimed')}
     Selenium::WebDriver::Error::UnhandledAlertError:
       Modal dialog present
     # [remote server] file:///tmp/webdriver-profile20130116-3734-lw7267/extensions/fxdriver@googlecode.com/components/command_processor.js:10287:in `nsCommandProcessor.execute'
     # [remote server] file:///tmp/webdriver-profile20130116-3734-lw7267/extensions/fxdriver@googlecode.com/components/driver_component.js:7328:in `Dispatcher.executeAs/<'
     # [remote server] file:///tmp/webdriver-profile20130116-3734-lw7267/extensions/fxdriver@googlecode.com/components/driver_component.js:7488:in `Resource.handle'
     # [remote server] file:///tmp/webdriver-profile20130116-3734-lw7267/extensions/fxdriver@googlecode.com/components/driver_component.js:7435:in `Dispatcher.dispatch'
     # [remote server] file:///tmp/webdriver-profile20130116-3734-lw7267/extensions/fxdriver@googlecode.com/components/driver_component.js:10119:in `WebDriverServer/<.handle'
     # [remote server] file:///tmp/webdriver-profile20130116-3734-lw7267/extensions/fxdriver@googlecode.com/components/httpd.js:1935:in `unknown'
     # [remote server] file:///tmp/webdriver-profile20130116-3734-lw7267/extensions/fxdriver@googlecode.com/components/httpd.js:2261:in `ServerHandler.handleResponse'
     # [remote server] file:///tmp/webdriver-profile20130116-3734-lw7267/extensions/fxdriver@googlecode.com/components/httpd.js:1168:in `Connection.process'
     # [remote server] file:///tmp/webdriver-profile20130116-3734-lw7267/extensions/fxdriver@googlecode.com/components/httpd.js:1616:in `RequestReader._handleResponse'
     # [remote server] file:///tmp/webdriver-profile20130116-3734-lw7267/extensions/fxdriver@googlecode.com/components/httpd.js:1464:in `RequestReader._processBody'
     # [remote server] file:///tmp/webdriver-profile20130116-3734-lw7267/extensions/fxdriver@googlecode.com/components/httpd.js:1333:in `RequestReader.onInputStreamReady'
     # ./spec/features/ideas_spec.rb:26:in `block (4 levels) in <top (required)>'

Even though I see the browser clicking the button, turning it to “Claimed”, and there is no modal dialog shown.

Edit 2: I stand corrected! There was a modal dialog there after all! I fixed the JS to stop showing it, and the test now passes. I still think it’s weird that the framework has to repeat the whole sequence from scratch every step (seems like a waste of work), but whatever. Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:33:36+00:00Added an answer on June 17, 2026 at 8:33 am

    This is because the test data, including the capybara session data (such as logged-in state) and the model created by create(:idea) are wiped out between specs.

    You want to go with before(:each) not :all, even though it is more time consuming.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`
Here is my SQL script CREATE TABLE tracks( track_id int NOT NULL AUTO_INCREMENT, account_id
Basically, what I'm trying to create is a page of div tags, each has
Here is the final result of what my page is(not much fancy stuff yet):
Here is my problem.. I have the option to create(add) two new input fields,
Here the scenario is I have many .aspx pages if any page gives error,
Here's the problem....I have three components...A Page that contains a User Control and a
Here's my code: // Not all headers are relevant to the code snippet. #include
here is my code, SiteMember class @OneToMany(mappedBy = member,cascade=CascadeType.ALL) private List<MemberThread> memberThread = new
Here's the view: @if (stream.StreamSourceId == 1) { <img class=source src=@Url.Content(~/Public/assets/images/own3dlogo.png) alt= /> }

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.