Wipro Selenium Interview Questions
Here is the list of Selenium Interview Questions which are recently asked in Wipro company. These questions are included for both Freshers and Experienced professionals. Our Selenium Training has Answered all the below Questions.
Round 1:
1. Tell about Yourself.
Answer according to your profile and experience.
2. Automation experience in your project
3. What is Xpath? and Write Xpath for given scenario. [Navigate upwards]
XPath known as the XML path is a language that helps to query the XML documents. It consists of expression for a path along with certain conditions to locate a particular element.
4. Write xpath of two text boxes which don’t have any locators to find.
5. How to select value from Dropdown?
Syntax of select value from dropdown Select dropdown = new Select(driver.findElement(By.id("identifier")));
6. What are the Waits in selenium and explain briefly. Write code of each. [ImplicitlyWait, Sleep, WebdriverWait]
Implicit wait:
package credo;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
public class AppTest {
protected WebDriver driver;
@Test
public void credosystemz() throws InterruptedException
{
System.setProperty ("webdriver.chrome.driver",".\\chromedriver.exe" );
driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS) ;
String eTitle = "credosystemz";
String aTitle = "" ;
// launch Chrome and redirect it to the Base URL
driver.get("https://www.credosystemz.com/" );
//Maximizes the browser window
driver.manage().window().maximize() ;
//get the actual value of the title
aTitle = driver.getTitle();
//compare the actual title with the expected title
if (aTitle.equals(eTitle))
{
System.out.println( "Test Passed") ;
}
else {
System.out.println( "Test Failed" );
}
//close browser
driver.close();
}
}
Explicit code:
package credo;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.Test;
public class AppTest2 {
protected WebDriver driver;
@Test
public void credosystemz() throws InterruptedException
{
System.setProperty ("webdriver.chrome.driver",".\\chromedriver.exe" );
driver = new ChromeDriver();
WebDriverWait wait=new WebDriverWait(driver, 20);
String eTitle = "Credo Page";
String aTitle = "" ;
// launch Chrome and redirect it to the Base URL
driver.get("https://www.credosystemz.com/" );
//Maximizes the browser window
driver.manage().window().maximize() ;
//get the actual value of the title
aTitle = driver.getTitle();
//compare the actual title with the expected title
if (aTitle.contentEquals(eTitle))
{
System.out.println( "Test Passed") ;
}
else {
System.out.println( "Test Failed" );
}
WebElement credolink;
credolink= wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath( "/html/body/div[1]/section/div[2]/div/div[1]/div/div[1]/div/div/div/div[2]/div[2]/div/div/div/div/div[1]/div/div/a/i")));
credolink.click();
}
}
Sleep
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class PracticeWaitCommands {
public static WebDriver driver;
public static void main(String[] args) {
// Create a new instance of the Firefox driver
driver = new FirefoxDriver();
// Put an Implicit wait, this means that any search for elements on the page could take the time the implicit wait is set for before throwing exception
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
// Launch the URL
driver.get("https://toolsqa.com/automation-practice-switch-windows/");
// Click on the Button "Timing Alert"
driver.findElement(By.name("Timing Alert")).click();
System.out.println("Timer JavaScript Alert is triggered but it is not yet opened");
// Create new WebDriver wait
WebDriverWait wait = new WebDriverWait(driver, 10);
// Wait for Alert to be present
Alert myAlert = wait.until(ExpectedConditions.alertIsPresent());
System.out.println("Either Pop Up is displayed or it is Timed Out");
// Accept the Alert
myAlert.accept();
System.out.println("Alert Accepted");
// Close the main window
driver.close();
}
}
7. Exception Handling. Write code for given scenario.
lass Main {
public static void main(String[] args) {
try {
// code that generate exception
int divideByZero = 5 / 0;
System.out.println("Rest of code in try block");
}
catch (ArithmeticException e) {
System.out.println("ArithmeticException => " + e.getMessage());
}
}
}
Output
ArithmeticException - / by zero
8. Use “Throws” keyword.
public class TestThrow1{
static void validate(int age){
if(age<18)
throw new ArithmeticException("not valid");
else
System.out.println("welcome to vote");
}
public static void main(String args[]){
validate(13);
System.out.println("rest of the code...");
}
}
9. Use of “Finally” keyword
try {
int[] myNumbers = {1, 2, 3};
System.out.println(myNumbers[10]);
} catch (Exception e) {
System.out.println("Something went wrong.");
} finally {
System.out.println("The 'try catch' is finished.");
}
10. Diff – ‘Final’ & ‘finally’
Final | Finally |
---|---|
Final is used to apply restrictions on class, method and variable. | Finally is used to place important code, it will be executed whether exception is handled or not. |
11. Diff – ‘List’ & ‘Set’
List | Set |
---|---|
The list implementation allows us to add the same or duplicate elements. | The set implementation doesn't allow us to add the same or duplicate elements. |
The List implementation classes are LinkedList and ArrayList. | The Set implementation classes are TreeSet, HashSet and LinkedHashSet. |
12. Diff – ‘Abstract Class’ & ‘Interface’ with Code
// Abstract class
abstract class Animal {
// Abstract method (does not have a body)
public abstract void animalSound();
// Regular method
public void sleep() {
System.out.println("Zzz");
}
}
// Subclass (inherit from Animal)
class Pig extends Animal {
public void animalSound() {
// The body of animalSound() is provided here
System.out.println("The pig says: wee wee");
}
}
class Main {
public static void main(String[] args) {
Pig myPig = new Pig(); // Create a Pig object
myPig.animalSound();
myPig.sleep();
}
}
//interface
interface printable{
void print();
}
class A6 implements printable{
public void print(){System.out.println("Hello");}
public static void main(String args[]){
A6 obj = new A6();
obj.print();
}
}
13. POM
POM means Page Object Model. To simplify, in the Page Object Model framework, we create a class file for each web page. This class file consists of different web elements present on the web page.
14.Page Factory
Selenium Page Factory Pattern is like an extension to Page Object Model , but Page Factory is much enhanced model. In Page Factory, Annotations are used to give descriptive names for WebElements to improve code readability. And annotation @FindBy is used to identify Web Elements in the page.
15. Did you develop any Framework?
16. How to take screenshot – Code?
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import java.io.File;
import java.io.IOException;
public class ScreenshotDemo {
public static void main(String[] args) {
//set the location of chrome browser
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
// Initialize browser
WebDriver driver = new ChromeDriver();
//navigate to url
driver.get("https://demoqa.com");
//Take the screenshot
File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
//Copy the file to a location and use try catch block to handle exception
try {
FileUtils.copyFile(screenshot, new File("C:\\projectScreenshots\\homePageScreenshot.png"));
} catch (IOException e) {
System.out.println(e.getMessage());
}
//closing the webdriver
driver.close();
}
}
17. Real time experience in BUILD tool [Apache Ant or Maven]
18. Version Controlling
18. Version Controlling
junit
junit
4.10
test
org.seleniumhq.selenium
selenium-java
2.45.0
19. Member access modifiers
The access modifiers in java specifies accessibility (scope) of a data member, method, constructor or class. These are the Java keywords, which are used in declaring variables, method, constructor or class. These modifiers help to set the level of access of the data or it decides the scope of the data.
20. Diff – ‘Array’ & ‘ArrayList’
Array | ArrayList |
---|---|
The array is a native programming component or a data structure. | ArrayList is a class from the Java Collections framework, an API. In fact, ArrayList is internally implemented using an array in Java. |
Is a simple fixed-size data structure which requires a size at the time of creation. | Is a dynamic sized data structure which doesn’t require a specific size at the time of initialization |
21. How to Sort using ‘Collection
For example:
public static void sort(List myList)
myList : A List type object we want to sort.
This method doesn't return anything
22. What kind of framework you have worked? Explain it?
Below are the types of framework:- Linear Automation Framework
- Modular Based Testing Framework
- Library Architecture Testing Framework
- Data-Driven Framework
- Keyword-Driven Framework
- Hybrid Testing Framework
23. Write xpath to locate the div that has no tags?
24. How will you run Smoke test cases seperately?
Free PDF : Get our updated Selenium Course Content pdf
25. Explain about static and final key words?
Static keywords | Final Keywords |
---|---|
Static variable belongs to a class not to a object | The final keyword in java is used to restrict the user. The java final keyword can be used in many context. |
26. Explain about interface and abstract class? Why interface than abstract class?
Interface can have only abstract methods. Since Java 8, it can have default and static methods also. Abstract class can have abstract and non-abstract methods. Interfaces cannot be instantiated, though abstract classes that implement interfaces can.
27. Do you know collections in java?
The Java collections framework provides a set of interfaces and classes to implement various data structures and algorithms. For example, the LinkedList class of the collections framework provides the implementation of the doubly-linked list data structure.
28. Write a program to loop through Arraylist?
import java.util.*;
public class LoopExample {
public static void main(String[] args) {
ArrayList arrlist = new ArrayList();
arrlist.add(14);
arrlist.add(7);
arrlist.add(39);
arrlist.add(40);
/* For Loop for iterating ArrayList */
System.out.println("For Loop");
for (int counter = 0; counter < arrlist.size(); counter++) {
System.out.println(arrlist.get(counter));
}
/* Advanced For Loop*/
System.out.println("Advanced For Loop");
for (Integer num : arrlist) {
System.out.println(num);
}
/* While Loop for iterating ArrayList*/
System.out.println("While Loop");
int count = 0;
while (arrlist.size() > count) {
System.out.println(arrlist.get(count));
count++;
}
/*Looping Array List using Iterator*/
System.out.println("Iterator");
Iterator iter = arrlist.iterator();
while (iter.hasNext()) {
System.out.println(iter.next());
}
}
}
29. “09/24/2015”. seperate numbers only from this string.
30. What is the difference between Commit and Push in Github?
Git considers its data more like a set of snapshots, like a mini file system or versions of a project called commits.
Each developer has their own private repository to track their changes in.
When you use the push command, you apply your changes to the upstream repository.
31. Writer a program to keep current browser but close other browsers?
32. There are three webelements having same property. Write a program to go to third one?
33. How will you push your code to server in github?
34. Brief about your automation testing experience?
35. What is protected access modifier?
Classes in java can use only public and default access modifiers. On the other hand, class visibility takes precedence over member visibility. If member is using public access modifier but class is default. Variable will not be accessible from outside package.
36. Do you know Page object model framework and Pagefactory?
Page Object Model, also known as POM, is a design pattern in Selenium that creates an object repository for storing all web elements. It is useful in reducing code duplication and improves test case maintenance.
Page Factory in Selenium is an inbuilt extension of Page Object Model. It is optimized. It is a class where
Three two methods in it,
@FindBy annotation - to find WebElement
initElementts() method - to initialize web elements automatically.
37. Write script to drag drop a text box?*9
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.Test;
public class DragAndDrop {
WebDriver driver;
@Test
public void DragnDrop()
{
System.setProperty("webdriver.chrome.driver"," E://Selenium//Selenium_Jars//chromedriver.exe ");
driver= new ChromeDriver();
driver.get("http://demo.guru99.com/test/drag_drop.html");
//Element which needs to drag.
WebElement From=driver.findElement(By.xpath("//*[@id='credit2']/a"));
//Element on which need to drop.
WebElement To=driver.findElement(By.xpath("//*[@id='bank']/li"));
//Using Action class for drag and drop.
Actions act=new Actions(driver);
//Dragged and dropped.
act.dragAndDrop(From, To).build().perform();
}
}
Round 3:38. Write a program to find occurrence of every characters in following string:String s = ‘Welcome to Wipro”;
39. Have you worked on Page object model framework?
For example,
If you are worked in Page object model framework, then explain its with your projects. Page Object Model is a way of representing an application in a test framework.
40. Implicit and explicit wait. difference?
Implicit wait | Explicit wait |
---|---|
The implicit wait will tell to the web driver to wait for a certain amount of time before it throws a "No Such Element Exception". | The explicit wait is an intelligent kind of wait, but it can be applied only for specified elements. The explicit wait gives better options than that of an implicit wait as it will wait for dynamically loaded Ajax elements. |
41. Thread.sleep and Thread.wait. difference?
Thread.sleep | Thread.wait |
---|---|
If you call wait method without synchronization, it will throw IllegalMonitorStateException in Java. | There is no requirement of synchronization for calling sleep method, you can call it normally. |
42. Inerface and Abstract class. difference?
Interface | Abstract Class |
---|---|
It is not declare constructors or destructors | Abstract Class Can declare constructors and destructors |
Having only one abstract class | Can implement several interfaces |
43. Why interface than abstract class
Interface is for contract behavior at the same time abstract class is an default behavior in an subclasses.
44. How will you manage build?
45. What is the purpose of using Maven?
- Support for managing the full lifecycle of a test project.
- On the other hand, to define project structure, dependencies, build, and test management.
- Most importantly, automatically downloads the necessary files from the repository while building the project.
46. I am facing an error says ‘Fast forward’ while pusing my code to server in Github. How to resolve it/
47. How will you push your code to server in github?
48. How will you handle popups?
Syntax of handle the popups: String mainPage = driver.getWindowHandle(); Alert alt = driver.switchTo().alert(); // to move control to alert popup alt.accept(); // to click on ok. alt.dismiss(); // to click on cancel. //Then move the control back to main web page- driver.switchTo().window(mainPage); → to switch back to main page. String mainPage = driver.getWindowHandle(); Alert alt = driver.switchTo().alert(); // to move control to alert popup alt.accept(); // to click on ok. alt.dismiss(); // to click on cancel. //Then move the control back to main web page- driver.switchTo().window(mainPage); → to switch back to main page.
49. How will you run a machine in grid?
Below two steps are used to run a machine in grid,- Start the HUB
- Start the NODE
Book a Free Mock Interviews and Test your Selenium skills with our Experts
TOP MNC's SELENIUM INTERVIEW QUESTIONS & ANSWERS
Here we listed all Selenium Interview Questions and Answers which are asked in Top MNCs. Periodically we update this page with recently asked Questions, please do visit our page often and be updated in Selenium.
Related Blogs
To become a Selenium Certified professional and join in your dream company, Enroll now for our Best Selenium Training. We help you to crack any levels of Selenium Interviews and We offering Selenium Training with Placement Assistance.