Professional Documents
Culture Documents
https://www.softwaretestingmaterial.com
GainSight - Done
WHat is an Interface?
What are the selenium dependencies that required to be configured into the
framework.
What is the logic that should be written in step definition i.e how data tables is
passed in step definition logic. Scenario outline case.
How to get the data and compare in web tables.
Parameterized constructors.
How an object is instantiated?
Ex: public class Demo{
Demo d = new Demo()
What is Demo()? Method or constructor?
Infor - Done
How can you findout automation test cases?
Sol:1) 1. Test case executed with different set of data
2. Test case executed with different browser
3. Test case executed with different environment
4. Test case Involves large amount of data
5. Test case has any dependency
Sol2) 1.Identify the modules of your application which you want to automate because
you are not supposed to automate each and every module. For e.g. if
there are any modules which can be tested manually more effectively or in less
time, So there is no need to include these modules in automation.�
2. Once you identify the modules, first try to work with positive scenarios and
then negative (NOT MUCH), mainly focuses on test data(Which test data you
need to work with), because using different frameworks you can run a single scripts
with multiple set of data[Including positive or negative].
How can you transfer the money at a time? Example: Axis bank
How can you manage all the data in the framework?
Write the logic for the sorting of a string without using sort method.
How can you select the dropdown?
What is jenkins?
l Where duplicate values are allowed?
What is cucumber?
What is the difference between Usecase and Scenario?
How to connect db using selenium?
Zettamine -
first framework adigaru
java concepts emi use chesaru framework lo annaru
difference between find Element and findElements
write a dynamic xpath annadu
fibonnaci program
string reverse program adigadu
SQL basics ani cheppu. so basic level adiugadu
select and updte statement adigadu
implicit and explicit wait adigadu
Agile ante enti ani adigadu
SDLC and STLC stages cheppamannadu
elements locators priority cheppamnnadu
first id, class last lo xpath ala cheppamnnadu
mana framework lo Collections emi use chesamu andi adigadu
List, Hash Map
Points to remember:
1. Abstract classes may or may not include abstract methods
2. If a class is declared abstract then it cannot be instantiated. If instantiated:
Abstract Method:
An abstract method is a method that is declared without an implementation (without
braces, and followed by a semicolon),
like this: abstract void myMethod();
In order to use an abstract method, you need to override that method in sub class.
We use abstraction when we know that our class should have some methods but we are
not sure how exactly those methods should
function. Assume, I am creating a class of Vehicle which should have a method
called start(). There will be some other
subclass of this Vehicle class such as Car, Bike and these two subclasses use
start() method. But the implementation
of start() method in Car is different from Bike. So in this case I don�t implement
the start() method in Vehicle class
and implement those in subclasses.
Abstract classes doesn�t give 100% abstraction since abstract class allows
concrete methods. With abstract class we can
achieve partial abstraction where as we can achieve 100% abstraction with
interface.
b. Encapsulation:
Group all relevant things together. I.e. encapsulation is wrapping/binding up of
data and member functions in single
unit. In simple, abstraction is hiding the implementation and encapsulation is to
hide data.
package encapsulationClass;
package encapsulationClass;
public class EncapsulationClassTwo {
In the above example, you can find all the data member (variables) are declared as
private. If the data member is
private it means it can only be accessed within the same class. No other class can
access these private variables of
other class. To access these private variables from other classes, we used public
getter and setter methods such as
getAge(), getName(), setAge(), setName(). So, the data can be accessed by public
methods when we can set the variables
private and hide their implementation from other classes. This way we call
encapsulation as data hiding.
8. What is a String?
9. Why String is immutable?
10. Given two strings and used concat() method asked output.
11. Difference between quit() and close()
quit - This method is used to destroy the instance of WebDriver. It closes all
Browser Windows associated with that
driver and safely ends the session.
close - This method is used to close the current open window. It closes the
current open window on which driver has
focus on.
The following are the Expected Conditions that can be used in Explicit Wait
alertIsPresent()
elementSelectionStateToBe()
elementToBeClickable()
elementToBeSelected()
frameToBeAvaliableAndSwitchToIt()
invisibilityOfTheElementLocated()
invisibilityOfElementWithText()
presenceOfAllElementsLocatedBy()
presenceOfElementLocated()
textToBePresentInElement()
textToBePresentInElementLocated()
textToBePresentInElementValue()
titleIs()
titleContains()
visibilityOf()
visibilityOfAllElements()
visibilityOfAllElementsLocatedBy()
visibilityOfElementLocated()
Frequency: Setting up a repeat cycle with the time frame to verify/check the
condition at the regular interval of time
.withTimeout(30, TimeUnit.SECONDS)
.pollingEvery(5, TimeUnit.SECONDS)
.ignoring(NoSuchElementException.class);
What is Thread.sleep()
It will make the script to halt for given seconds eventhough the page is loaded as
expected.
driver.navigate().to("http://www.example.com");
To reiterate: navigate().to() and get() do exactly the same thing.
The navigate interface also exposes the ability to move backwards and forwards in
your browser�s history:
driver.navigate().forward();
driver.navigate().back();
findElement();
close();
getClass(); and many more
Ex:
// It will get and store the main window page handle or id
String mainpage = driver.getWindowHandle();
String subwinhandleString = null;
//set a loop which will store all window pop up handles
Set<String> handle = driver.getWindowHandles();
Iterator<String> iterator = handle.iterator();
while(iterator.hasNext ()) {
subwinhandleString = iterator.next( );
}
driver.switchTo().window(subwinhandleString);
System.out.println(driver.getTitle());
Thread.sleep(2000);
driver.close();
//Again switch back to main window
driver.switchTo().window(mainpage);
System.out.println(driver.getTitle());
}
}
How to read the data from properties file using Java selenium?
'.properties' files are mainly used in Java programs to maintain project
configuration data, database config or project
settings etc. Each parameter in properties file are stored as a pair of strings, in
key and value format, where each
key is on one line. You can easily read properties from some file using object of
type Properties.
Ex:
public static void main(String[] args) {
File file = new File("D:/Dev/ReadData/src/datafile.properties");
driver.findElement(By.id("Email")).sendKeys(prop.getProperty("username"));
driver.findElement(By.id("Passwd")).sendKeys(prop.getProperty("password"));
driver.findElement(By.id("SignIn")).click();
System.out.println("URL ::" + prop.getProperty("URL"));
driver.switchTo().window(ids.get(2));
driver.findElement(By.xpath("")).isDisplayed();
driver.close();
//Now lets switch to parent window. Most probably parent window will be stored in
the index of 0.
driver.switchTo().window(ids.get(0));
Code:
//Used tagName method to collect the list of items with tagName "a"
//findElements - to find all the elements with in the current page. It returns a
list of all webelements or an empty list if nothing matches
List<WebElement> links = driver.findElements(By.tagName("a"));
//To print the total number of links
System.out.println("Total links are "+links.size());
//used for loop to
for(int i=0; i<links.size(); i++) {
WebElement element = links.get(i);
//By using "href" attribute, we could get the url of the requried link
String url=element.getAttribute("href");
//calling verifyLink() method here. Passing the parameter as url which we
collected in the above link
//See the detailed functionality of the verifyLink(url) method below
verifyLink(url);
}
}
// The below function verifyLink(String urlLink) verifies any broken links and
return the server status.
public static void verifyLink(String urlLink) {
//Sometimes we may face exception "java.net.MalformedURLException". Keep
the code in try catch block to continue the broken link analysis
try {
//Use URL Class - Create object of the URL Class and pass the urlLink as parameter
URL link = new URL(urlLink);
// Create a connection using URL object (i.e., link)
HttpURLConnection httpConn =(HttpURLConnection)link.openConnection();
//Set the timeout for 2 seconds
httpConn.setConnectTimeout(2000);
//connect using connect method
httpConn.connect();
//use getResponseCode() to get the response code.
if(httpConn.getResponseCode()== 200) {
System.out.println(urlLink+" - "+httpConn.getResponseMessage());
}
if(httpConn.getResponseCode()== 404) {
System.out.println(urlLink+" - "+httpConn.getResponseMessage());
}
}
//getResponseCode method returns = IOException - if an error occurred connecting
to the server.
catch (Exception e) {
//e.printStackTrace();
}
}
}
select.deselectAll();
select.deselectByIndex(1);
select.deselectByValue("valuesName");
select.deselectByVisibleText("textName");
What are the java script functions for selenium object location
following-sibling
preceding-sibling
starts-with()
ends-with()
following
preceding
contains
css:
nth-child(1)
$ (starts-with)
^ (ends-with)
Explaining framework:
Root folder: POMProject where it has two sub packages src/main/java and
src/test/java
Why src/main/java?
1. It will have only java code which will support to execute the framework.
2. As we know that every test case will have certain parameters that is common
accross for that we need to design a testBase
In testBase, We can write how to navigate to the browser, how to select the
browser, reading the data from the properties file,
maximizing the browser,reading data from external source, waits. Simply it will
drive our framework.
3. What is config
Whenever we do automation there are certain parameters that is fixed for all the
scripts.
For Example: We have an username, password, url, browser these four parameters are
fixed. Inside the config we can create
the properties file say OR.properties and place these four parameters.
What is the need of that?
Say that these properties file will be consumed by all the test scripts. Apart from
that, In the framework lets say
there is database connectivity. Database will have certain set of properties like
db url, username, password, db drivers
all these can be placed in OR.properties
Then what is APP.properties?
Here we can write application specific verifications Ex: Application Text
What is excelReader
It will help us to read the data from the excel sheet and supply to the test
scripts. When there is a dependency to get
the data from external source we can define all the methods in Excel_Reader class
What is pageActions
Here we will define all the pages present in the application and define the
specific methods related to the particular
page Ex: loginPage, HomePage, BagPage, PaymentsPage etc
What is customListener
This Listener class will be provided by testNG and whenever a failure occurs in the
test scripts it will capture the screenshots
nd will attach to the Html report or testnG report
What is data
The data which will be used by all the test scripts it can be either excel sheet or
xml or properties file.
What is report
When we run automation scripts, At the end of run need to generate a report.
What is screenShot
Whenever a test case is passed or failed the screenshots will be saved for the
proof of evidence
Why src/test/java?
1. It will have only test scripts which we will execute using testNG or JUnit
What is testScripts
Based on the pages which we have a module is created for each page and the
corresponding test cases will be written
What are the different dependencies you will be using with cucumber?
cucumber-java
cucumber-jvm
cucumber-junit
cucumber-jvm-deps
cucumber-reporting
gherkin
junit
selenium java
Natural plugin - Search in market eclipse place, If not google it and just drag and
drop in opened eclipse
CTS:
Pennant:
Jenkins:
**To generate proper Extent/HTML Report in Jenkins, use following script in Script
Console of Jenkins:
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "")
What is log?
Capturing info/activities at the time of program execution.
How it works?
It reads log4j configuration from log4j.properties file
Where to create?
Create inside resources folder(Create a source folder as src/main/resources).
Oracle:
STLC
Diff b/w SDLC and STLC
CTS:
Prithvi say that - As per my knowledge term incase you are not confident enough.
Sample code:
try {
FileReader reader = new FileReader(dataFilePath + dataFileName);
{
"Name": "crunchify.com",
"Author": "App Shah",
"Company List": [
"Compnay: eBay",
"Compnay: Paypal",
"Compnay: Google"
]
}
Step 3) Send the query to database using execute query and store the results in the
ResultSet object.
ResultSet rs = stmt.executeQuery(select * from employee;)
Oracle:
1. There is a file sample.txt which has the text "Selenium automation and Java
automation are not easy as you think".
How to read the file and finding the duplicate words and repitition of duplicate
letters.
2. factorial of a number using Recursive program
3. Bubblesort
4. Common code to select the checkbox(Male and Female)
<div>
<label> Male <label>
<type> checkbox <type>
<div>
<div>
<label> Female <label>
<type> checkbox <type>
<div>
5. There are two tables Employee and Department. Get all the employee details from
the department QA.
Method � 1:
� Iterate row and column and get the cell value.
� Using for loop
� Get total rows and iterate table
� Put if(string matches) then select the respective checkbox
� Lengthy method
Method � 2:
� Using custom XPath
� Using parent and preceding-sibling tags
� No need to write for loop
� No full iteration of table
� Single line statement
� More dynamic
� Efficient and fast
Refer:
F:\java_workspace\Shutterbug\src\main\java\seleniumSessions\DynamicWebTableHandle.j
ava
ZenQ-
1. screenshot code.
2. There is an integer int a = 132. Print in string format.
3. Git commands.
4. testNG.xml file. What is it and how its useful?
5. Maven - What is dependency(inside the dependency)?
6. OOPS concepts.
7. Implicit wait and Explicit wait(When it will be used)
7. testNG.
8. Do you know about listeners.
9. How to access the data from excel sheets?
10. There is a method add. when a child class having the same method and it extends
parent class. Does it throws CE?
11. Is there any overloaded methods in selenium?
12. How can you perform parallel execution without using selenium grid?
1. StaleElementException
2. How to handle uploading documents.
3. Git commands
4. Rerunning failed scenarios.
5. Json wire protocol
6.