
Do you use Page Object in your project? Suppose I want to add a new object to the object repository. How will I add that?
What is an Object Repository?
An object repository is a centralised place where you store and manage locators (like XPath, ID, CSS selectors) of web elements. It allows easier updates and reuse of elements across tests.
In our framework, we use a Page Object Model (POM) structure where each web page has its own class file representing the page's elements and actions.
To add a new field or element to the object repository:
- I identify the web element using browser developer tools (Inspect element).
- Then I create a new WebElement in the corresponding page class using
@FindByordriver.findElement()with an appropriate locator (like ID, XPath, or CSS). - I also add a method to interact with that element — for example, to input text or click a button.
This way, our object repository remains organized, and if the locator changes later, we only need to update it in one place.
To add a new field to the object repository, I first inspect the web element and identify a reliable locator. Then I update the relevant page object class by adding a new WebElement or entry, depending on whether we use Page Object Model or external files like .properties. This ensures centralized and reusable access to the element.
What is the difference between a single slash (/) and a double slash (//) in XPath?
single slash / is used to define an absolute path starting from the root node of the HTML. it goes to direct child in DOM tree.
For example, /html/body/div/input will select the element only if it matches that exact hierarchy.
double slash // is used for relative paths, allowing you to find an element anywhere in the DOM. it navigate to distant child in DOM tree
For example, //input[@id='email'] will find the input with id 'email' no matter where it is in the document.
In Selenium, we mostly use combination of relative and absolute both.
What are the different TestNG annotations, and what is their execution order?
TestNG provides various annotations that help control the flow of test execution.
The most commonly used ones are:
@BeforeSuite,@BeforeTest, and@BeforeClass— used for setup activities like initialising drivers or test data.@BeforeMethodruns before each@Test, often used for opening the browser or navigating to a page.@Testis the actual test case.@AfterMethodis used to clean up after each test, like closing pop-ups or logging out.@AfterClass,@AfterTest, and@AfterSuiteare for teardown — like closing browsers, releasing resources, or generating reports.
Sequence will look like
BeforeSuite - BeforeTest - BeforeClass - BeforeMethod - Test - AfterMethod - AfterClass - AfterTest - AfterSuite
The execution order starts from @BeforeSuite and ends at @AfterSuite. Using these annotations ensures our tests are well-structured, maintainable, and easy to debug.
Can you explain how Jenkins works in your project? How are you executing your automation framework in Jenkins?
Jenkins is an open-source automation server used to build, test, and deploy software continuously. It plays a crucial role in Continuous Integration and Continuous Delivery (CI/CD) pipelines.
In the context of automation testing, we use Jenkins to automatically trigger our test scripts whenever code is pushed to the repository. For example, when a developer commits code to Git, Jenkins pulls the latest code, builds the project using tools like Maven or Gradle, and runs automated tests, both UI and API.
We've configured Jenkins to run Selenium tests via Maven using a JenkinsFile or freestyle project. After execution, test reports like Extent Reports or Allure Reports are published and shared with the team.
I’ve also set up Jenkins jobs to run on schedule (e.g., nightly regression), configured email notifications for test results, and integrated it with GitHub and Slack for team visibility.
Jenkins helps catch issues early, ensures code quality, and allows us to maintain faster release cycles.
How do you handle alerts in Selenium?
To handle JavaScript alerts in Selenium, I use the Alert interface.
First, I switch the driver's context to the alert using
- use
accept()to click OK. For confirmation alerts, - use
dismiss()to click Cancel. - For prompt alerts, I use
sendKeys()to enter text before accepting. - For getText from alert, I use getText() method.
I also wrap alert handling with WebDriverWait using ExpectedConditions.alertIsPresent() to ensure stability in case the alert takes time to appear.
Suppose I have a file. I want to upload that file in our server. What will be process we will use for this ?
If Element File Type is file
To handle file upload buttons in Selenium, I first check if the input element has type='file'.
If it does, I use the sendKeys() method to directly pass the file path, like:
Native OS Dialog
If the file upload opens a native OS dialog, I use Java’s Robot class to simulate keyboard actions like pasting the path and pressing Enter. In some cases, I’ve also used AutoIt scripts when interacting with complex upload windows that Robot couldn’t handle reliably.
What is polymorphism, and how is it applied in Selenium?
Polymorphism is an OOP concept where a method or object can take many forms.
In Selenium, we apply runtime polymorphism (Method Overriding) using the WebDriver interface. For example:
Here, WebDriver is an interface and ChromeDriver is a class that implements it. We can later replace ChromeDriver with FirefoxDriver or EdgeDriver without changing our test logic.
We also use method overloading in our framework to create reusable utility functions with the same method name but different parameters – that's compile-time polymorphism.
These principles help us write more flexible and maintainable automation code.
Can you describe your current project and explain its main components?
Currently, I’m working on a web-based insurance application that allows users to buy, renew, and manage their insurance policies online. It has modules like
- user registration
- policy management
- payments
- claims processing
- admin dashboards
The front end is built with React, and the backend is powered by Java Spring Boot APIs with MySQL as the database. All APIs are documented using Swagger, and we use Postman for initial testing.
From the QA side, we have both manual and automation processes. I work mainly on the UI automation using Selenium WebDriver with Java, and the framework is built on TestNG with Maven. We're also covering API automation using Rest Assured.
We run our tests in Jenkins as part of the CI/CD pipeline, and reports are generated using Extent Reports. Version control is done through Git, and we use JIRA for test and defect management.
I’ve contributed to designing and maintaining the automation framework, writing reusable methods, creating scripts for regression and smoke suites, and integrating test execution into Jenkins pipelines.
Note:
Banking Project – Mention modules like fund transfers, transactions, authentication, dashboards.
E-commerce Project – Mention cart, checkout, payments, inventory, user profiles.
Healthcare Project – Mention patient portals, appointment systems, medical records.
Please explain your automation framework?
In my current project, we are using a Hybrid Automation Framework built using Selenium WebDriver with Java, integrated with TestNG for test execution and Maven for build management.
The framework supports both data-driven and modular approaches. We use Apache POI for reading test data from Excel files, and our test scripts are written using Page Object Model (POM) to maintain scalability and reusability.
For reporting, we have integrated Extent Reports, and for CI/CD, our framework runs on Jenkins with triggers on every code commit.
In terms of my role, I was responsible for enhancing the framework by adding reusable utilities, writing new test scripts, maintaining the
object repository, and setting up parallel execution using TestNG XML.
We also used Git for version control and Allure reports in some modules to better visualize test results."
Can you explain the purpose of the Robot class in Selenium?
The Robot class in Java is used in Selenium when we need to simulate low-level keyboard and mouse events that Selenium WebDriver alone cannot handle.
It comes from the java.awt package and is especially useful for scenarios like:
Use Cases:
- Handling OS-level pop-ups or dialogs
- (e.g., File Upload/Download windows that are outside the browser DOM)
- Simulating keyboard events
- (e.g., pressing
Enter,Tab,Ctrl+C, etc.) - Mouse movements and clicks
- (for custom mouse operations)
Example: Handling File Upload Window
This sequence simulates pasting a file path into an OS file upload dialog and pressing Enter.
Why Robot Class?
- Selenium interacts with web elements in the DOM.
Robotis helpful when we need to interact with non-DOM-based components, like native OS windows.
Why is Page Factory used in object repositories?
Page Factory is used in Selenium to implement the Page Object Model (POM) in a more efficient and readable way. It helps manage object repositories by initializing web elements using annotations, making the code cleaner and easier to maintain.
Key Reasons for Using Page Factory:
Improves Readability and Maintainability:
You define all elements at the top of the class using @FindBy, separating the element locators from the test logic.
Efficient Object Initialization:
Page Factory uses initElements() method to initialize all @FindBy annotated elements when the page class is instantiated.
Reduces Boilerplate Code:
No need to repeatedly use driver.findElement(); Page Factory handles it automatically.
Supports Lazy Initialization (with AjaxElementLocatorFactory):
It waits until the element is actually used in the code, which is helpful in dynamic or AJAX-heavy pages
So as summary, Page Factory is a clean and efficient way to organize element locators and is especially helpful in large projects for making object repositories modular and reusable.
How do you launch Internet Explorer in Selenium WebDriver?
To launch Internet Explorer in Selenium WebDriver, I use the InternetExplorerDriver class. Here are the steps I follow:
- Download the IE Driver Server from the official Selenium website, and ensure the version (32-bit or 64-bit) matches the installed IE browser.
- Set the system property in my Java code to specify the path of the
IEDriverServer.exe. - Create an instance of
InternetExplorerDriverand use it like any other WebDriver.
- I also ensure required IE settings are in place:
- Protected mode settings must be the same for all zones.
- Zoom level should be set to 100%.
- IE Enhanced Security Configuration should be turned off.
I typically avoid using IE unless required, as it's deprecated and less stable. In most modern projects, I prefer using Chrome, Edge, or Firefox.
How do you use the Select class in Selenium for handling dropdowns?
How to Use the Select Class in Selenium (Java)
Approach of Select:
- Identify the
<select>element using a locator (e.g.,By.id,By.name). - Create a
Selectobject by passing theWebElement. - Use available methods to select or deselect options.
Example:
Could you write a program for taking a screenshot in Selenium?

