Sel 1
Sel 1
Workbook w b = WorkbookFact
Ans- it is used to find the WebElement in web page. It is very useful to identify the dynamic web
elements.
Ans- There are 8 types of locators and all are the static methods of the By class.
Ans- Assert- it is used to verify the result. If the test case fail then it will stop the execution of the
test case there itself and move the control to other test case.
Verify- it is also used to verify the result. If the test case fail then it will not stop the execution of
that test case.
Ans- use submit() method but it can be used only when attribute type=submit.
Syntax
driver.findElement(By.xpath("xp
If the return value of this method is true then it is checked else it is not.
Ans- To handle alert pop-ups, we need to 1st switch control to alert pop-ups then click on ok or
cancle then move control back to main page.
Syntax-
Ans- Before launching IE or Chrome browser we need to set the System property.
System.setProperty(w ebdriver
act.moveToElement(w ebElemen
driver.findElement(By.xpath(inp
Ques 14) How do you click on a menu item in a drop down menu?
Ans- If that menu has been created by using select tag then we can use the methods
selectByValue() or selectByIndex() or selectByVisibleText(). These are the methods of the
Select class.
If the menu has not been created by using the select tag then we can simply find the xpath of that
element and click on that to select.
driver.navigate().back();
driver.navigate().forw ard();
1 driver.navigate().back();
2
3 driver.navigate().forward();
driver.getCurrentUrl();
1 driver.getCurrentUrl();
Ans- Both methods are abstract method of WebDriver interface and used to find the
WebElement in a web page.
findElement() it used to find the one web element. It return only one WebElement type.
findElements()- it used to find more than one web element. It return List of WebElements.
Syntax- driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
Here it will wait for 10sec if while execution driver did not find the element in the page
immediately. This code will attach with each and every line of the script automatically. It is not
required to write every time. Just write it once after opening the browser.
Ques 20) Write the code for Reading and Writing to Excel through Selenium ?
Workbook w b = WorkbookFact
1 FileInputStream fis = new FileInputStream(path of excel file);
2
3 Workbook wb = WorkbookFactory.create(fis);
4
5 Sheet s = wb.getSheet("sheetName");
6
7 String value = s.getRow(rowNum).getCell(cellNum).getStringCellValue(); // read data
8
9 s.getRow(rowNum).getCell(cellNum).setCellValue("value to be set"); //write data
10
11 FileOutputStream fos = new FileOutputStream(path of file);
12
13 wb.write(fos); //save file
Ques 22) What are the different exceptions you got when working with WebDriver ?
Ans- Python, Ruby, C# and Java are all supported directly by the development team. There are
also webdriver implementations for PHP and Perl.
driver.findElement(By.xpath("xp
1 driver.findElement(By.xpath("xpath of box")).clear();
Maintaining consistency of Testing, Improves test structuring, Minimum usage of code, Less
Maintenance of code, Improve re-usability, Non Technical testers can be involved in code,
Training period of using the tool can be reduced, Involves Data wherever appropriate.
Ans- JDK, Eclipse, WebDriver(selenium standalone jar file), browser, application to be tested.
Ans- a) It supports with most of the browsers like Firefox, IE, Chrome, Safari, Opera etc.
b) It supports with most of the language like Java, Python, Ruby, C# etc.
Ans- WebDriverBackedSelenium is a kind of class name where we can create an object for it as
below:
Selenium w bdriver= new WebD
The main use of this is when we want to write code using both WebDriver and Selenium RC , we
must use above created object to use selenium commands.
driver.get(url); or driver.naviga
1 driver.get(url); or driver.navigate().to(url);
Ans- Selenium-Grid allows you to run your tests on different machines against different
browsers in parallel. That is, running multiple tests at the same time against different machines,
different browsers and operating systems. Essentially, Selenium-Grid support distributed test
execution. It allows for running your tests in a distributed test execution environment.
Ques 33) What is the command line we have to write inside a .bat file to execute a selenium
project when we are using testng ?
Ques 34) Which is the package which is to be imported while working with WebDriver ?
Ans- org.openqa.selenium
Ans- use isDisplayed() method. The return type of the method is boolean. So if it return true then
element is visible else not visible.
driver.findElement(By.xpath("xp
1 driver.findElement(By.xpath("xpath of elemnt")).isDisplayed();
Ans- Use isEnabled() method. The return type of the method is boolean. So if it return true then
button is enabled else not enabled.
driver.findElement(By.xpath("xp
1 driver.findElement(By.xpath("xpath of button")).isEnabled();
Here if both color and back color different then that means that element is in different color.
Ques 38) How to check the checkbox or radio button is selected ?
Ans- Use isSelected() method to identify. The return type of the method is boolean. So if it
return true then button is selected else not enabled.
driver.findElement(By.xpath("xp
1 driver.findElement(By.xpath("xpath of button")).isSelected();
Syntax- driver.getTitle();
1 Syntax- driver.getTitle();
driver.findElement(By.xpath(xp
driver.findElement(By.xpath(xp
Similarly you can get CSS properties of any tag by using getCssValue(some propety name).
1
2
3 Ans- Identify by getCssValue(border-bottom) or sometime getCssValue(text-decoration)
4 method if the
5
6 cssValue is 'underline' for that WebElement or not.
7
8 ex- This is for when moving cursor over element that is going to be underlined or not-
9
1 public class UnderLine {
0
1 public static void main(String[] args) {
1
1 WebDriver driver = new FirefoxDriver();
2
1 driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
3
1 driver.get("https://www.google.co.in/?gfe_rd=ctrl&ei=bXAwU8jYN4W6iAf8zIDgDA
4 &gws_rd=cr");
1
5 String cssValue= driver.findElement(By.xpath("//a[text()='Hindi']")).getCssValue("text-
1 decoration");
6
1 System.out.println("value"+cssValue);
7
1 Actions act = new Actions(driver);
8
1 act.moveToElement(driver.findElement(By.xpath("//a[text()='Hindi']"))).perform();
9
2 String cssValue1= driver.findElement(By.xpath("//a[text()='Hindi']")).getCssValue("text-
0 decoration");
2
1 System.out.println("value over"+cssValue1);
2
2 driver.close();
2
3 }
2
4 }
2
5
2
6
2
7
2
8
2
9
3
0
3
1
3
2
3
3
Ques 43) How to change the URL on a webpage using selenium web driver ?
driver.get(url1);
driver.get(url2);
1 driver.get(url1);
2
3 driver.get(url2);
act.moveToElement(w ebelemen
Ans- getOptions() is used to get the selected option from the dropdown list.
Ans- SearchContext.
Ans- close() it will close the browser where the control is.
Pg--2
Ans Yes we can enter text without using sendKeys() method. We have to use combination of
javascript and wrapper classes with WebDriver extension class, check the below code-
driver.executeScript("argu
Syntax-EventFiringWebDriver e
Ques 4) How to login into any site if its showing any authetication popup for user name and
pass ?
Ans pass the username and password with url.
Syntax- http://username:passw
ex- http://creyate:jamesbond007
1 Syntax- http://username:password@url
2
3 ex- http://creyate:[email protected]
Ans- HtmlUnitDriver.
Ques 6) Open a browser in memory means whenever it will try to open a browser the
browser page must not come and can perform the operation internally.
ex-
h) An xml file can be generated to execute the entire test suite. In that xml file we can rearrange
our execution order and we can also skip the execution of particular test case.
Ans-
Ans- use click() or submit() [submit() can be used only when type=submit]) method for
ENTER. Or use Actions class to press keys.
For Enter-
act.sendKeys(Keys.RETURN);
1 act.sendKeys(Keys.RETURN);
For Tab-
act.sendKeys(Keys.ENTER);
1 act.sendKeys(Keys.ENTER);
Ans- Datadriven framework- In this Framework , while Test case logic resides in Test Scripts,
the Test Data is separated and kept outside the Test Scripts.Test Data is read from the external
files (Excel File) and are loaded into the variables inside the Test Script. Variables are used both
for Input values and for Verification values.
Ques 11) While explaining the framework, what are points which should be covered ?
Ans-
d) Architecture.
1 Syntax driver.switchTo().defaultContent();
Ques 13) How to type text in a new line inside a text area ?
ex- w ebelement.sendKeys(Sa
Sanjay_Line1.
Sanjay_Line2.
Ans- Some times while doing testing with selenium, we get stuck by some interruptions like a
window based pop up. But selenium fails to handle this as it has support for only web based
application. To overcome this problem we need to use AutoIT along with selenium script.
AutoIT is a third party tool to handle window based applications. The scripting language used is
in VBScript.
act.doubleClick(w ebelement);
Ans-
w ebelement.sendKeys(press);
Ans- getWindowHandles()- is used to get the address of all the open browser and its return type
is Iterator<String>.
getWindowHandle()- is used to get the address of the current browser where the conrol is and
return type is String.
Ques 19) How do you accommodate project specific methods in your framework ?
Ans- 1st go through all the manual test cases and identify the steps which are repeating. Note
down such steps and make them as methods and write into ProjectSpecificLibrary.
Ans-
a) It does not supports looping or conditional statements. Tester has to use native languages to
write logic in the test case.
b) It does not supports test reporting, you have to use selenium RC with some external reporting
plugin like TestNG or JUint to get test execution report.
c) Error handling is also not supported depending on the native language for this.
Ans-
List<webElement> chkBox =
1
driver.findElements(By.xpath(//htmltag[@attbute='checkbox']));
2
3
for(int i=0; i<=chkBox.size(); i++){
4
5
chkBox.get(i).click();
6
7
}
Ans- use the locator By.tagName and find the elements for the tag //a then use loop to count the
number of elements found.
Ques 25) How do you identify the Xpath of element on your browser ?
And- to find the xpath , we use Firebug addons on firefox browser and to identify the xpath
written we use Firepath addons.
Syntax- //htmltag[@attname='att
Ans- WebDriver is the name of the key interface against which tests should be written in Java.
All the methods of WebDriver have been implementated by RemoteWebDriver.
Ans- Selenium IDE is a complete integrated development environment (IDE) for Selenium tests.
It is implemented as a Firefox Add-On, and allows recording, editing, and debugging tests. It
was previously known as Selenium Recorder.
Scripts may be automatically recorded and edited manually providing autocompletion support
and the ability to move commands around quickly.
Scripts are recorded in Selenese, a special test scripting language for Selenium. Selenese
provides commands for performing actions in a browser (click a link, select an option), and for
retrieving data from the resulting pages.
Ans- selenium IDE, selenium RC, Selenium WebDriver and Selenium Grid.
Ans- Its an open source Web Automation Tool. It supports all types of web browsers. Despite
being open source its actively developed and supported.
Ans- Selenium RC injects javascript function into browsers when the web page is loaded.
Ans-
a) Native automation faster and a little less prone to error and browser configuration,
Ans- xpath.
Ques 35) what are the different assertions or check points used in your script ?
Ques 38) What are the different attributes for @Test annotation ?
ex- @Test(expectedExceptions
@Test(timeOut = 2000)
Ans- yes.
Ans- An object repository is a very essential entity in any UI automation tool. A repository
allows a tester to store all the objects that will be used in the scripts in one or more centralized
locations rather than letting them be scattered all over the test scripts. The concept of an object
repository is not tied to WET alone. It can be used for any UI test automation. In fact, the
original reason why the concept of object repositories were introduced was for a framework
required by QTP.
Ans-
a) Encapsulation,
b) Abstraction,
c) Polymorphism,
d) Inheritance.
Ans- Inherit the feature of any class by making some relations between the class/interface is
known as inheritance.
Ans- The methods by passing different arguments list/type is known as overloading of methods
while having the same method signature with different method body is known as method
overriding.
Ans- Interface supports multiple inheritance but class does not support.
Ans-
Ans-
Ans- Reasons-
a) Manual testing of all work flows, all fields, all negative scenarios is time and cost consuming.
c) Automation does not require human intervention. We can run automated test
unattended(Overnight).
Ans- A Test Strategy document is a high level document and normally developed by project
manager. This document defines Software Testing Approach to achieve testing objectives. The
Test Strategy is normally derived from the Business Requirement Specification document.
Ans-
try{
Assert.assertEquals(expUserN
1 try{
2
3 Assert.assertEquals(expUserName, actUserName);
4
5 }catch(Exception e){
6
7 Syste.out.println(name is invalid);
8
9}
Pg-3
JAVA
Selenium
JAVA
Selenium
Manual Testing
--------------
1. What is the difference between Whitebox and Blackbox testing?
2. What is Agile Methodology? What is Scrum,Sprint?Have you used it?
3. Who will be involved in Agile testing meeting?
4. What is DSR ,WSR?(status reports)
5. Have you done monthly Test plan?
6. Do you know Web testing?
7. Write a program to print to select all columns from Employees table and Departments table
where Department name is "Testing"
8. How many years you have in Manual testing,Automation testing?
9. Have you done testing for Redbus application?
10. Write out some positive and negative scenarios to test "Add Friend" feature in Facebook?
11. What is the test design you have used to write test cases?
12. Imagine you are given a Bank Account Login Page. (userid,password,account no, Submit
button). List out two positive scenarios to test it?
EBay:
3. write functional test cases for " you have three field A, B, C and one ok button field can
take only two character if by using the fields the triangle is formed then ok button must
display valid triangle else invalid triangle.
5. some logical puzzles he asked like :-
a> how to measure 4 lt. if u have 2 container of 5 and 3 lt.
b> 3 bulb and 3 switch puzzle
c> car parking no. puzzle
6. what is the use of cookies and cache.
7. how to remove cookies
9. if you have opened any web application and it is broken means it has changed its layout
and other thing which type of testing you will perform to check this
Happiest Minds:
1.Explain your prevoius project, ur role
2.how u rate ur self in java?
3.Overloading and Overriding ...when u use overLoading and Overriding.
4.What is singleton and have used singleton concept in ur project ??
5.What is TestNG framework and what annotations u have worked on.
6.Write a syntax for the dataprovider in TestNg?
7.What are the frameworks u are aware of?
8.What are issues u faced in ur project while automation
9.Have u followed the agile methodology??What will u do if u find the bug at the end of
the sprint and how fast will u make sure that the bug is fixed and verified.
10.Have u done compatibility testing ?? what all browsers u have used?
11.How do u run the scripts on other browser like IE,Chrome,write the code
12.what are exceptions u have handled in selenium webdriver
******************************************************************************
*********************************************************************
Cognizant Interview Question
He give Programes
-----------------------------------
1.Reverse a number
2.1,2,3,4,5,65,76,5,,4,33,4,34,232,3,2323,
find the biggest number among these
simple string programe.
what is exception, types of exception
From manual
----------------------------------
what is the testcase technique
why we write test case.
bug life cycle
what are the different status of bug
what is the different between functional and smoke testing
what is STLC.
from Selenium
=======================================
what is testng and its advantage
how to handle SSl/
how to handle alert
how to take screenshot
give the diagram write a scrpt..
tell me about Project .What are the challenge face during project
what is the difference between RC and webdriver
what is freamwork explain it.
why we use wait statement.
2nd technical
he gives a application & tell to write the scenario
some manual testing concepts.
===================================
CaterPiller
EF Systems
Happiest Minds
1.Explain ur FramwWork
2.How u will run tests parallely
3.pgm to search ipod in flipkart and sort the results in ascending order based on price
4.give examples for Checked exception and Runtime Exception.
5.Some time application takes 2 sec to load some time 30 sec some times more than 5 min
how u will handle this.**
6.wat is maven and wat is ant
COGNIZANT Questions:
1.Brief Description
2.How will you rate yourself in Selenium.
3.SIDE
4.How will you handle pop-up.
5.Which framework you are using in your project & why.
6.How will you handle java script pop-up.
7.How will you handle SSL issue
8.How will you take screenshot.
9.How will you handle AJAX?Explain it with code.
10.Explain your framework.
11.What is STLC,Test Plan & Defect Life Cycle(Procedure to file a defect)
12.traceability matrix
13.Selenium Grid concepts with code ?RC
14.Project Description
15.Diff between Implicitly Wait and Explicitly Wait
16. When will you stop testing
17.Thread 7 Synchronization in java
18.why you switched three companies in 3 years.
2. What you do with your code when a new version of browser is launched?
3. What are the features in your automation code?
4. How to integrate HPALM/HPQC with Selenium?
5. How you are sending the emails from framework, as .rar files are blocked in most of the
companies?
6. How code review is done for your code?
Erricson:
Tavant:
Happiest Minds
1.Explain ur FrameWork
2.How u will run tests parallely
3.pgm to search ipod in flipkart and sort the results in ascending order based on price
4.give examples for Checked exception and Runtime Exception.
5.Some time application takes 2 sec to load some time 30 sec some times more than 5 min
how u will handle this.
6.wat is maven and wat is ant
Maven is dependance tool (used to download latest jar from internet before running)
ANT is Build tool
7.In a String remove duplicate words and duplicate characters.
8.what is checked exception and gve example
Exception which are verified by the compiler before the compilation and it makes it
mandatory to try-catch or throws.
are checked exception example InvalidFormatException, IOException,
InterruptedException
9.Script to find ipad in flipkart and the results should store in ascending order
Tavant
CaterPiller
EF Systems
3D PLM:
Selenium
1. Introduce yourself?
2. STLC?
3. What is Interface and Abstract Class?
4. Can we create an object of Abstract class?
5. What are the types of Automation frameworks we have? Can u explain them?
6. What is a sub Query?
7. What are Joins?
8. Queries on Joins and Sub-Query?
9. What is TestNG? Why we use it in Selenium?
10. Explain Automation Framework?
11. Program on Prime Number?
12. SDLC?
13. Program to Read and Write data in to Excel Sheet?
14. How to Right Click in Selenium?
Manager Round
1. About Yourself?
2. Why Testing U r from Electronics Background right?
3. Qualities of Good Test Engineer?
4. Challenges in Testing?
5. Objectives of Developer and Test Engineer?
6. About Family?
7. Explain frame Work?
HappyestMind& Ness
Selenium
Java
Hi Guys,
https://addons.mozilla.org/en-US/firefox/addon/element-locator-for-webdriv/
Steps:
Its very useful to you to develop/create Xpaths and writing the Selenium code.
It saves lot of time
1. If there is a priority bug from production how do you address when the Sprint is in
progress?
2. What is the level of involvement of Management in a Scrum team?
3. After a Sprint ends when the planning for next sprint begins?
4. Have you created VBA macros to update status of multiple test cases in QC?
5. I had DB2 exp in resume - so he asked me to write a join query invoving table A & B
where only the values from table B be retrieved excluding those rows from B having
matching rows in A.
6. What are the challenges you faced while creating framework?
7. Have you used Selenium Grid?
8. Have you run tests in parallel?
9. How will you wait until all the elements in a page gets loaded, the page is completely
dynamic and you cannot guess which will be the last element to load.
10. When tests run in parallel how will Webdriver know that it has to work on a particular
Browser window only?
11. When you move from one page to another how will you ensure that the proper page is
loaded?
12. How will you drag and drop an element in a webpage?
13. If the element for which you are waiting for is not loaded, how will you handle the
same?
14. How selenium interacts with Firefox, Chrome and IE (internal aspects)?
15. Have you used Javascript Executor in your scripting?
16. Why is main method Static?
17. Can the main method have return type other than void? (Yes it can, it can have return
type int to provide info about successful execution, this info can be used in batch file/shell
scripting - interviewers answer)
18. I was given a Unstable system of a Agile toolkit (its like our Jira) and was aked to list
down the scenarios for testing Task Creation and editing the same. Also I was asked to find
the bugs.
19. For the above scenario (point 18), I was asked to automate Task Creation and drag &
drop of task from 'To Do' to 'In Progress'. This has to be done alongside with TestNG
framework.
I was given 2hrs for performing point 18 & 19.
Mind tree