Giter Site home page Giter Site logo

Comments (7)

andyw8 avatar andyw8 commented on September 6, 2024

(edited the original post to correct a few things)

from site_prism.

tmertens avatar tmertens commented on September 6, 2024

@andyw8 Your implementation looks correct. You must explicitly specify which page you are interacting with.

from site_prism.

andyw8 avatar andyw8 commented on September 6, 2024

Ok. So how do I avoid using a page model which potentially doesn't correspond to the page that was actually rendered? Should I be checking displayed? before calling load in each place where I expect to be redirected?

from site_prism.

tmertens avatar tmertens commented on September 6, 2024

Can you give me an example? I'm not sure I understand how you could
'potentially' use a page model different than the page expected. If you are
writing tests, you should know in advance what page you will be landing on
after performing some action.

e.g. If I click the 'Login' link on the home page, I expect to be
redirected to the login page and hence I know to a LoginPage object for
interactions corresponding to the Login page.

Can you provide a simple example of where this fails for you?

On Fri, Oct 11, 2013 at 3:18 PM, Andy Waite [email protected]:

Ok. So how do you avoid using a page model which potentially doesn't
correspond to the actual page being rendered? Should I be checking
displayed? before calling load in each place where I expect to be
redirected?


Reply to this email directly or view it on GitHubhttps://github.com//issues/51#issuecomment-26168973
.

from site_prism.

tmertens avatar tmertens commented on September 6, 2024

I should add that if you are expecting to be redirected by some action
(e.g. home_page.login_link.click ), you shouldn't be calling
'LoginPage#load' at all as it will override the login_link click redirect
action and simply tell Capybara to load the login page's URL as specified
in the LoginPage class rather than following the actual redirect from the
click.

e.g. assuming we have HomePage and LoginPage classes:

let(:home_page) { HomePage.new }
let(:login_page) { LoginPage.new }

context "Login Link"
  scenario "redirects to the login page"
    home_page.load
    expect(home_page).to be_displayed
    home_page.login_link.click
    expect(login_page).to be_displayed
  end
end

On Fri, Oct 11, 2013 at 3:25 PM, Tim M [email protected] wrote:

Can you give me an example? I'm not sure I understand how you could
'potentially' use a page model different than the page expected. If you are
writing tests, you should know in advance what page you will be landing on
after performing some action.

e.g. If I click the 'Login' link on the home page, I expect to be
redirected to the login page and hence I know to a LoginPage object for
interactions corresponding to the Login page.

Can you provide a simple example of where this fails for you?

On Fri, Oct 11, 2013 at 3:18 PM, Andy Waite [email protected]:

Ok. So how do you avoid using a page model which potentially doesn't
correspond to the actual page being rendered? Should I be checking
displayed? before calling load in each place where I expect to be
redirected?


Reply to this email directly or view it on GitHubhttps://github.com//issues/51#issuecomment-26168973
.

from site_prism.

andyw8 avatar andyw8 commented on September 6, 2024

Got it! Wasn't obvious from the README, I'll send a PR to add that info if I have a chance.

from site_prism.

natritmeyer avatar natritmeyer commented on September 6, 2024

@andyw8 happy for me to close this? Good to hear from you again :)

from site_prism.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.