0% found this document useful (0 votes)
27 views

Selenium Java Interview Questions and Answers - Part 1

Uploaded by

Vijendra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Selenium Java Interview Questions and Answers - Part 1

Uploaded by

Vijendra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Selenium Java

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?

JavascriptExecutor executor = (JavascriptExecutor)driver;


executor.executeScript("document.getElementById("<<inputbox_id>>").val
ue='new value’”);

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?

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.

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?

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

TheTestingAcademy.com
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.

TheTestingAcademy.com
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.

TheTestingAcademy.com
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.

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?

Single Cookie Delete by Name

driver.manage.deleteCookieNamed(
“hello”);

All the cookies

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?

We can use the JavaScriptExecutor to handle hidden elements.

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.

List<WebElement> elements = driver.findElements(By.tagName(“a”));

TheTestingAcademy.com
TheTestingAcademy.com

You might also like