Recall & Review
beginner
What is PageFactory in Selenium?
PageFactory is a class in Selenium that helps initialize web elements defined in a Page Object Model class, making tests easier to read and maintain.Click to reveal answer
beginner
How do you initialize web elements using PageFactory in Java?
You call <code>PageFactory.initElements(driver, this);</code> inside the constructor of your page class to initialize all @FindBy annotated elements.Click to reveal answer
beginner
What is the purpose of the
@FindBy annotation?It tells Selenium how to locate a web element on the page, such as by id, name, xpath, or css.
Click to reveal answer
intermediate
Why is PageFactory initialization preferred over traditional element locating?
PageFactory initializes elements only when they are used, improving performance and making the code cleaner and easier to maintain.
Click to reveal answer
beginner
What happens if you forget to call
PageFactory.initElements() in your page class?The web elements will not be initialized, causing NullPointerException when you try to interact with them.
Click to reveal answer
Which method is used to initialize web elements with PageFactory in Selenium Java?
✗ Incorrect
PageFactory.initElements(driver, this) initializes all @FindBy annotated elements in the page class.
What annotation is used to locate elements in PageFactory?
✗ Incorrect
@FindBy annotation specifies how to find the element on the page.
What will happen if you try to use a web element without initializing PageFactory?
✗ Incorrect
Without initialization, the element reference is null, causing NullPointerException.
PageFactory initialization improves test code by:
✗ Incorrect
PageFactory initializes elements only when used and makes code cleaner.
Which of the following is NOT a valid locator strategy with @FindBy?
✗ Incorrect
There is no 'color' locator strategy in Selenium @FindBy.
Explain how PageFactory initialization works in Selenium and why it is useful.
Think about how PageFactory connects your page class fields to actual web elements.
You got /4 concepts.
Describe the steps to create a Page Object class using PageFactory in Selenium Java.
Focus on annotations, constructor, and usage.
You got /3 concepts.