2

I am wondering if page object is really fast. Lets say I define 10 or 20 elements in a page object class. I don't use it regularly. At any given time, I use only 2 3 elements or actions, all elements are used only for few workflow cases.

So I am wondering if Page object gives any performance advantage over using a single element usage without page object.

Does Page object assist in using cache to find all elements at one go, if you invoke it even once to do an action on one element?

1
  • With the Page Object Model, each element is only found when you use it. If you're using Page Factory, which has some sort of FindBy annotation in the different bindings, the object just gets initialized when the Page Object is created. It doesn't actually try to find the element for use until you use it. in short, that's not going to have much, if any impact on your performance.
    – mrfreester
    Mar 25, 2019 at 17:09

1 Answer 1

1

Any performance difference would be negligible.

If it tried to find each element at once, that would be an issue, but it will only try to find it the moment you try to use it unless you're not following a typical pattern.

One thing to note, it will try to lookup the element every single time you do something with it. If you have some selectors that are slow for some reason, or you are really trying to get the best possible performance, you can consider using @CacheLookup.

This is a good reference for learning how to use cache lookup and when elements are found. I think it should be something available in most selenium bindings. You may need to research how to do that for the language you are interested in.

Your Answer

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

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