I am a new test engineer and have been reading about Page Object Model and implementing them and keep coming across Page Factory. I understand that Page Factory is a POM tha
Why do I want to instantiate all the elements instead of doing it on the fly?
If I remember correctly, PageFactory scans for any WebElement properties/fields and their attributes and wraps them with a proxy. At that point you're not touching Selenium server yet (you can check this in server console output). Once you try to access the property the WebElement gets instantiated. So if you only accessed one PO property/field only for that one WebElement is created.
What are the advantages of Page Factory that I'm missing?
The use of attributes make the code much more readable and also easy to generate. It is common to create a tool that generates PageObjects for you.
PageFactory was created to support PageObject pattern, nothing more. You don't have to necessarily use it in order to go PO way.
Finally, if you're curious about how it works in detail, I'd suggest you check the source code. It's what I did when I was just starting with Selenium.