Selenium Automation Framework Page Object Modal Hybrid
Automation Framework Architecture
1. What automation framework are you using?
Hybrid Framework built with Selenium WebDriver + Java + TestNG + Maven. It follows Page Object Model (POM) to separate test logic from page elements. Integrates configuration readers, reusable helpers, and Extent Reports. The design ensures scalability and maintainability as the application grows.
2. Explain your framework architecture
Layered architecture:
- Test Scripts – actual test cases (TestNG).
- Page Classes – locators + page actions (POM).
- Utility Classes – waits, screenshots, browser setup, Excel helpers.
- Configuration Files –
config.properties(URL, browser, timeouts). - Test Data – external Excel/JSON files.
This separation keeps code organized, maintainable, and environment‑flexible.
3. Why did you choose Page Object Model (POM)?
POM improves maintainability and readability. Each web page is a separate class containing its locators and methods. Test logic is separated from element definitions, reducing code duplication. If a locator changes, update only one class — not dozens of tests.
4. POM vs Page Factory
Both keep tests clean; Page Factory reduces locator code.
5. Disadvantages of POM?
- Many page classes → project complexity.
- If not well structured, page classes become huge and hard to manage.
- Requires extra design effort for small applications.
6. What is a Hybrid Framework?
Combines multiple approaches: Data‑Driven + Keyword‑Driven + POM. Test data stored externally (Excel/JSON), keywords for actions, and page objects for elements. Offers flexibility, scalability, and easier maintenance – standard in enterprise projects.
7. Where do you keep Locators?
Inside Page Object classes. Each page class contains all locators (By.xpath, By.id) for that page. Centralised → one change only.
public class LoginPage {
By username = By.id("username");
By password = By.id("password");
By loginBtn = By.id("loginBtn");
}
8. Where do you keep Test Data?
External files: Excel (.xlsx), JSON, CSV, or databases. Enables data‑driven testing without modifying test logic.
9. Where do you keep Config Files?
config.properties file (or YAML). Contains environment‑specific values:
url=https://example.com
timeout=10
No hardcoding → run in dev/qa/prod without code changes.
10. How do you handle environment-specific configurations?
Use multiple config files (e.g., dev.properties, qa.properties) or profiles. At runtime, load the appropriate file based on a system property or parameter. Same scripts, different environments.
11. How do you read data from Excel?
Using Apache POI library.
Workbook wb = new XSSFWorkbook(file);
Sheet sheet = wb.getSheet("LoginData");
Row row = sheet.getRow(0);
Cell cell = row.getCell(0);
String value = cell.getStringCellValue();
Commonly used for data‑driven testing.
12. How do you read data from a Properties file?
Java Properties class + FileInputStream.
FileInputStream file = new FileInputStream("config.properties");
prop.load(file);
String url = prop.getProperty("url");
13. How do you read data from JSON?
Using Jackson or JSON‑simple.
Object obj = parser.parse(new FileReader("data.json"));
JSONObject json = (JSONObject) obj;
String username = (String) json.get("username");
Ideal for complex test data structures.
14. How do you pass test data dynamically?
TestNG DataProvider – feeds multiple datasets to the same test.
public Object[][] getData() {
return new Object[][] {{"user1","pass1"},{"user2","pass2"}};
}
@Test(dataProvider="loginData")
public void testLogin(String user, String pass) { ... }
Also combine with external files for truly dynamic execution.
15. How do you avoid hardcoding values?
Store all variable data externally: config files, Excel, JSON, or environment variables. Framework reads values at runtime. Example: URL comes from config.properties, not from the test script. This makes tests portable and maintainable.
// driver.get("http://dev.example.com");
// Use:
String url = prop.getProperty("url");
driver.get(url);
Comments
Post a Comment