What I think is that this involves the lazy loading mechanism, where the loading of the page factory WebElements are deferred till it's required.
Now if this is the cases then what's the need of PageFactory.initElements
?
And in the situation where we have a button in the webpage that has id='button'
and name='save'
, and we use page factory to initialize the element to click the button(we use only the id='button'
for identifying the element).
After that the button vanishes and a new button comes up having id='button'
and name='add'
. Can I use the same WebElement used earlier to click on it? Because even though the location strategy is same, the attribute name has changed.