Professional Documents
Culture Documents
• Execute Tests:
• Execute your test cases either individually or collectively.
• Monitor test execution results and debug failures if any.
• Continuous Integration:
• Integrate your automation framework with Continuous Integration (CI) tools like Jenkins,
Bamboo, or Azure DevOps for automated test execution.
CUCUMBER:
Setup Your Project:
• Follow the steps mentioned earlier to set up your Java project with Selenium WebDriver.
• Add Cucumber dependencies to your project. You'll need cucumber-java, cucumber-core,
cucumber-junit, and cucumber-jvm dependencies.
• Write feature files using Gherkin syntax. Feature files describe the behavior of your
application in a human-readable format.
• Define scenarios and steps that represent different test cases.
• Create step definition classes to map each step in your feature files to Java code.
• Implement the logic to interact with your application using Selenium WebDriver methods.
• Utilize regular expressions to match step definitions with corresponding steps in feature files.
• Configure Cucumber options in a test runner class. You can specify the location of your
feature files, glue code (step definitions), and other options.
• Integrate reporting plugins like Cucumber Extent Reporter or Cucumber HTML Reporter to
generate detailed test reports.
• Implement logging within step definitions to capture runtime information.
Continuous Integration:
• Integrate your Cucumber tests with a CI/CD pipeline for automated execution.
• Configure your CI server to run Cucumber tests as part of the build process.
• Use Cucumber feature files as a means of communication between stakeholders, testers, and
developers.
• Ensure that feature files are written in a language that all stakeholders understand.
• Follow best practices for writing feature files and step definitions.
• Regularly refactor and optimize your step definitions for better maintainability and
readability.
WebDriverManager: Utility for managing WebDriver binaries for different browsers. It automatically
downloads and configures the required WebDriver executables, eliminating the need for manual
management.
Test Data Management Utilities: Libraries or methods for reading test data from external sources
such as Excel files, CSV files, or databases. These utilities help in parameterizing tests and separating
test data from test logic.
Wait Utilities: Classes and methods for implementing explicit and implicit waits in tests. They allow
waiting for certain conditions to be met before proceeding with test execution, improving test
stability and reliability.
Logging Utilities: Frameworks for logging runtime information and debugging test failures. These
utilities capture log messages, exceptions, and other relevant information during test execution for
analysis and troubleshooting.
Reporting Utilities: Libraries or plugins for generating test reports with detailed information about
test executions, including test case status, screenshots, logs, and performance metrics. These reports
help in test analysis and result interpretation.
Page Object Model (POM) Implementations: Frameworks or utilities for implementing the Page
Object Model (POM) pattern, which helps in creating reusable and maintainable page objects for
organizing and managing web elements in test scripts.
TestNG or JUnit Integration Utilities: Integrations or extensions for TestNG or JUnit frameworks that
provide additional features or utilities specific to Selenium testing, such as parallel test execution,
test parameterization, and test suite management.
Browser Manipulation Utilities: Classes and methods for handling browser-specific operations, such
as managing cookies, handling alerts, executing JavaScript, and navigating back and forward in
browser history.
Screenshot and Video Capture Utilities: Utilities for capturing screenshots or recording videos of test
executions. These utilities are useful for documenting test results, reproducing failures, and providing
visual evidence of test coverage.
BrowserStack or Sauce Labs Integration Utilities: Integrations with cloud-based testing platforms like
BrowserStack or Sauce Labs for running Selenium tests on a wide range of browsers, devices, and
operating systems in parallel.
Configuration Management Utilities: Libraries or methods for managing test configurations and
environment settings. They help in configuring test parameters, setting up test environments, and
managing test data sources.
HTML,CSS,JacaScript:
Question: What is the purpose of the <div> element in HTML, and how is it commonly used?
Answer:
The <div> element in HTML is a generic container used to group and style other elements or sections
of a web page. It does not have any specific semantic meaning and is primarily used for layout
purposes and organizing content.
Question: In the code block below, there is a bug that prevents the paragraph text from appearing.
Identify the bug and provide a fix.
<div>
<p>Some text here</p>
</div>Code language: HTML, XML (xml)
Answer:
The bug is that the closing </div> tag is missing a forward slash (“/”). The correct code should be:
<div>
<p>Some text here</p>
</div>Code language: HTML, XML (xml)
Answer:
The CSS Box Model is a fundamental concept in CSS that describes how elements are rendered and
sized in a web page. It consists of four components: content, padding, border, and margin. The
content area is where the actual content of the element is displayed. The padding area surrounds
the content and provides space between the content and the border. The border is a line that goes
around the padding and content area, and the margin is the space outside the border.
Question: In the code block below, the CSS selector is incorrect. Identify the error and provide a
fix.
.styed-button {
background-color: blue;
color: white;
padding: 10px;
}Code language: CSS (css)
Answer:
The error is in the CSS selector. It should be .styled-button instead of .styed-button. The correct code
should be:
.styled-button {
background-color: blue;
color: white;
padding: 10px;
}Code language: CSS (css)
Question: Explain the purpose of the querySelector method in JavaScript, and provide an example
of how to use it.
Answer:
The querySelector method in JavaScript allows you to select elements from the DOM using CSS-style
selectors. It returns the first element that matches the selector. Here’s an example:
This example selects the first element with the class “my-class” and assigns it to
the element variable.
Question: In the code block below, there is a syntax error preventing the JavaScript function from
executing. Identify the error and provide a fix.
function sayHello() {
console.log("Hello, world!")
}Code language: JavaScript (javascript)
Answer:
The error is the missing closing parenthesis “)” at the end of the function definition. The correct code
should be:
function sayHello() {
console.log("Hello, world!");
}Code language: JavaScript (javascript)
Question: Explain the purpose of the href attribute in an <a> element in HTML, and how it is used.
Answer:
The href attribute in an <a> element is used to specify the URL or destination that the link should
navigate to when clicked. It is an essential attribute for creating hyperlinks in HTML. The value of
the href attribute can be an absolute URL, a relative URL, or an anchor reference within the same
page.
Question: In the code block below, the CSS property is missing. Identify the missing property and
provide a fix.
.container {
width: 500px;
height: 300px;
background-color: red;
/* Missing CSS property */
}Code language: CSS (css)
Answer:
The missing CSS property is border. To fix the code, add the border property with the desired value,
such as:
.container {
width: 500px;
height: 300px;
background-color: red;
border: 1px solid black;
}Code language: CSS (css)
Question: Explain the concept of event handling in JavaScript and provide an example of attaching
an event listener to a button.
Answer:
In JavaScript, event handling involves responding to user actions or events triggered by the browser.
Event listeners are functions that listen for specific events and execute code in response. Here’s an
example of attaching an event listener to a button:
button.addEventListener("click", () => {
console.log("Button clicked!");
});Code language: JavaScript (javascript)
In this example, the event listener is attached to the button element with the id “myButton.” When
the button is clicked, the anonymous arrow function is executed, and it logs “Button clicked!” to the
console.
Question: In the code block below, the JavaScript function contains an error preventing it
from executing. Identify the error and provide a fix.
function calculateSum(a, b) {
const sum = a + b;
console.log("The sum is: " + sum);
}
Answer:
The error is the missing closing parenthesis “)” at the end of the function call. The correct
code should be:
calculateSum(5, 10);
HTML Interview Questions and Answers
1. What is HTML?
HTML stands for HyperText Markup Language. It is used to design web pages using a markup
language. HTML is a combination of Hypertext and Markup language. Hypertext defines the link
between the web pages. The markup language is used to define the text document within the tag
which defines the structure of web pages. HTML is used to structure the website and is therefore
used for Web Development.
HTML stands for Hypertext Markup XHTML stands for Extensible Hypertext
1.
Language. Markup Language.
All tags and attributes are not necessarily In this, every tag and attribute should be in
6.
to be in lower or upper case. lower case.
Doctype is not necessary to write at the Doctype is very necessary to write at the top
7.
top. of the file.
It is not necessary to close the tags in the It is necessary to close the tags in the order
8.
order they are opened. they are opened.
The used filename extensions are .html, The used Filename extensions are .xhtml, .xht,
10.
.htm. .xml.
It didn’t support audio and video without the use It supports audio and video controls with the
of Flash player support. use of <audio> and <video> tags.
Not possible to draw shapes like circles, HTML5 allows drawing shapes like circles,
rectangles, triangles, etc. rectangles, triangles, etc.
Older versions of HTML are less mobile-friendly. HTML5 language is more mobile-friendly.
The doctype declaration is too long and The doctype declaration is quite simple and
complicated. easy.
Character encoding is long and complicated. Character encoding is simple and easy.
It is almost impossible to get the true GeoLocation One can track the Geo Location of a user
of users with the help of the browser. easily by using JS GeoLocation API.
Attributes like charset, async, and ping are absent Attributes of the charset, async, and ping are
in HTML. a part of HTML 5.
4.What are the various markup languages available?
• HTML: Hypertext Markup Language
• KML: Key whole Markup Language
• MathML: Mathematical Markup Language
• SGML: Standard Generalized Markup Language
• XHTML: eXtensible Hypertext Markup Language
• XML: eXtensible Markup Language
7. What are elements and tags, and what are the differences between them?
HTML Tags: Tags are the starting and ending parts of an HTML element. They begin with < symbol
and end with > symbol. Whatever is written inside < and > are called tags.
Syntax:
<b> </b>
HTML elements: Elements enclose the contents in between the tags. They consist of some kind of
structure or expression. It generally consists of a start tag, content, and an end tag.
Syntax:
<b>This is the content.</b>
Difference between HTML Tag & HTML Element:
HTML Tag HTML Element
Either opening or closing is used to mark the start Collection of a start tag, end tag, and its
or end of an element. attributes.
<section id="home_section">
Information About Page
</section>
Example: When the user clicks on the “Contact Us” link, he will be redirected to the “Contact Us
section” on the same page.
• HTML
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 100%;
height: 400px;
border: 1px solid black;
}
</style>
</head>
<body>
<h2>Welcome to GeeksforGeeks</h2>
<p>
This is the example of
<i>
Redirect to a particular section
using HTML on same page
</i>
</p>
</html>
Output:
11. Are <b> and <strong> tags same? If not, then why?
HTML strong tag: The strong tag is one of the elements of HTML used in formatting HTML texts. It
is used to show the importance of the text by making it bold or highlighting it semantically.
Syntax:
<strong> Contents... </strong>
HTML bold tag: The bold tag or <b> is also one of the formatting elements of HTML. The text written
under the <b> tag makes the text bold presentationally to draw attention.
Syntax:
<b> Contents... </b>
The main difference between the <bold> tag & <strong> tag is that the strong tag semantically
emphasizes the important word or section of words while the bold tag is just offset text
conventionally styled in bold.
16. What is the use of the target attribute in the <link> tag?
The HTML <link> target Attribute is used to specify the window or a frame where the linked
document is loaded. It is not supported by HTML 5.
Syntax:
<link target="_blank|_self|_parent|_top|framename">
Attribute Values:
• _blank: It opens the link in a new window.
• _self: It opens the linked document in the same frame.
• _parent: It opens the linked document in the parent frameset.
• _top: It opens the linked document in the full body of the window.
• framename: It opens the linked document in the named frame.
APPIUM:
• Test Web
• Provides cross-platform for Native and Hybrid mobile automation
• Support JSON wire protocol
• It does not require recompilation of App
• Support automation test on physical device as well as similar or emulator both
• It has no dependency on mobile device
• ANDROID SDK
• JDK
• TestNG
• Eclipse
• Selenium Server JAR
• Webdriver Language Binding Library
• APPIUM for Windows
• APK App Info On Google Play
• js
• Appium does not support testing of Android Version lower than 4.2
• Limited support for hybrid app testing. E.g., not possible to test the switching action of
application from the web app to native and vice-versa
• No support to run Appium Inspector on Microsoft Windows
Appium interview questions
• Appium is an “HTTP Server” written using Node.js platform and drives iOS and Android
session using Webdriver JSON wire protocol. Hence, before initializing the Appium Server,
Node.js must be pre-installed on the system
• When Appium is downloaded and installed, then a server is setup on our machine that
exposes a REST API
• It receives connection and command request from the client and execute that command on
mobile devices (Android / iOS)
• It responds back with HTTP responses. Again, to execute this request, it uses the mobile test
automation frameworks to drive the user interface of the apps. Framework like
• Apple Instruments for iOS (Instruments are available only in Xcode 3.0 or later with
OS X v10.5 and later)
• Google UIAutomator for Android API level 16 or higher
• Selendroid for Android API level 15 or less
• For programmer irrespective of the platform, he is automating ( Android or iOS) all the
complexities will remain under single Appium server
• It opens the door to cross-platform mobile testing which means the same test would work
on multiple platforms
• Appium does not require extra components in your App to make it automation friendly
• It can automate Hybrid, Web and Native mobile applications
Cons:
• Running scripts on multiple iOS simulators at the same time is possible with Appium
• It uses UIAutomator for Android Automation which supports only Android SDK platform, API
16 or higher and to support the older API’s they have used another open source library
called Selendroid
9) Explain what is APPIUM INSPECTOR?
Similar to Selenium IDE record and Playback tool, Appium has an “Inspector” to record and playback.
It records and plays native application behavior by inspecting DOM and generates the test scripts in
any desired language. However, Appium Inspector does not support Windows and use UIAutomator
viewer in its option.
10) Mention what are the basic requirement for writing Appium tests?
For writing Appium tests you require,
• Driver Client: Appium drives mobile applications as though it were a user. Using a client
library you write your Appium tests which wrap your test steps and sends to the Appium
server over HTTP.
• Appium Session: You have to first initialize a session, as such Appium test takes place in the
session. Once the Automation is done for one session, it can be ended and wait for another
session
• Desired Capabilities: To initialize an Appium session you need to define certain parameters
known as “desired capabilities” like PlatformName, PlatformVersion, Device Name and so
on. It specifies the kind of automation one requires from the Appium server.
• Driver Commands: You can write your test steps using a large and expressive vocabulary of
commands.
11) Mention what are the possible errors one might encounter using Appium?
The possible errors one might face in Appium includes
• Error 1: The following desired capabilities are needed but not provided: Device Name,
platformName
• Error 2: Could not find adb. Please set the ANDROID_HOME environment variable with the
Android SDK root directory path
• Error 3: openqa.selenium.SessionNotCreatedException: A new session could not be created
• Error 4: How to find DOM element or XPath in a mobile application?
13) Is it possible to interact with my apps using Javascript while I am testing with Appium?
Yes, it is possible to interact with App while using Javascript. When the commands run on Appium,
the server will send the script to your app wrapped into an anonymous function to be executed.
14) Mention what are the most difficult scenarios to test with Appium?
The most difficult scenario to test with Appium is data exchange.
16) In Android, do you need an app’s .apk to automate using Appium or you also need app in my
workspace?
In Android, you only need .apk file to automate using Appium.
# using es7/babe1
#regular es5
API testing is a type of software testing that involves checking if the Application Programming
Interfaces (APIs) meet their functionality, reliability, performance, and security requirements. It
focuses on verifying the communication and data exchange between different software
components or systems.
2. What is Postman?
Postman is a popular tool used for API development and testing. It provides an intuitive user
interface for sending requests to APIs, testing API endpoints, automating API testing workflows,
and generating API documentation.
API testing is crucial because it ensures that APIs function correctly and reliably, facilitating
smooth communication and data exchange between different software components or systems.
It helps identify bugs, security vulnerabilities, and performance issues early in the development
lifecycle, saving time and resources.
In Postman, API testing involves creating requests to API endpoints using HTTP methods like GET,
POST, PUT, DELETE, etc. We can then send these requests to the API server and analyze the
responses to verify if the API behaves as expected. Postman provides features like environment
variables, test scripts, assertions, and collections to streamline and automate the API testing
process.
Automation in Postman can be achieved using collections and test scripts. Collections allow you
to organize and group related requests together, while test scripts enable you to define custom
validation logic and assertions. By combining collections with test scripts and leveraging features
like Newman (Postman's command-line tool) or integrating with continuous integration (CI)
systems, we can automate the execution of API tests as part of your development pipeline.
7. What are some common challenges faced in API testing?
Some common challenges in API testing include handling authentication mechanisms, ensuring
proper data validation and error handling, managing dependencies on external services, testing
for edge cases and boundary conditions, and maintaining test suites as APIs evolve over time.
Effective strategies and tools like Postman can help address these challenges and streamline the
API testing process.
Status codes in API responses indicate the success or failure of a request and provide additional
information about the result. For example, HTTP status code 200 indicates a successful response,
while codes like 404 signify that the requested resource was not found. In API testing, analyzing
status codes helps verify if the API behaves as expected under different conditions and enables
testers to identify and troubleshoot issues effectively.
Postman provides various authentication methods such as Basic Auth, Digest Auth, OAuth 1.0,
OAuth 2.0, API Key, etc. You can configure authentication for your requests within Postman by
selecting the appropriate method and providing the required credentials or tokens. Additionally,
Postman allows you to automate authentication processes using environment variables or
scripts, making it easier to manage and reuse authentication settings across multiple requests.
• Identifying test scenarios: Determine the functionality, performance, security, and edge
cases to be tested.
• Creating reusable test cases: Develop modular and maintainable test cases that can be
reused across different API endpoints.
• Using automation: Automate repetitive tasks and regression tests to increase efficiency and
consistency.
• Validating responses: Verify response data, status codes, headers, and error messages to
ensure correctness and reliability.
• Handling dependencies: Mock external dependencies or use stubs to isolate the API under
test and ensure reliable test execution.
• Implementing security testing: Test for vulnerabilities such as injection attacks,
authentication flaws, and data exposure.
• Monitoring performance: Measure response times, throughput, and resource utilization to
assess performance under different loads.
• Documenting tests: Document test cases, scenarios, and results for traceability and
knowledge sharing within the team.
11. How can you parameterize requests in Postman?
• Parameterization in Postman allows you to replace static values in requests with variables,
making tests more dynamic and reusable.
• You can use variables to represent values like URLs, query parameters, headers, request
bodies, etc.
• Postman supports various types of variables, including environment variables, global
variables, collection variables, and local variables defined within request scripts.
• By parameterizing requests, you can easily adapt tests to different environments or scenarios
without modifying the test logic.
12. What is API mocking, and how is it useful in API testing?
API mocking means creating pretend responses from API endpoints without talking to the real
backend. It's like practicing with a dummy instead of a real opponent. It helps testers to try out
different situations and problems before everything is fully set up, making testing faster and
more flexible.
Pagination is like breaking a big list into smaller pieces. In Postman, you handle it by asking for
one piece at a time and then automatically getting the next piece until you have everything. It's
like asking for a few pages of a book at a time instead of the whole book at once.
Pre-request scripts are like getting ready before you go out — you might check the weather or
grab your keys. In Postman, it's code you run just before sending a request. Post-request scripts
are like what you do after you come back home — maybe you unpack your bags or write down
what happened. In Postman, it's code you run just after getting a response.
Program Statement:
Given two sorted arrays 'a' and 'b' of size 'n' and 'm' respectively.
Median is defined as the middle value of a sorted list of numbers. In case the length of list is
even, median is the average of the two middle elements.
The expected time complexity is O(min(logn, logm)), where 'n' and 'm' are the sizes of arrays 'a'
and 'b', respectively, and the expected space complexity is O(1).
Example:
Input: 'a' = [2, 4, 6] and 'b' = [1, 3, 5]
Output: 3.5
Explanation: The array after merging 'a' and 'b' will be { 1, 2, 3, 4, 5, 6 }. Here two medians are 3 and
4. So the median will be the average of 3 and 4, which is 3.5.
Detailed explanation ( Input/output format, Notes, Images )
Sample Input 1:
33
246
135
Sample Output 1:
3.5
Explanation of Sample Input 1 :
The array after merging 'a' and 'b' will be { 1, 2, 3, 4, 5, 6 }.
Here two medians are 3 and 4. So the median will be the average of 3 and 4, which is 3.5.
Sample Input 2:
32
246
13
Sample Output 2:
3
Explanation of Sample Input 2 :
The array after merging 'a' and 'b' will be { 1, 2, 3, 4, 6 }.
The median is 3.
Sample Input 3:
33
122
244
Sample Output 3:
2.0
Explanation of Sample Input 3 :
The array after merging 'a' and 'b' will be { 1, 2, 2, 2, 4, 4 }.
Here two medians are 2 and 2. So the median will be the average of 2 and 2, which is 2.
Constraints:
1 <= 'n' <= 10 ^ 6
1 <= 'm' <= 10 ^ 6
1 <= 'a[i]' <= 10 ^ 9
1 <= 'b[i]' <= 10 ^ 9
import java.util.Arrays;
• Import Statement:
This line imports the Arrays class from the java.util package, which provides utility methods for
arrays, including sorting.
• Method Declaration:
The median method takes two integer arrays a and b as input parameters and returns a double value,
which represents the median of the merged array.
• Merging Arrays:
Here, we create a new integer array merged with a length equal to the sum of the lengths of arrays a
and b. We then use System.arraycopy() method to copy the elements of arrays a and b into the
merged array. This effectively merges the two arrays into a single array.
• Sorting:
After merging the arrays, we sort the merged array in ascending order using the Arrays.sort()
method. Sorting the array is necessary to find the median value.
• Calculating Median:
If the total length of the merged array is even, we take the average of the two middle elements to get
the median. If the total length is odd, we simply return the middle element as the median.
• Return Statement:
This implementation is straightforward and easy to understand. It merges the arrays, sorts them, and
then calculates the median based on the length of the merged array.