Selenium Java Interview Questions and Answers - Part 1
Selenium Java Interview Questions and Answers - Part 1
Interview Questions
And Answers
Pramod Dutta
Cracking Automation Tester Interview Series : Part #1 Sr. SDET
TheTestingAcademy.com
Question #1 : What is Selenium Webdriver?
● Its 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
TheTestingAcademy.com
Question #2 : What are the different types of exceptions
you have faced in Selenium WebDriver?
● NoSuchElementException
● NoSuchWindowException
● NoSuchFrameException
● NoAlertPresentException
● ElementNotVisibleException
● ElementNotSelectableException
● TimeoutException
TheTestingAcademy.com
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);
TheTestingAcademy.com
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”)));
TheTestingAcademy.com
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”));
}
}
TheTestingAcademy.com
Question #6 : How to Input Text into a value by Javascript?
TheTestingAcademy.com
Question #7 : How to get an attribute value of an element
using Selenium WebDriver?
driver.findElement(By.Id(“button_id”)).getAttribute(“text”);
TheTestingAcademy.com
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);
TheTestingAcademy.com
Question #9 : What is the difference between
driver.get(“URL”) and driver.navigate().to(“URL”)
commands?
TheTestingAcademy.com
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);
TheTestingAcademy.com
Question #11 : What is Selenium Grid and when do we go
for it?
TheTestingAcademy.com
Question #12 : What is a Hub in Selenium Grid?
TheTestingAcademy.com
Question #13 : What is a Node in Selenium Grid?
TheTestingAcademy.com
Question #14 : Which WebDriver implementation claims to
be the fastest?
It is same as Chrome, IE, or FireFox driver, but it does not have GUI so one
cannot see the test execution on screen.
TheTestingAcademy.com
Question #15 : What are the open source frameworks
supported by Selenium WebDriver?
● TestNG
● JUnit
● Cucumber
● Robot Framework
● Appium
● Protractor
TheTestingAcademy.com
Question #16 : What are the different types of navigation
commands in Selenium?
● navigate().to();
● navigate().forward();
● navigate().back();
● navigate().refresh();
TheTestingAcademy.com
Question #17 : How can we maximize browser window in
Selenium WebDriver?
driver.manage().window().maximize();
TheTestingAcademy.com
Question #18 : How to delete cookies in Selenium?
driver.manage.deleteCookieNamed(
“hello”);
driver.manage().deleteAllCookies();
TheTestingAcademy.com
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
TheTestingAcademy.com
Question #20 : How to handle hidden elements in
Selenium WebDriver?
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("document.getElementById('displayed-text').value=texthHidden");
TheTestingAcademy.com
Question #21 : How to find more than one web element in
the list?
We can find more than one web element by using the findElements() method in
Selenium.
TheTestingAcademy.com
TheTestingAcademy.com