Interview Questions
1> How will you compare two excel sheets, cell by cell using apache poi
2> Question on random number generation between two limits
3> Can we make post request using get in restful
4> Difference between vi and view in linux
5> What is sed in linux
6> Difference between page object and page factory in selenium
Version Control Systems are just that, software that provides versioning functionality (Git, Subversion, TFS Version Control) all fall into this category.
Software Configuration Management is a broader term that encompasses all the processes needed to build, package, and deploy software -- this includes Version Control Systems. It does not refer to software per se.
Jenkins is a CI tool means Continuous Integration tool. It can also be used as a CD i.e. Continuous deployment tool using Deleivery Pipeline Plugin.
In Continuous Integration, every code commit is build and tested, but, is not in a condition to be released on production servers for UAT.
In Continuous Delivery, the application is continuously deployed on the production servers for UAT Or we can say the application is ready to be released to production anytime.
Version Control Systems are just that, software that provides versioning functionality (Git, Subversion, TFS Version Control) all fall into this category.
Software Configuration Management is a broader term that encompasses all the processes needed to build, package, and deploy software -- this includes Version Control Systems. It does not refer to software per se.
Jenkins is a CI tool means Continuous Integration tool. It can also be used as a CD i.e. Continuous deployment tool using Deleivery Pipeline Plugin.
In Continuous Integration, every code commit is build and tested, but, is not in a condition to be released on production servers for UAT.
In Continuous Delivery, the application is continuously deployed on the production servers for UAT Or we can say the application is ready to be released to production anytime.
/*****************************************************************************/
Ques: Explain error :
Ans: Lets first understand how default constructors are created . If you dont declare a constructor in a class then compiler by default creates a constructor like this:
Class dummy extends dummy2{
dummy(){
super();
}
}
So we get this error because a class which has no constructor, for those classes compiler automatically creates a default argument less constructor.
Since here our parent class test has been given a parameterized constructor and if we do not declare constructor in child class then by default constructor should create default constructor like above but here compiler wont know how to handle arguments in super keyword. Thats why it is asking us to define constructor.
So it can be handled in two ways like below.:
Way 1:
Way2:
Ques.2> Reverse arr 1,2,3,4,5 to 5,4,3,2,1
Ans:
Ques3> Reverse this in this way:
This Is India -> sihT sI aidnI
/*****************************************************************************/
Ques:Why can't static method access 'this' or 'super' in Java?
Ans: A static method belong to class rather than object of class. Now this keyword is a refrence variable which is used to refer current class object. Same way super keyword is a reference variable which is used to refer immediate parent class object.
So we can say this and super keywords both are reference variables that refers to some variable.
In othere words we can say these both keywords belongs to instance of class.
Whereas, static method belong to class rather than instance of class.
That's Why static method cant access this and super keyword in java.
Ques: What are recovery scenarios in QTP?
Ques: Different type of constructors.
Ques: How do you run Sahi from jenkins/cmd.
Ans: From Jenkins
Step:1 First create ant target using sahi editor and save it by name build.xml
Step:2 In build.xml in scriptDir node pass the path where your scripts directories are kept
Step:3 In jenkins configure new job and in build step pass this build.xml path
From cmd
To run sahi suite from cmd prompt go to test runner folder and fire command in this way:
C:\sahi_pro\userdata\bin> testrunner <sahifile/suitefilename> <starturl> <browserType> <tags>
Q: Sahi Pro parallel Execution.
Ans: To run tests parallely using sahi pro on a single machine create a suite file with testcases names in it and from sahi pro editor window open run as and select number of threads and types of browsers to run. Then run.
Ques. How to run sahi scripts on multiple machines.
Ans : Sahi Pro can distribute and run tests on multiple machines (nodes).
drun.bat(windows) and drun.sh(linux) files allow running scripts on multiple machines from the command line.
Open sahi_pro/userdata/bin/drun.bat (drun.sh on linux) using any editor.
Configure the NODES variable to contain all the machines on which the tests should run. The command to set the nodes in Windows
For Windows:
SET NODES=localhost:9999;othermachine:9999;thirdmachine:9999
Now trigger from cmd prompt
c:\sahi_pro\userdata\bin>drun demo.suite http://www.testingsite.com/ chrome+ie+firefox
For more details refer to sahipro documentation site
Ques: What is @Factory in testNG? / How to run parallel instances in testNG? / What is the meaning of running parallel instances in testNG? / How to use dataprovider which is in different class?
Ans:
--@Factory annotation marks method as a factory that returns objects that will be used by TestNG as test classes.
--In testNG xml, for parallel execution in parallel tag we can give classes, methods or instances. If we specify instances in testNG xml then testng will create different instances
of classes per thread and run in that particular thread.
--running parallel instances means running parallel instances of classes in TestNG and parallel instances attribute is applicable in the case of factories that are powered by a data provider and when set would cause the instances produced by a factory to run in parallel
Ques: default and static method in Java8. Which method will be called if two interfaces having same name default method is implemented by a class.
Ans:
Ques: build.gradle
Ans:
Ques: How to convert Maven based Java Project to support Eclipse IDE?
Ans:
Step1: Navigate to your java project folder where pom.xml is present and fire this command:
mvn eclipse:eclipse
Step2: Now you will notice that two new files are created i.e. .classpath and .project ,both the files are created for eclipse ide.
In .classpath file we will have a variable m2_repo, we will have to add this on our build path. m2repo is a variable that defines where maven 2 repository is on our disk.
Step3: Now you can import it in eclipse.
Ques: What maven clean does.
Ans: cleans up artifacts created by prior builds.
Ques: What does .class file contains in Java
Ans: It contains bytecode.
Ques: What does .mvc and .project file contains?
Ans:
Ques: What is pipeline in jenkins?
Ans: Jenkins pipeline is a suite of plugins which supports implementing and integrating continuous delivery pipeline into jenkins.A continuous delivery (CD) pipeline is an automated expression of your process for getting software from version control right through to your users and customers.
Ques: What are default overloded methods in jenkins?
Ans:
Ques: Example where we override some method in java/selenium
Ans: We override apply method of function interface.
Function<WebDriver,Boolean> func = new Function<WebDriver,Boolean>() {
@Override
public Boolean apply(WebDriver arg0) {
// TODO Auto-generated method stub
return null;
}
};
Ques: What is staleelement exception and how do you handle it.
Ans: We get stalelementexception when the element is no longer attached to dom or its references has been changed. This can occur due to navigating back , refreshing page or some ajax section got refreshed.
Example to get this exception:
To solve this :
1> After weblements are initialized, do not refresh the page. If situation comes that page gets refreshed then initialise elements again.
2>We could avoid StaleElementException using POM. In POM, we use initElements() method which loads the element but it won’t initialize elements. initElements() takes latest address. It initializes during run time when we try to perform any action on an element. This process is also known as Lazy Initialization.
3>Other ways are to use explicit waits to wait for element to attach itself to dom in case of Ajax.
Ques: Handling exceptions in testNG?
Ans:
Ques: How to resolve git merge conflicts?
Ans.
Conflict comes when you are trying to push changes on remote server where already some one has meade changes like below:
Step 1: fire command
git pull --rebase origin master
Step3: fire command git am --show-current-patch ,to see the issue
Step4: fir cmd git mergetool
Now press i and edit the file like you do in linux then save all 4 instanses e.g. :wq and press enter 4 times.
Step 5: fire command git rebase --continue
Step 6: fire command git push origin master
##origin is a term for the remote repository and master is the branch there.
##If we don’t mention any priority, testng will execute the @Test methods based on alphabetical order of their method names irrespective of their place of implementation in the code
Ques.: When do u get this error:
Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms.
Ans.: This issue comes when webdriver is of lower version and browser is of higher version and because of this they have got difficulty talking to each other.
Ques: Steps to configure jenkins for maven Project.
Ans.: Configuring jenkins for maven project
1: Download jenkins war file
2: Create a folder for jenkins and paste above war file in there
3: Now open cmd and gotot dir where u have kept this war file and fire command jave -jar <give war file name>
4: Once done launch browser and fire url: localhost:8080 and copy password for command prompt and paste it there..
5: Install suggested plugins
6: If maven plugin not available then install it from manage page of jenkins
7: Click on new item and give your project name then select maven project
8: In source code mangement chhose repository where ur code is available like git/subversive or local
9: Give your projects pom.xml file path
10: In goal and options give - clean install , so maven will first claean and install and then run
11: Click on build now. (We can do many othere things also like scheduling build,triggereing build whenever there is checkin in repository,after execution sending mails to different persons etc.)
Ques.: How do you implement log4J in your project?
Ans.: Log is capturing the information which goes on at the time of execution.
Types of logs
1>info
2>warn
3>error
4>fatal
To generate logs we can use apache log4j api
How it works: it reads log4j configuration from log4j.properties file
Where to create properties file? --create inside resources folder, name it exactly as log4j.properties and in this file give information in the form of key and value pairs
Create object like below in class and use
Logger log = Logger.getLogger(LoginPageTest.class); Here LoginPageTest is the name of the class in which we are creating Logger object.
/*****************************************************************************/
Ques: Explain error :
Ans: Lets first understand how default constructors are created . If you dont declare a constructor in a class then compiler by default creates a constructor like this:
Class dummy extends dummy2{
dummy(){
super();
}
}
So we get this error because a class which has no constructor, for those classes compiler automatically creates a default argument less constructor.
Since here our parent class test has been given a parameterized constructor and if we do not declare constructor in child class then by default constructor should create default constructor like above but here compiler wont know how to handle arguments in super keyword. Thats why it is asking us to define constructor.
So it can be handled in two ways like below.:
Way 1:
Way2:
Ques.2> Reverse arr 1,2,3,4,5 to 5,4,3,2,1
Ans:
Ques3> Reverse this in this way:
This Is India -> sihT sI aidnI
/*****************************************************************************/
Ques:Why can't static method access 'this' or 'super' in Java?
Ans: A static method belong to class rather than object of class. Now this keyword is a refrence variable which is used to refer current class object. Same way super keyword is a reference variable which is used to refer immediate parent class object.
So we can say this and super keywords both are reference variables that refers to some variable.
In othere words we can say these both keywords belongs to instance of class.
Whereas, static method belong to class rather than instance of class.
That's Why static method cant access this and super keyword in java.
Ques: What are recovery scenarios in QTP?
Ques: Different type of constructors.
Ques: How do you run Sahi from jenkins/cmd.
Ans: From Jenkins
Step:1 First create ant target using sahi editor and save it by name build.xml
Step:2 In build.xml in scriptDir node pass the path where your scripts directories are kept
Step:3 In jenkins configure new job and in build step pass this build.xml path
From cmd
To run sahi suite from cmd prompt go to test runner folder and fire command in this way:
C:\sahi_pro\userdata\bin> testrunner <sahifile/suitefilename> <starturl> <browserType> <tags>
Q: Sahi Pro parallel Execution.
Ans: To run tests parallely using sahi pro on a single machine create a suite file with testcases names in it and from sahi pro editor window open run as and select number of threads and types of browsers to run. Then run.
Ques. How to run sahi scripts on multiple machines.
Ans : Sahi Pro can distribute and run tests on multiple machines (nodes).
drun.bat(windows) and drun.sh(linux) files allow running scripts on multiple machines from the command line.
Open sahi_pro/userdata/bin/drun.bat (drun.sh on linux) using any editor.
Configure the NODES variable to contain all the machines on which the tests should run. The command to set the nodes in Windows
For Windows:
SET NODES=localhost:9999;othermachine:9999;thirdmachine:9999
Now trigger from cmd prompt
c:\sahi_pro\userdata\bin>drun demo.suite http://www.testingsite.com/ chrome+ie+firefox
For more details refer to sahipro documentation site
Ques: What is @Factory in testNG? / How to run parallel instances in testNG? / What is the meaning of running parallel instances in testNG? / How to use dataprovider which is in different class?
Ans:
--@Factory annotation marks method as a factory that returns objects that will be used by TestNG as test classes.
--In testNG xml, for parallel execution in parallel tag we can give classes, methods or instances. If we specify instances in testNG xml then testng will create different instances
of classes per thread and run in that particular thread.
--running parallel instances means running parallel instances of classes in TestNG and parallel instances attribute is applicable in the case of factories that are powered by a data provider and when set would cause the instances produced by a factory to run in parallel
Ques: default and static method in Java8. Which method will be called if two interfaces having same name default method is implemented by a class.
Ans:
Ques: build.gradle
Ans:
Ques: How to convert Maven based Java Project to support Eclipse IDE?
Ans:
Step1: Navigate to your java project folder where pom.xml is present and fire this command:
mvn eclipse:eclipse
Step2: Now you will notice that two new files are created i.e. .classpath and .project ,both the files are created for eclipse ide.
In .classpath file we will have a variable m2_repo, we will have to add this on our build path. m2repo is a variable that defines where maven 2 repository is on our disk.
Step3: Now you can import it in eclipse.
Ques: What maven clean does.
Ans: cleans up artifacts created by prior builds.
Ques: What does .class file contains in Java
Ans: It contains bytecode.
Ques: What does .mvc and .project file contains?
Ans:
Ques: What is pipeline in jenkins?
Ans: Jenkins pipeline is a suite of plugins which supports implementing and integrating continuous delivery pipeline into jenkins.A continuous delivery (CD) pipeline is an automated expression of your process for getting software from version control right through to your users and customers.
Ques: What are default overloded methods in jenkins?
Ans:
Ques: Example where we override some method in java/selenium
Ans: We override apply method of function interface.
Function<WebDriver,Boolean> func = new Function<WebDriver,Boolean>() {
@Override
public Boolean apply(WebDriver arg0) {
// TODO Auto-generated method stub
return null;
}
};
Ques: What is staleelement exception and how do you handle it.
Ans: We get stalelementexception when the element is no longer attached to dom or its references has been changed. This can occur due to navigating back , refreshing page or some ajax section got refreshed.
Example to get this exception:
To solve this :
1> After weblements are initialized, do not refresh the page. If situation comes that page gets refreshed then initialise elements again.
2>We could avoid StaleElementException using POM. In POM, we use initElements() method which loads the element but it won’t initialize elements. initElements() takes latest address. It initializes during run time when we try to perform any action on an element. This process is also known as Lazy Initialization.
3>Other ways are to use explicit waits to wait for element to attach itself to dom in case of Ajax.
Ques: Handling exceptions in testNG?
Ans:
Ques: How to resolve git merge conflicts?
Ans.
Conflict comes when you are trying to push changes on remote server where already some one has meade changes like below:
Step 1: fire command
git pull --rebase origin master
Step3: fire command git am --show-current-patch ,to see the issue
Step4: fir cmd git mergetool
Now press i and edit the file like you do in linux then save all 4 instanses e.g. :wq and press enter 4 times.
Step 5: fire command git rebase --continue
Step 6: fire command git push origin master
##origin is a term for the remote repository and master is the branch there.
##If we don’t mention any priority, testng will execute the @Test methods based on alphabetical order of their method names irrespective of their place of implementation in the code
Ques.: When do u get this error:
Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms.
Ans.: This issue comes when webdriver is of lower version and browser is of higher version and because of this they have got difficulty talking to each other.
Ques: Steps to configure jenkins for maven Project.
Ans.: Configuring jenkins for maven project
1: Download jenkins war file
2: Create a folder for jenkins and paste above war file in there
3: Now open cmd and gotot dir where u have kept this war file and fire command jave -jar <give war file name>
4: Once done launch browser and fire url: localhost:8080 and copy password for command prompt and paste it there..
5: Install suggested plugins
6: If maven plugin not available then install it from manage page of jenkins
7: Click on new item and give your project name then select maven project
8: In source code mangement chhose repository where ur code is available like git/subversive or local
9: Give your projects pom.xml file path
10: In goal and options give - clean install , so maven will first claean and install and then run
11: Click on build now. (We can do many othere things also like scheduling build,triggereing build whenever there is checkin in repository,after execution sending mails to different persons etc.)
Ques.: How do you implement log4J in your project?
Ans.: Log is capturing the information which goes on at the time of execution.
Types of logs
1>info
2>warn
3>error
4>fatal
To generate logs we can use apache log4j api
How it works: it reads log4j configuration from log4j.properties file
Where to create properties file? --create inside resources folder, name it exactly as log4j.properties and in this file give information in the form of key and value pairs
Create object like below in class and use
Logger log = Logger.getLogger(LoginPageTest.class); Here LoginPageTest is the name of the class in which we are creating Logger object.
/*****************************************************************************/
No comments:
Post a Comment