81. What are dependencies and how are they handled in Maven?
Dependencies are external libraries required by a project. In Maven, they are specified in the pom.xml file, and Maven automatically downloads and includes them during the build process.
82. What is POM.xml?
The pom.xml (Project Object Model) file is the core of a Maven project. It contains information about the project, its dependencies, build configuration, and plugins.
83. What Maven plugins do you use?
- maven-surefire-plugin: Runs unit tests
- maven-compiler-plugin: Compiles Java source code
- maven-clean-plugin: Cleans up the target directory
84. How to execute TestNG.xml using Maven?
Configure the maven-surefire-plugin in the pom.xml and run the following command:
bash
mvn test
This will execute the tests defined in the testng.xml file.
85. What is Jenkins?
Jenkins is an open-source automation server that facilitates continuous integration and continuous delivery (CI/CD) by automating the building, testing, and deployment of applications.
86. What is the role of Jenkins in your framework?
Jenkins automates the execution of test suites, integrates with version control systems like GitHub, and triggers builds upon code commits, ensuring continuous testing and integration.
87. What are the advantages of Jenkins?
- Automates repetitive tasks
- Supports a wide range of plugins
- Facilitates continuous integration and delivery
- Provides real-time feedback on builds and tests
88. How to configure Jenkins?
- Install Jenkins and required plugins
- Create a new job or pipeline
- Configure source code repository (e.g., GitHub)
- Set build triggers and steps
- Save and run the job to initiate builds
89. Difference between XPath and CSS Selector?
Feature | XPath | CSS Selector |
Syntax | Complex | Simpler |
Direction | Supports both forward and backward | Only forward |
Performance | Slower | Faster |
Browser Support | Limited in older browsers | Widely supported |
90. Where is a constructor used in Selenium?
In Selenium, constructors are used in the Page Object Model (POM) to initialize web elements using PageFactory and to pass the WebDriver instance to page classes.
91. How to execute JavaScript or scroll in Selenium?
java
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript(“window.scrollBy(0,300)”);
92. How to handle SSL popup in IE?
Set the desired capabilities to accept SSL certificates
java
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
93. Non-automatable test cases in your project?
- CAPTCHA verification
- Barcode scanning
- Visual aesthetics and color validations
- Usability and exploratory testing
96. Explain the Selenium Architecture
Answer:
Selenium follows a three-tier architecture that consists of:
1. Selenium Client Libraries (Language Bindings)
Selenium supports multiple languages like Java, Python, C#, Ruby, JavaScript, etc. Developers use these bindings to write test scripts in their preferred language.
2. JSON Wire Protocol:
This is a transport mechanism used by Selenium WebDriver to communicate between the client libraries and the browser drivers. It defines a RESTful API for automation commands such as click, navigate, sendKeys, etc.
3. Browser Drivers:
Each browser (Chrome, Firefox, Edge, Safari) has its own driver:
- ChromeDriver for Chrome
- GeckoDriver for Firefox
- IEDriverServer for Internet Explorer
- EdgeDriver for Microsoft Edge
These drivers act as a bridge between Selenium and the actual browser, executing the commands sent from test scripts.
4. Real Browser:
The actual browser where the test actions are performed based on the instructions received via the browser driver.
Selenium Architecture Flow:
- Test script → Selenium bindings
- Selenium bindings → JSON Wire Protocol
- JSON → Browser Driver
- Driver → Executes in the browser
97. Difference between Selenium IDE, Selenium RC, and Selenium WebDriver
Feature | Selenium IDE | Selenium RC | Selenium WebDriver |
Type | Record & playback tool | Server-based tool | Programming interface (API) |
Language Support | No (only Selenese) | Yes | Yes |
Browser Interaction | Works only with Firefox | Works via RC server | Direct browser communication |
Speed | Very slow | Slower than WebDriver | Fastest |
Installation | Firefox Add-on | Requires RC server | Only browser drivers |
Deprecated? | Yes | Yes | No (actively used) |
98. Difference between:
java
WebDriver driver = new FirefoxDriver();
FirefoxDriver driver = new FirefoxDriver();
Explanation:
- WebDriver driver = new FirefoxDriver();
- This is the recommended approach.
- Uses the WebDriver interface, allowing the code to be browser-independent and follow good abstraction.
- You can later switch to another browser (e.g., ChromeDriver) without major code changes.
- This is the recommended approach.
- FirefoxDriver driver = new FirefoxDriver();
- This is a direct instantiation of the FirefoxDriver class.
- It’s tightly coupled to the Firefox browser.
- Less flexible for cross-browser automation.
- This is a direct instantiation of the FirefoxDriver class.
Best Practice:
Always use:
java
WebDriver driver = new FirefoxDriver();
so that you can easily switch browsers and follow interface-based programming.
99. Difference between get() and navigate().to()
Feature | get(String url) | navigate().to(String url) |
Interface | Comes from WebDriver | Comes from Navigation interface |
Function | Loads a new web page | Loads a new web page |
History Handling | No browser history maintained | Maintains browser history |
Navigation Back/Forward | Not supported | Supports back(), forward(), refresh() operations |
Example | driver.get(“http://example.com”) | driver.navigate().to(“http://example.com”) |
When to Use:
- Use get() when you simply want to open a page.
- Use navigate().to() when performing advanced navigation like back() or forward().
100. What is API? Where is it used in Selenium?
Answer:
🔷 What is an API?
An API (Application Programming Interface) is a set of protocols, definitions, and tools that allows different software components to communicate with each other.
Example: When you use driver.get(“url”) in Selenium, you’re calling an API method from WebDriver.
🔷 API in Selenium:
Selenium WebDriver itself is an API library that enables interaction with browsers programmatically. It exposes a rich set of methods such as:
- get(), click(), sendKeys(), navigate(), switchTo() etc.
🔷 Where Else is API Used?
- In frameworks like REST Assured to test REST APIs
- In tools like Postman, JMeter
- In hybrid automation frameworks to call backend APIs for test setup, authentication, or data validation