Selenium Java Interview Questions And Answers : That Every QA should Know (Top 51+ Questions)
We are going to learn about the TOP 51+ Selenium Selenium Java Interview Questions and Answers. These are exact questions asked for the beginners and experience people.
You can download the selenium java interview questions and answers for experienced as PDF also in below link.
1
Contents
Question #1 : What is Selenium WebDriver?
It is an automation framework that allows you to execute your tests against different browsers.
WebDriver also enables you to use a programming language in creating your test scripts
Java, .Net, PHP, Python, Ruby, Perl
It supports Chrome ,Firefox ,Opera , Safari , IE , HTML unit driver(headless)

2
Question #2 : What are the different types of exceptions you have faced in Selenium WebDriver?
- NoSuchElementException
- NoSuchWindowException
- NoSuchFrameException
- NoAlertPresentException
- ElementNotVisibleException
- ElementNotSelectableException
- TimeoutException

3
Question #3 : What is implicit wait in Selenium WebDriver?`
The implicit wait will tell the WebDriver to wait a certain amount of time before it throws a “No Such Element Exception.”
The default setting of implicit wait is zero. Once you set the time, the web driver will wait for that particular amount of time before throwing an exception.
Syntax:
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
4
Question #4 : What is WebDriver Wait in Selenium WebDriver?
Explicit waits are a concept from the dynamic wait, which waits dynamically for specific conditions. It can be implemented by the WebDriverWait class
Syntax:
WebDriverWait wait = new WebDriverWait(driver, 20);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id(“input”)));
5
Question #5 : What is Fluent Wait in Selenium WebDriver?

Each FluentWait instance defines the maximum amount of time to wait for a condition, as well as the frequency with which to check the condition.
Syntax:
Wait wait = new FluentWait(driver)
.withTimeout(30, SECONDS)
.pollingEvery(5, SECONDS)
.ignoring(NoSuchElementException.class);
WebElement element = wait.until(new Function()
{
public WebElement apply(WebDriver driver) {
return driver.findElement(By.id(“element”));
}
}
6
Question #6 : How to Input Text into a value by Javascript?
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("document.getElementById("<<inputbox_id>>").value='new value’”);
7
Question #7 : How to get an attribute value of an element using Selenium WebDriver?
driver.findElement(By.Id(“button_id”)).getAttribute(“text”);
8
Question #8 : How to Send Keyboard keys like press Enter key on text box in Selenium WebDriver?
driver.findElement(By.Id(“button_id”)).sendKeys(keys.ENTER);
9
driver.get() is used to navigate particular URL(website) and wait till page load.
driver.navigate() is used to navigate to particular URL and does not wait to page load. It maintains browser history or cookies to navigate back or forward.
10
Question #10 : How to pause a test execution for 5 seconds at a specific point?
We can pause test execution for 5 seconds by using the wait command.
Syntax:
driver.wait(5);
11
Question #11 : What is Selenium Grid and when do we go for it?

Selenium Grid is used to run tests on different machines against different browsers in parallel. We use Selenium Grid in the following scenarios:
Execute your test on different operating systems
Execute your tests on different versions of same browser
Execute your tests on multiple browsers
Execute your tests in parallel and multiple threads
12
Question #12 : What is a Hub in Selenium Grid?
- Hub is the central point to the entire GRID Architecture which receives all requests.
There is only one hub in the selenium grid. Hub distributes the test cases across each node.
13
Question #13 : What is a Node in Selenium Grid?
There can be multiple nodes in Grid.
Tests will run in nodes.
Each node communicates with the Hub and performs test assigned to it.
14
Question #14 : Which WebDriver implementation claims to be the fastest?
HTML UnitDriver is the most lightweight and fastest implementation headless browser for of WebDriver. It is based on HtmlUnit.
It is known as Headless Browser Driver.
It is same as Chrome, IE, or FireFox driver, but it does not have GUI so one cannot see the test execution on screen.
15
Question #15 : What are the open source frameworks supported by Selenium WebDriver?
- TestNG
- JUnit
- Cucumber
- Robot Framework
- Appium
- Protractor
16
- navigate().to();
navigate().forward();
navigate().back();
navigate().refresh();
17
Question #17 : How can we Maximize browser window in Selenium WebDriver?
- driver.manage().window().maximize();
18
Single Cookie Delete by Name
driver.manage.deleteCookieNamed(“hello”);
All the cookies
driver.manage().deleteAllCookies();
19
Question #19 : What is the difference between driver.getWindowHandle() and driver.getWinowHandles() in Selenium WebDriver and their return type?
driver.getWindowHandle() – To get the window handle of the current window. Returns a string of alphanumeric window handle
driver.getWinowHandles() – To get the window handle of all current windows. Return a set of window handles
20
We can use the JavaScriptExecutor to handle hidden elements.
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("document.getElementById('displayed-text').value=texthHidden");
21
