Special Offer - Enroll Now and Get 2 Course at ₹25000/- Only Explore Now!

All Courses
Selenium with Java Interview Questions and Answers

Selenium with Java Interview Questions and Answers

November 26th, 2018

In case you’re searching for Selenium with Java Interview Questions and answers for Experienced or Freshers, you are at the correct place. There is parcel of chances from many presumed organizations on the planet. The Selenium with Java advertise is relied upon to develop to more than $5 billion by 2021, from just $180 million, as per Selenium with Java industry gauges. In this way, despite everything you have the chance to push forward in your vocation in Selenium with Java Development. Gangboard offers Advanced Selenium with Java Interview Questions and answers that assist you in splitting your Selenium with Java interview and procure dream vocation as Selenium with Java Developer.

Best Selenium with Java Interview Questions and Answers

Do you believe that you have the right stuff to be a section in the advancement of future Selenium with Java, the GangBoard is here to control you to sustain your vocation. Various fortune 1000 organizations around the world are utilizing the innovation of Selenium with Java to meet the necessities of their customers. Selenium with Java is being utilized as a part of numerous businesses. To have a great development in Selenium with Java work, our page furnishes you with nitty-gritty data as Selenium with Java prospective employee meeting questions and answers. Selenium with Java Interview Questions and answers are prepared by 10+ years experienced industry experts. Selenium with Java Interview Questions and answers are very useful to the Fresher or Experienced person who is looking for the new challenging job from the reputed company. Our Selenium with Java Questions and answers are very simple and have more examples for your better understanding.
By this Selenium with Java Interview Questions and answers, many students are got placed in many reputed companies with high package salary. So utilize our Selenium with Java Interview Questions and answers to grow in your career.

Q1). What is the different use of this statement in java?

This is a keyword in java used for referring same class instance variable, same class method, returning same class instance.

Q2). What is run time polymorphism in java?

In java, calling to a method is defined based on the type of object created in runtime. That is run time polymorphism.

Q3). Which method is used to convert String to Char?

by using toCharArray();

Q4). Is it possible to have static method in method overloading?

Yes its possible as method overloading depends only on the number of the argument and data type.

Q5). In a class can a local variable be static?


Q6). Is it possible to call finally block after throwing an exception?

Yes. Finally, will always be executed.

Q7). Is finally block always executed?

No. In case of System. exit() it won’t be executed.

Q8). What are the OOPs concept in java?

Inheritance, Abstraction, Polymorphism, Encapsulation, Interface

Q9). Why String is immutable?

As, once the String object is created cannot be modified

Q10). Is multiple inheritance possible in java?

No. Its possible only through interface.

Q11). Can a Interface have complete method.

Yes. After java ver 8, Interface can have complete methods but the method should be static and default.

Q12). Is it possible to have auto widening and auto narrowing in java?

Auto widening is possible but auto narrowing is not.

Q13). Why auto narrowing is not possible in java?

In auto narrowing there is always a loss of memory. So its not possible.

Q14). Where the String objected created?

The string objects are created in String pool area.

Q15). If a String s= “Hi I am Good”. How to separate each word of a String?

By using Split(“ ”) method

Q16). What is encapsulation in java?

In java encapsulation is property, where we hide data member by declaring them as private and try to access them through public methods.

Q17). What is difference in HashMap and HashTable in java?

HashMap can have a Null key and Multiple Null values but HashTable can not have Null key and Null values.

Q18). What is the difference in List and Set in java?

List can have duplicate element but St only have unique element.

Q19). What is recursion in java?

In Java, recursion is a process where a method with in a class calls itself inside the class.

Q20). What is the difference in finally and finalize in java?

Finally, is a java block where finalize is used in garbage collection.

Q21). Can we override static methods in java?

No We cannot override static methods in java.

Q22). What is the difference in Collections and Collection in java.

Collection is an interface in java whereas Collections is a utility class has static java methods inside it.

Q23). What is the difference in Poll and Peak in java collection?

In java collection, poll is used for retrieve data and release memory permanently, but Peak used to retrieve data and release memory temporarily.

Q24). What is boxing and unboxing in java?

In java boxing is used to convert wrapper class to object type and Unboxing is used to get object from wrapper class.

Q25). What is java polymorphism?

In java, an entity is showing different behaviors at different instance of time is known as polymorphism.

Q26). What is java constructor?

When we want to perform an operation/action when an object is created we used constructors.

Q27). What are the different type of constructor?

Java has default and parameterized constructor.

Q28). Which package is used for file reading and writing in java?

Java I/O package is used

Q29). In java how to take input from user?

By using Scanner class

Q30). What  is the difference in array list and linked list ?

Arraylist store memory as continuous memory location but linked list store in random memory locations

Q31). What are different locators in selenium?

ID, name,xpath,CSS,class name, tag name, link text, partial linktext

Q32). What is a web driver ?

Webdriver is an Interface which provide different APIs to perform automation across browsers.

Q33). How to handle select/ dropdown option in selenium?

By using Select class

Q34). How to handle dynamic xpath in selenium?

by using methods such as, text(),Contains(), parent,child,following-siblings,ansestors etc

Q35). How to handle multiple windows in selenium?

By using getWindowHandle()

Q36). What is the difference in getWindowHandle() and getWindowHandles() in selenium?

getWindowHandle() return a String but getWindowHandles() return a collections of String

Q37). How to handle windows popup in selenium?

By using AutoIT

Q38). How to perform keyboard operation in selenium?

By using Action class

Q39). What is Soft assert in selenium?

In selenium soft assert is used to continue the execution without failing the test if any assertion fails. In the end it will collect all exception and fail the test.

Q40). What is ITest result in selenium?

ITest result in selenium is an Listener API used to monitor the execution status of test

Q41). What is the test NG annotations?

@test, @ BeforeMethod, @AfterMethod,@ BeforeClass,@AfterClass, @ Beforegroup, @AfterGroup

Q42). How to Disable an execution of test in TestNG?


Q43). How to handle cookies in selenium?

By using getCookies();

Q44). How to delete cookie by name in selenium?


Q45). How to set SSL certificate in selenium?


Q46). What is Frame handling in selenium?

Frames are different HTML page within a page. In selenium we use driver.switchto.frame()

Q47). In java what is checked exception?

Checked exception are the exception checked by the compiler.

Q48). What is different variable type sin java?

Local , Instance, Static

Q49). What is toString() in java?

toString() is used for String representation of objects.

Q50). What is Selenium grid?

Selenium grid is used to run multiple test across different browsers.

Q51). Write the syntax for to check the xpath in console?


Q52). Explain the Statement WebDriver driver=new Chrome Driver ();

Webdriver is an interface and driver is a reference variable pointing to class chrome driver

Q53). What is Xpath ?

Xpath is XML path in the DOM ( Document object Model)

Q54). Write the syntax for xpath ?


Q55). How do you select a value from Drop Down ?

  • We can select a drop down value from Select Class
  • Select sel=new Select ( WebElement)
  • selectbyVisibleText or Index or Value

Q56). How do you Select a sub menu from a Main Menu

We can select a sub menu by using Actions Class with move to element method

Q57). What are OOPS Concepts used in Selenium ?

  • Below are the following OOPS concepts used
  • Inheritance
  • Polymorphism
  • Encapsulation ( POM )
  • Abstraction

Q58). What does the annotation @ Find by do in Selenium

@Find by annotation is used to identify the webelements through its attributes ‘’

Q59). How do you execute a Test Regression Suite in Selenium ?

We can execute the regression suite by creating a test ng xml which includes the test cases

Q60). How can you retrieve the Property from a property file

We can retrieve by using the Properties class and retrieve the key value pair

Q61). Selenium function used for retrieving the attribute or value?

getAttribute(), getText().

Q62). How do get typed text from a textbox?


Q63). How do you simulate browser back and forward?


Q64). How do you get the current page URL?


Q65). How do you achieve synchronization in WebDriver?


Q66). How do you clear the contents of a textbox in selenium?

use clear() method.
selenium QA.txt
Displaying selenium QA.txt.

Q67). What is annotations

@Test, @BeforeTest, @AfterTest, @BeforeClass, @AfterClass, @BeforeMethod, @AfterMethod, @BeforeSuite, @AfterSuite.

Q68). What is ghost driver ?

Ghost driver  means it is the JavaScript. It implemented the web driver protocol phantom JS.
Then it can use remote web  driver for back end.

Q69). What is the use of Property file in your framework ?

Properties file is use to store GUI locator and global field database properties .
Mainly it use for JAVA

Q70). What is flash automation

Flash automation means the SWF file is the also in Flash and we can use  HTML file

Q71). How many types of WebDriver APIs using in Selenium?

  • Chrome Driver
  • Firefox Driver
  • Gecko Driver
  • InternetExplorer Driver
  • Opera Driver
  • Android Driver
  • iPhone Driver

Q72). Which Operating Systems support to Selenium WebDrivers?

  • Windows Operating Systems
  • Linux Operating Systems
  • Apple Operating Systems

Q73). What is selenium and why it is used by more users?

Selenium is an automation test tool used to test the web application by using the web driver in a browser. It’s an open source so it has large no of user.

Q74). What are the components of selenium?

  • Selenium web driver
  • Selenium RC
  • Selenium Grid
  • Selenium IDE

Q75). What are the languages supports in selenium?

  • C
  • C++
  • Java
  • Python
  • C-sharp
  • Ruby

and we need to configure the jars file for each language.

Q76). Write the code to open chrome browser in selenium?

WebDriver driver = new chrome driver ();

Q77). Write the locater to find element in selenium?

By id
By name
By classname
By xpath
By css-selectors

Q78). Write the syntax for Xpath and the two type of xpath?

//tagname[@attributes=”value”] *[@attributes=”value”] Types:

  • Absolute xpath
  • Relative xpath

Q79). Write the syntax for get element by id and xpath ? And syntax for click button?


Q80). Write the code to open firefox browser in selenium?

WebDriver driver = new geckodriver ();

Q81). How many test types are support to Selenium?

There are 7 types are supporting

  • Integration Testing
  • Regression Testing
  • Functional Testing
  • Smoke Testing
  • Responsive Testing
  • Cross Browsers Testing
  • UI testing (black box)

Q82). How to get the Source code of the webpage?


Q83). How to disable the Browser level Notifications in Selenium?

ChromeOptions options = new ChromeOptions();
WebDriver driver =new ChromeDriver(options);

Q84). How to go back to main menu from Inner most frame directly?


Q85). How to switch from inner frames to parent frame one by one?

driver.switchTo().parentFrame() ;

Q86). WebDriver interface extends the features from which Interface?

SearchContext interface

Q87). Explain the uses of javaScriptExecutor in Selenium.

  • To locate an element if normal locators do not work.
  • To pass values instead of sendKeys().
  • To generate user defined alert window.
  • To capture scrape data(url, title, domain etc).
  • To navigate to a url.
  • To Scroll the page.
  • To open a new Tab.

Q88). How to handle Windows based alert in Selenium?

Selenium does not support this feature.

Q89). How to Resize the browser window?

Dimension d=new Dimension(480, 620);

Q90). What methods are used to scroll the page in javaScriptExecutor?

scrollBy(), scrollTo().

Q91). What is the difference between quit() & close()?

All windows opened by webDriver are closed with quit(). Close() closes only browser window currently webDriver is controlling.

Q92). Can we switch from one frame to another frame through automation?

No we cannot switch from one frame to another frame directly.

Q93). How to switch to a frame?


Q94). How to switch to parent frame?


Q95). How to retire the data from Encapsulation?

Using getter and setter method we can access the data.

Q96). How to launch a browser ?

static void launchbrowser()
String filepath = System.getProperty("user.dir")+"\\Library\\Driver\\chromedriver.exe";
System.setProperty("webdriver.chrome.driver",filepath );
browser = new ChromeDriver();
}catch(Exception e){

Q97). How to identify the given drop down and what are the ways?

  • Select class
  • Robot class

Q98). How to switch to alert ?

alert.accept() à ok button
alert.dismiss() à cancel

Q99). How to identify the nth child ?

browser.findElement(By.cssSelector(“div#d3 > form#frm3 > input:nth-child(5)”)).sendKeys(“fifthchild”);

Q100). How many types of wait statements?

  • Implicit wait
  • Explicit wait

Q101). Does Java support multiple inheritance?

Java does not support Multiple inheritance.