So I am debating a bit on whether it makes sense to have a sort of isLoaded or similar method in a page object. I know there is some debate on having assertions in page objects (Most say no, some say yes) but I guess that's not what my question is necessarily about.

I think classes like LoadableComponent were built in selenium to reduce flakiness (which makes sense) but with newer frameworks having auto-waiting functionality/etc... that makes less sense to use.

My question I suppose is if it makes sense to have a function (say isLoaded) that purely acts as an assertion method on the key elements of a page and less of a flakiness band-aid. Sort of a method you can call to ensure that page "generally" looks and has the elements you need (Without using visual regression or anything heavier).

However when I think about something like this, you would only ever want to call it once right? Since there isn't a need to do multiple assertions on the same thing you've asserted. In that case does it make more sense to just have a test case that runs multiple assertions on key elements of a page?

Hopefully what im asking makes sense, and im curious if people have something similar in newer frameworks (like Playwright/Selenium) where we don't rely on an isLoaded type method to combat flakiness.

1 Answer 1


I've gone back and forth on this myself. Not necessarily with isLoaded but with URL validation or page readiness (see browsingContext().

Overall, I think it's good to do. Where do you add this? Commonly, I'll do a URL validation in the POM constructor. If it fails, great, you know early!

Alternatively, you can add these types of checks in the beforeAll() or the before() test methods.

A third option would be to create a helper method to check for these validations, which you'd call in either the constructor or beforeAll() or the before() test methods. This would cut down on the amount of code written.

Either way, as long as it's readable, in context with your test, doing these validations early to bail on failure is a proper methodology.

If I were doing a code review and saw these types of validations in the POM, but in a general method, I'd have an objection and recommendation to move it to either the constructor or beforeAll() or the before() test methods.

  • The problem with adding it in the constructor for me is it relies you to create the instance objects when the page is there. Which I guess "makes sense" but generally in our tests we just create all the const instance objects at the top. I have thought about making it a utility method that I pass locators into that it loops through and checks visibility. Im curious how this would work in a before hook though? I guess unless all tests went to the same URL in the test block
    – Mercfh
    Commented May 6 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.