Multiple Companys

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 17

==

1. what is testng? why we go for testng?

is a testing framework for the Java programming language. It's an extension of


JUnit and inspired by NUnit.
TestNG's design goal is to cover a wide range of test categories, including unit,
functional, end-to-end, and integration testing. It helps to make automated testing
easier by making it more structured, readable, maintainable, and user-friendly.
Annotations: Used to describe a batch of code or business logic used to control the
flow of methods in the test script
Grouping tests: Helps to write powerful test cases
Parameterization: Helps to write powerful test cases
Parallel testing: Allows multiple tests to be executed simultaneously in different
thread processes
Reporting: Helps to generate a proper report and easily understand how many test
cases are passed, failed, and skipped
Data-driven testing: An advanced feature that makes TestNG an attractive option for
automation testers
Listeners

what are the apache poi interface and class

Apache POI is an open-source Java library that allows users to create and
manipulate file formats based on Microsoft Office. It provides methods to create,
read, and write into Excel sheets. Apache POI uses interfaces and classes to handle
files in an application

It holds object of HSSFWorkbook class and provides methods to create, read and
write into the Excel sheet.

Here are some Apache POI interfaces:

Workbook: Represents an Excel workbook


Sheet: Represents an Excel worksheet
Row: Represents a row in a spreadsheet
Cell: A high-level representation of cells in a spreadsheet row

Here are some Apache POI classes:

XSSFRow: Creates rows in a spreadsheet


Cell: A high-level representation of cells in a spreadsheet row
XSSFCell: Implements the Cell interface
XSSFCellStyle: Provides information about the content format in a spreadsheet cell

2. what is maven

Maven is an open-source build automation tool and project management tool used for
Java applications. It's written in Java and can also be used to build projects
written in other languages, such as C#, Scala, and Ruby.

What is a POM file?

A Project Object Model or POM is the fundamental unit of work in Maven. It is an


XML file that contains information about the project and configuration details used
by Maven to build the project. It contains default values for most projects.
2.can we run a test without testng?

Yes, you can run a test without TestNG:


Maven's surefire plugin: Allows you to run a testng class or testng.xml without
using a testng.xml file. You can use the Surefire plugin with TestNG to execute
your tests if you follow surefire's test naming conventions.

3. what is the difference between verification and valiation?

Verification: Determines if the software is designed and developed according to the


specified requirements. This includes all activities associated with producing high
quality software.
Validation: Checks if the software meets the client's needs and expectations. This
is also sometimes called acceptance or business testing

4. what are the different locators in selenium?

ID: Locate elements by their unique ID attribute.


driver.findElement(By.id("elementId"));
Name: Locate elements by their name attribute.
driver.findElement(By.name("elementName"));
Class Name: Locate elements by their class attribute.
driver.findElement(By.className("className"));
Tag Name: Locate elements by their HTML tag name.
driver.findElement(By.tagName("tagName"));
Link Text: Locate anchor elements (a) by their visible text.
driver.findElement(By.linkText("linkText"));
Partial Link Text: Locate anchor elements (a) by a portion of their visible text.
driver.findElement(By.partialLinkText("partialLinkText"));
XPath: Locate elements using XPath expressions.
driver.findElement(By.xpath("xpathExpression"));
CSS Selector: Locate elements using CSS selectors.
driver.findElement(By.cssSelector("cssSelector"));

5. what is xpath?

Absolute XPath: Starts from the root node and follows a path down to the desired
node. It begins with a single forward slash /.
Example:
/html/body/div[1]/form/input[2]

Relative XPath: Starts from any node in the XML structure and does not need to
begin from the root node. It does not start with a forward slash.
Example:
//input[@id='username']

6. diffrence between absolute and relative path?

Absolute XPath: Starts from the root node and follows a path down to the desired
node. It begins with a single forward slash /.
Example:
/html/body/div[1]/form/input[2]

Relative XPath: Starts from any node in the XML structure and does not need to
begin from the root node. It does not start with a forward slash.
Example:
//input[@id='username']
8. what in diff between method overloading and constructor overloading? with
example?

Constructor Overloading:

Constructor overloading refers to defining multiple constructors in the same class


with the same name but different parameters.
Constructor overloading allows you to create objects of a class with different
initialization behaviors based on the parameters provided.
Constructor overloading is used to provide flexibility in object creation and
initialization.
Constructor overloading does not depend on the return type of the constructor.

9.diffrence between string and string buffer?

String:
The String class is immutable.
String is slow and consumes more memory when we concatenate too many strings
because every time it creates new instance.
String class overrides the equals() method of Object class. So you can compare the
contents of two strings by equals() method.
String class is slower while performing concatenation operation.
String class uses String constant pool.

StringBuffer:

The StringBuffer class is mutable.


StringBuffer is fast and consumes less memory when we concatenate t strings.
StringBuffer class doesn't override the equals() method of Object class.
StringBuffer class is faster while performing concatenation operation.
StringBuffer uses Heap memory

10. what is overriding ?

Polymorphism allows us to perform a single action in different ways. In Java


polymorphism can be achieved by two ways:
- Method Overloading: When there are multiple methods with same name but different
parameters then these methods are said to be overloaded. Methods can be overloaded
by change in number of arguments.
In Selenium Automation, Implicit wait is an example of Method Overloading. In
implicit wait we use different time stamps such as SECONDS, MINUTES, HOURS etc.
- Method Overriding: It occurs when a derived class has a definition for one of the
member functions of the base class. That base function is said to be overridden.
In Selenium Automation, Method Overriding can be achieved by overriding any
WebDriver method. For example, we can override the findElement method In assertion
we have used overload because in assertion we used to like asset.true(actual,
expected) and second time we can use same assert.true(actual,

11.how to handle dynamic elements?

Handling dynamic elements in web automation refers to dealing with elements on a


web page whose attributes, such as ID, class name, or XPath, may change dynamically
based on various factors such as user interactions, page reloads, or updates to the
web application. To handle dynamic elements effectively in Selenium WebDriver, you
can use the following techniques:
Wait Strategies:

Use explicit waits: Wait for the element to become clickable, visible, or present
on the page before interacting with it. You can use WebDriverWait in combination
with ExpectedConditions.
Use implicit waits: Set a timeout globally for WebDriver to wait for elements
before throwing an exception.
Unique Attributes:

If possible, identify the element by an attribute that remains constant or less


likely to change dynamically. For example, use name, value, or other custom
attributes.
XPath and CSS Selectors:

Use XPath or CSS selectors to locate elements based on their position, relationship
with other elements, or any other unique characteristics. These locators can be
more flexible in handling dynamic elements than ID or class name.
Partial Match:

If the element's attribute value changes dynamically but a part of it remains


constant, you can use partial matching with XPath or CSS selectors. For example,
using contains() function in XPath or substring matching in CSS selectors.
Parent-Child Relationships:

Identify a stable parent element and then navigate to the desired dynamic element
using XPath or CSS selectors. This ensures that even if the child element changes,
the parent's location remains constant.
Retry Mechanism:

Implement a retry mechanism to handle intermittent failures due to dynamic


elements. You can catch exceptions when locating elements and retry the operation
after a short delay.
Page Object Model (POM):

Use the Page Object Model pattern to encapsulate web pages' functionality and
locators. This way, if the dynamic elements change, you only need to update the
page object class rather than changing tests' implementation.

12. how to get the no of emp getting same salary?

import java.util.HashMap;
import java.util.Map;

public class Main {


public static void main(String[] args) {
// Sample data: employee names and their salaries
String[] employees = {"Alice", "Bob", "Charlie", "David", "Emma", "Alice",
"David"};
int[] salaries = {50000, 60000, 50000, 70000, 60000, 50000, 70000};

// Count the occurrences of each salary using a HashMap


Map<Integer, Integer> salaryCounts = new HashMap<>();
for (int salary : salaries) {
salaryCounts.put(salary, salaryCounts.getOrDefault(salary, 0) + 1);
}

// Print the counts


for (Map.Entry<Integer, Integer> entry : salaryCounts.entrySet()) {
System.out.println("Number of employees with salary " + entry.getKey()
+ ": " + entry.getValue());
}
}
}

5. what is difference between abstract class and interface?

Abstract class Interface


1) Abstract class can have abstract and non-abstract methods.
2) Abstract class doesn't support multiple inheritance.
3) Abstract class can have final, non-final, static and non-static variables.
4) Abstract class can provide the implementation of interface.
5) The abstract keyword is used to declare abstract class.
6) An abstract class can extend another Java class and implement multiple Java
interfaces.
7) An abstract class can be extended using keyword "extends".
8) A Java abstract class can have class members like private, protected, etc.

Interface can have only abstract methods. Since Java 8, it can have default and
static methods also.
Interface supports multiple inheritance.
Interface has only static and final variables.
Interface can't provide the implementation of abstract class.
The interface keyword is used to declare interface.
An interface can extend another Java interface only.
An interface can be implemented using keyword "implements".
Members of a Java interface are public by default.

6.diffrence between final, finaly,finalize?

Definition final is the keyword and access modifier which is used to apply
restrictions on a class, method or variable.
Applicable to Final keyword is used with the classes, methods and variables.
final method cannot be overridden by sub class.
final class cannot be inherited.
Final method is executed only when we call it.
Once declared, final variable becomes constant and cannot be modified.

finally is the block in Java Exception Handling to execute the important code
whether the exception occurs or not.
Finally block is always related to the try and catch block in exception handling.
finally block runs the important code even if exception occurs or not.
Finally block is executed as soon as the try-catch block is executed.

finalize is the method in Java which is used to perform clean up processing just
before object is garbage collected.
finalize() method is used with the objects.
inalize method is executed just before the object is destroyed.

7.diffrence between normal class and final class?

In Java, the main difference between a normal class and a final class is that a
final class cannot be subclassed. A final class is a complete and immutable class,
so data elements do not change by external access

8.how to handle frames without having any attributes?


Switch the driver's focus to the frame using the switchTo(). frame() method.
Using web driver commands, interact with the elements of the frame and perform the
operations.
Switch back to the web content by the switchTo(). defaultContent() method.
switch to the main page using the driver. switchTo(). defaultContent();

9. diffence between smoke and sanity testing?

Smoke test is done to make sure that the critical functionalities of the program
are working fine, whereas sanity testing is done to check that newly added
functionalities, bugs, etc., have been fixed. The software build may be either
stable or unstable during smoke testing.

===================================================================================
====
Bosch interview Qustions

4. generic code for fetching data from xl sheet?

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.poi.ss.usermodel.*;

public class ReadExcelData {


public static void main(String[] args) {
// Path to the Excel file
String filePath = "path/to/your/excel/file.xlsx";

try {
FileInputStream fis = new FileInputStream(filePath);
Workbook workbook = WorkbookFactory.create(fis);
Sheet sheet = workbook.getSheetAt(0); // Assuming data is in the first
sheet

// Iterate through each row


for (Row row : sheet) {
// Iterate through each cell in the row
for (Cell cell : row) {
// Retrieve the cell value based on the cell type
switch (cell.getCellType()) {
case STRING:
System.out.print(cell.getStringCellValue() + "\t");
break;
case NUMERIC:
System.out.print(cell.getNumericCellValue() + "\t");
break;
case BOOLEAN:
System.out.print(cell.getBooleanCellValue() + "\t");
break;
case BLANK:
System.out.print("[BLANK]\t");
break;
default:
System.out.print("[UNKNOWN]\t");
}
}
System.out.println(); // Move to the next line after printing each
row
}

// Close the workbook and file input stream


workbook.close();
fis.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}

7.how to do parallel execution?

TestNG allows running the tests in parallel by setting the “parallel” attribute in
the “<suite>” tag respectively to “tests”, “methods”, “classes”, “instances”. As
per the setting provided to run the tests, it will start executing the tests in
separate threads.

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">


<suite name="Parallel Test Suite" parallel="tests" thread-count="3">

<!-- Test 1: Parallel execution with multiple test classes -->


<test name="Test1" parallel="classes">
<classes>
<class name="com.example.TestClass1"/>
<class name="com.example.TestClass2"/>
</classes>
</test>

<!-- Test 2: Parallel execution with a single test class -->


<test name="Test2" parallel="methods">
<classes>
<class name="com.example.TestClass3"/>
</classes>
</test>

</suite>

10.how to fetch all the options in auto suggest?

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.List;

public class AutoSuggestDropdown {


public static void main(String[] args) {
// Set the path to the ChromeDriver executable
System.setProperty("webdriver.chrome.driver", "path/to/chromedriver");

// Initialize ChromeDriver
WebDriver driver = new ChromeDriver();
// Navigate to the webpage with the auto-suggest dropdown
driver.get("url_of_the_webpage_with_auto_suggest_dropdown");

// Locate the auto-suggest dropdown element


WebElement autoSuggestDropdown =
driver.findElement(By.id("id_of_auto_suggest_dropdown"));

// Retrieve all options from the auto-suggest dropdown


List<WebElement> options =
autoSuggestDropdown.findElements(By.tagName("option"));

// Print or process the options


System.out.println("Options in the auto-suggest dropdown:");
for (WebElement option : options) {
System.out.println(option.getText());
}

// Close the browser


driver.quit();
}
}

12. how to generate daily execution report?

To generate daily execution reports in Selenium, you can use various reporting
frameworks and tools available in the Java ecosystem. One popular reporting
framework used with Selenium is ExtentReports. ExtentReports allows you to create
interactive and customizable HTML reports with detailed test execution results.

<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>5.0.5</version>
<scope>test</scope>
</dependency>

testImplementation 'com.aventstack:extentreports:5.0.5'

Write Test Cases: Write your Selenium test cases using TestNG or JUnit.

Generate ExtentReports: Within your test methods, use ExtentReports API to create
and log test events (e.g., test pass, fail, skip) along with additional information
such as screenshots, logs, etc.

Customize Reports: Customize your ExtentReports to include information such as test


case names, descriptions, timestamps, etc., to make the reports more informative.

Save Reports: Save the generated ExtentReports as HTML files in a specified


directory.

Techmetric interview

1. what is webdriver?

WebDriver is a web automation framework that allows you to automate interactions


with web browsers. It provides a programming interface to interact with web
browsers such as Chrome, Firefox, Safari, Edge, etc

Cross-browser Testing: WebDriver supports multiple web browsers, allowing you to


write browser-agnostic automation scripts that work across different browsers
without modification.

Rich API: WebDriver provides a rich set of APIs (Application Programming


Interfaces) in various programming languages (e.g., Java, Python, JavaScript, C#,
etc.) for interacting with web elements, navigating web pages, handling alerts,
managing cookies, and more.

Support for Multiple Platforms: WebDriver supports multiple operating systems


(e.g., Windows, macOS, Linux) and can be used to automate web tasks on desktop and
mobile browsers.

Integration with Testing Frameworks: WebDriver can be integrated with testing


frameworks such as TestNG, JUnit, NUnit, etc., allowing you to write and execute
automated tests efficiently.

Headless Browser Support: WebDriver supports headless browser testing, enabling you
to run tests without opening a visible browser window. This is useful for running
tests in headless environments like CI/CD pipelines

2. where all of abstract methods of webdriver are implemented?

The abstract methods of SearchContext and WebDriver interfaces are implemented in


the RemoteWebDriver class. All browser-related classes, such as FirefoxDriver and
ChromeDriver, extend the RemoteWebdriver class.

get(String url), quit(), close(), getWindowHandle(), getWindowHandles(),


getTitle().
In Selenium, abstract classes play a significant role in fostering a more
structured, organized, and maintainable test automation codebase. They are mainly
used to establish a foundation for the Page Object Model (POM) design pattern and
other best practices.

7.how to connect to the database?

Establish a connection to the database using JDBC

try {
// Establish database connection
connection = DriverManager.getConnection(url, username, password);

// Create a SQL statement


statement = connection.createStatement();

// Execute a query
resultSet = statement.executeQuery("SELECT * FROM mytable");

// Process the result set


while (resultSet.next()) {
// Retrieve data from the result set
String column1Value = resultSet.getString("column1");
String column2Value = resultSet.getString("column2");

// Process data as needed


System.out.println(column1Value + "\t" + column2Value);
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
// Close JDBC resources
try {
if (resultSet != null) resultSet.close();
if (statement != null) statement.close();
if (connection != null) connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}

1. Explain ur responsibility in ur project?

2. Explain ur project(team size,domain etc)

3. Automation process?

4. All basic questions on Manual Testing?

5. Diff between RC,IDE,GRID and Web Driver?

6. How to handle SSL issue,POP-Up alert?...

HappiestMind interview questions

1. what is collection in java.

collection is a frame work provided by java , this frame work provides many
interfaces and thair implimented classes in order to store group of objects
(eliments)

2. play with any of the collections.

import java.util.ArrayList;
import java.util.Iterator;

public class Main {


public static void main(String[] args) {
// Create an ArrayList of strings
ArrayList<String> arrayList = new ArrayList<>();

// Add elements to the ArrayList


arrayList.add("Apple");
arrayList.add("Banana");
arrayList.add("Orange");
arrayList.add("Grapes");

// Print the ArrayList


System.out.println("ArrayList: " + arrayList);

// Remove an element
arrayList.remove("Banana");
System.out.println("After removing 'Banana': " + arrayList);

// Check if an element exists


System.out.println("Does 'Orange' exist? " + arrayList.contains("Orange"));

// Iterate through the ArrayList using Iterator


System.out.println("Iterating through the ArrayList:");
Iterator<String> iterator = arrayList.iterator();
while (iterator.hasNext()) {
System.out.println(iterator.next());
}

// Get the size of the ArrayList


System.out.println("Size of ArrayList: " + arrayList.size());

// Clear the ArrayList


arrayList.clear();
System.out.println("After clearing the ArrayList: " + arrayList);
}
}

3.scarch a letter in string?

public class Main {


public static void main(String[] args) {
String str = "Hello, World!";
char searchChar = 'o';

// Search for the letter 'o' in the string


int index = str.indexOf(searchChar);

if (index != -1) {
System.out.println("Letter '" + searchChar + "' found at index: " +
index);
} else {
System.out.println("Letter '" + searchChar + "' not found in the
string.");
}
}
}

4.reverse a number?

package OOPS;

public class rverseNumber {

public static void main(String[] args) {


int a=12345;
int b=0;
while(a!=0) {
int c=a%10;
b=b*10+c;
a=a/10;
}
System.out.println(b);
}
}

5. sorting ana array?

int[] arr = {1, 5, 3, 2, 4};


Arrays.sort(arr);

for (int i = 0; i < arr.length; i++) {


System.out.println(arr[i]);
}
Output: 1 2 3 4 5

6. What is page object model?

Page Object Model, also known as POM, is a design pattern in Selenium that creates
an object repository for storing all web elements. It helps reduce code duplication
and improves test case maintenance. In Page Object Model, consider each web page of
an application as a class file.

7. between css and xpath which one is faster?

CSS selectors are generally faster than XPath. CSS selectors are unidirectional,
which allows them to search for elements in the DOM tree more quickly. CSS
selectors are also easier to learn and implement, and they're compatible with most
browsers.
However, XPath has wider document type compatibility than CSS selectors, which only
work with HTML documents. XPath also allows traversal from child to parent, which
CSS selectors do not

8. what is exception.tell some exception.

Here are some examples of checked exceptions:

ClassNotFoundException: Thrown when an attempt is made to load a class that does


not exist.
IOException: Thrown when an input/output operation fails.
SQLException: Thrown when a database access operation fails.

Here are some examples of unchecked exceptions:

ArithmeticException: Thrown when an arithmetic operation, such as division by zero,


cannot be performed.
ArrayIndexOutOfBoundsException: Thrown when an attempt is made to access an element
of an array that is out of bounds.
NullPointerException: Thrown when an attempt is made to access a null object.
Exceptions are an important part of Java programming. By handling exceptions
properly, you can make your programs more robust and reliable.

9. tell some exception you get while writing code.

NoSuchElementException.
ElementNotVisibleException.
NoSuchFrameException.
NoAlertPresentException.
NoSuchWindowException.
SessionNotFoundException.
StaleElementReferenceException.
InvalidSelectorException.

10.how to handle exception ?

The "catch" block is used to handle the exception. It must be preceded by try block
which means we can't use catch block alone. It can be followed by finally block
later. The "finally" block is used to execute the necessary code of the program.

11.is it agood approche to throw an exception?

It is good programming practice to avoid this usage where possible. If null is a


reasonable value for the stated purpose of a method, or if a method is expected to
fail often in the normal course of operation, then it is reasonable to return null
to indicate failure; otherwise it is better to throw an exception.

14.how to generate a report?

TestNG provides built-in capabilities for generating reports of test execution


results. By default, TestNG generates an HTML report containing details such as
test suite name, test case names, status (pass/fail), duration, and stack traces
for failed tests. Additionally, you can use third-party libraries like
ExtentReports or Allure for more customizable and visually appealing reports.

Here's how you can generate a basic HTML report using TestNG:

Using TestNG XML Configuration:


In your TestNG XML configuration file, specify the listeners attribute in the
<suite> tag to include the org.testng.reporters.EmailableReporter2 class. This
listener generates the default HTML report.

Example testng.xml:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">


<suite name="MyTestSuite" verbose="1" >
<listeners>
<listener class-name="org.testng.reporters.EmailableReporter2" />
</listeners>
<test name="MyTest">
<classes>
<class name="com.example.MyTestClass" />
</classes>
</test>
</suite>

15.how many testcase you have automated.

During my previous role as a QA Automation Engineer, I automated approximately 200


test cases for our web application using Selenium WebDriver and Java. These test
cases covered a wide range of functionalities, including user authentication, data
validation, and end-to-end workflow testing. One of my notable achievements was
reducing the regression testing cycle from several days to just a few hours by
implementing automated test suites. I encountered challenges such as handling
dynamic elements and integrating automated tests into the CI/CD pipeline, but I was
able to overcome them through collaboration with the development team and
continuous learning. I am always eager to expand my knowledge and skills in test
automation and stay updated with the latest tools and technologies."

17. what is the minimum time to run a batch execution?

18. tell me complex senarion of your application?

User Authentication and Authorization:


Product Search and Selection:
Shopping Cart Management:
Checkout Process:
Product Details and Reviews:

19 challenges you faced in automation.

Dynamic Elements: Dealing with dynamic elements on web pages, such as changing IDs
or XPath, can make it difficult to locate elements consistently across test runs.

Test Data Management: Managing test data, especially for complex test scenarios or
environments with large datasets, can be challenging. Generating and maintaining
test data in a consistent and efficient manner is crucial for effective test
automation.

Synchronization Issues: Ensuring proper synchronization between test steps and


application behavior is essential for reliable test automation. Dealing with
asynchronous operations, AJAX requests, and delays in page loading can lead to
synchronization issues that need to be addressed.

Cross-Browser Compatibility: Testing across multiple browsers and browser versions


can uncover inconsistencies in rendering, functionality, or performance. Ensuring
cross-browser compatibility requires thorough testing and possibly maintaining
separate test scripts or configurations for different browsers.

Mobile Device Fragmentation: Testing on various mobile devices with different


screen sizes, resolutions, and operating systems presents challenges in ensuring
consistent behavior across devices. Compatibility testing and device-specific
configurations may be required to address these challenges.

Integration with CI/CD Pipelines: Integrating automated tests into continuous


integration and continuous deployment (CI/CD) pipelines requires careful planning
and coordination. Ensuring that tests run reliably and efficiently within the CI/CD
workflow and interpreting test results effectively are key challenges in
automation.

Maintenance of Test Scripts: As applications evolve over time, test scripts may
require frequent updates to adapt to changes in functionality, UI elements, or
underlying technologies. Keeping test scripts maintainable, reusable, and efficient
is an ongoing challenge in test automation.

Resource Management: Managing test environments, resources, and dependencies, such


as databases, APIs, or third-party services, can be challenging in automated
testing. Ensuring availability, consistency, and isolation of resources across test
runs is crucial for reliable and repeatable test automation.

Test Coverage and Prioritization: Ensuring adequate test coverage and prioritizing
tests based on risk, impact, and business requirements are important challenges in
test automation. Identifying critical test scenarios and optimizing test suites for
efficiency and effectiveness require careful planning and analysis.

22.how to run a test 3 times if the test fail ?

In the Page Object Model:

Each web page is represented as a separate class: Each web page in the application
has its own corresponding class, called a Page Object. The Page Object encapsulates
the behavior and elements of that specific page.

Page Object contains web elements and methods: The Page Object class contains
methods to interact with the web elements present on the page, such as clicking
buttons, filling forms, or verifying page content. It also contains references to
the web elements, typically using locators such as XPath, CSS selectors, or IDs.

Tests interact with Page Objects: Test scripts interact with the application's web
pages by calling methods provided by the corresponding Page Objects. This promotes
code reusability and makes the tests more readable and maintainable.

Separation of concerns: POM promotes separation of concerns by keeping test logic


(in test scripts) separate from the details of web page implementation (in Page
Objects). This allows for easier maintenance and updates to the tests and web
application.

Benefits of using the Page Object Model include:

Code Reusability: Page Objects encapsulate reusable code for interacting with web
elements, reducing duplication across tests.
Enhanced Maintainability: Updates or changes to web pages can be made in one place
(the corresponding Page Object), without impacting multiple test scripts.
Improved Readability: Tests written using Page Objects are more descriptive and
easier to understand, as they focus on high-level interactions with the application
rather than low-level implementation details.

30. how to upload file other than Autoit?

Using JavaScript: You can execute JavaScript to set the value of the file input
element directly.

WebElement fileInput = driver.findElement(By.id("fileInput"));


JavascriptExecutor jsExecutor = (JavascriptExecutor) driver;
jsExecutor.executeScript("arguments[0].setAttribute('value', '/path/to/file.txt')",

by using the actions class and robout class or by using the click method we can
upload a file
======================

There are three types of variables in Java:

Local variables: : These are declared inside a method, constructor, or block. They
are created when the method, constructor, or block is entered and destroyed when it
exits. Local variables are only visible within the declared method, constructor, or
block. They have no default value, so they should be declared and assigned an
initial value before the first use.
Instance variables: : These are declared inside a class outside of any method,
constructor, or block. They are created when an object of the class is created and
destroyed when the object is destroyed. Instance variables are accessible to all
methods and constructors of the class. They have a default value, which is 0 for
numeric variables and null for reference variables.

Static variables: : These are declared inside a class with the static keyword. They
are created when the class is loaded into memory and destroyed when the class is
unloaded from memory. Static variables are accessible to all methods and
constructors of the class, as well as to all objects of the class. They have a
default value, which is 0 for numeric variables and null for reference variables.

only global variable can be static but not local variable


==============================================
which will be haivng the default values

byte: 0
short: 0
int: 0
long: 0L
float: 0.0f
double: 0.0d
char: ‘\u0000’ (null character)
boolean: false

====================
what are the predefined classes in java

Predefined classes in Java are classes that are already defined in the Java
standard library and are available for use in your code. Predefined classes are
also known as built-in classes or standard classes. There are many predefined
classes in Java, each with its own set of methods and fields.
Some of the most commonly used predefined classes in Java include:

String: This class represents character strings and provides various methods for
manipulating strings.
Math: This class contains a set of mathematical functions and constants, such as
trigonometric functions, square root, and absolute value.
System: This class provides access to system resources, such as the console and the
file system.
Date: This class represents a date and time.
ArrayList: This class implements a resizable array.
HashMap: This class implements a hash table.
LinkedList: This class implements a linked list.
Predefined classes are a valuable resource for Java programmers, as they provide a
wide range of functionality that can be used to develop a variety of applications.

Here are some additional examples of predefined classes in Java:

Object: This class is the root of all classes in Java.


Class: This class represents a class.
Exception: This class represents an exception.
Thread: This class represents a thread of execution.
File: This class represents a file.
InputStream: This class represents an input stream.
OutputStream: This class represents an output stream.
Reader: This class represents a character-input stream.
Writer: This class represents a character-output stream.

========================

what is super calling statement in java ?

The super calling statement in Java is a statement that is used to call the
constructor of the superclass from the subclass constructor. It is a reserved
keyword that is used to refer to the immediate parent class of the current class.
The syntax for the super calling statement is:

super();

The super calling statement must be the first statement in the subclass
constructor. If it is not, the compiler will generate an error. The super calling
statement can be used with or without arguments. If it is used with arguments, the
arguments must match the parameters of the superclass constructor.
The super calling statement is used to initialize the inherited members of the
subclass. It is also used to ensure that the superclass constructor is always
called, even if the subclass constructor does not explicitly call it.

super.methodName();

You might also like