0% found this document useful (0 votes)
6 views20 pages

Frequently Asked Interview Questions in Selenium Basic

The document provides a comprehensive overview of frequently asked interview questions related to Selenium, covering topics such as automation testing, Selenium components, WebDriver, and various testing frameworks. It details the benefits, limitations, and differences between Selenium and other testing tools, as well as specific commands and methods used in Selenium WebDriver. Additionally, it explains the structure of WebDriver, its supported programming languages, and how to interact with web elements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views20 pages

Frequently Asked Interview Questions in Selenium Basic

The document provides a comprehensive overview of frequently asked interview questions related to Selenium, covering topics such as automation testing, Selenium components, WebDriver, and various testing frameworks. It details the benefits, limitations, and differences between Selenium and other testing tools, as well as specific commands and methods used in Selenium WebDriver. Additionally, it explains the structure of WebDriver, its supported programming languages, and how to interact with web elements.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Frequently Asked Interview Questions in

Selenium Basic

1. What is Automation Testing?


Ans: Automation testing is a process of automating manual
processes to test applications or systems. It uses separate testing
tools in which test script is created and executed repeatedly.
2. What are the benefits of Automation testing?
Ans: There are the following benefits of automation testing. They are
as follows:
 Automation testing supports the execution of repeated test
cases.
 It supports parallel execution.
 It helps to improve accuracy and reduces human-generated
error.
 It saves time and money.
3. What is Selenium? What are the different components of
selenium?
Ans: Selenium is a free and open-source browser automation testing
tool which is used to test the functionality of web based application.
It supports different operating systems and different languages. It is
originally developed by Jason Huggins in 2004.
There are four components available in selenium suite to automate
the web application.
 Selenium IDE (Integrated Development Environment)
 Selenium Remote Control (RC)
 WebDriver
 Selenium Grid
4. Why should Selenium be selected as a testing tool?
Ans: There are the following reasons to select selenium as a testing
tool.
 Selenium is free and open-source.
 It supports different operating systems like Windows, Mac OS,
and Linux.
 It supports different programming languages such as Java, C#,
Python, Perl, Ruby, and PHP. We can code in Java, Python, C#,
etc.
 It supports almost all popular browsers like Chrome, Firefox,
Opera, IE, etc.
 Selenium supports cross-browser compatibility (Chrome,
Firefox, or IE).
5. What is Selenium 1.0?
Ans: Selenium 1.0 or Selenium Remote Control (popularly known as
Selenium RC) is a freeware automated testing tool that allows
testers to test web-based applications.
It was developed to extend framework in multiple programming
languages. It is composed of Selenium IDE, Selenium Core, Selenium
RC, and Selenium Server.
6. What is Selenium 2.0?
Ans: Selenium 2.0 (also known as WebDriver) is the latest, free, and
open-source library to automate web applications. It is a pure
object-oriented tool.
This powerful tool was developed in 2008 when Selenium RC was
merged with another testing framework called WebDriver.
7. What are the types of testing supported by selenium?
Ans: Selenium supports different types of testing. They are as
follows:
 Functional Testing
 Regression Testing
 Retesting
 Acceptance Testing
 End-to-End Testing
 Smoke Testing
 Sanity Testing
 Responsive Testing
 Cross Browser Testing
 UI Testing
 Integration Testing
8. What are four parameters that have to pass in Selenium?
Ans: Four parameters that have to pass in selenium, are Host, Port
Number, Browser, and URL.
9. What are the limitations of Selenium?
Ans: There are the following limitations of Selenium. They are:
 Selenium supports the testing of only web applications.
 Captcha and barcode cannot be tested by using selenium.
 Mobile applications cannot be tested by using Selenium.
 Test reports can only be generated using third-party tools like
JUnit or TestNG.
10. What is the difference between Selenium and QTP?
Ans: There are several differences between Selenium and QTP. They
are:
a) Open/Licensed: Selenium is free and open-source whereas, QTP
is a licensed tool.
b) Operating system: Selenium supports various operating
systems like Windows, Mac OS, and Linux whereas, QTP supports
only Windows operating systems.
c) Browser: Selenium supports almost all types of browsers like
Firefox, Chrome, IE, Opera, Safari, etc whereas, QTP supports only
IE.
d) Testing: Selenium supports only testing web-based applications
while QTP can be used for testing of both web-based and window-
based applications.
e) Programming language: Selenium supports multiple
programming languages like Java, C#, Python, Ruby, etc while QTP
supports only VB script.
f) Object repository: Object repository needs to be created in
selenium whereas QTP automatically creates and maintains object
repository.

Interview Questions based on Selenium


WebDriver

1. What is Selenium WebDriver?


Ans: Selenium WebDriver is a web automation framework that
executes tests against different browsers like Firefox, Chrome, IE,
etc.
It allows the users to create test scripts in different programming
languages. It was designed by Simon Stewart while he was working
at ThoughtWorks.
2. Is WebDriver interface or class?
Ans: WebDriver is a public interface, not a class. We just define a
reference variable (driver) of type WebDriver interface. Now, we can
assign an instance of a class (such as FirefoxDriver class) that
implements WebDriver interface to use methods provided by
WebDriver.
For example:
WebDriver driver = new FirefoxDriver();
3. How WebDriver is an interface?
Ans: Creating WebDriver as an interface is the best way to expose a
set of APIs that will provide a lot of capabilities to the Selenium tool.
Selenium developers knew that logic will not be the same for all
browsers.
Interface is a mechanism that has only abstract methods i.e
methods that have no body or logic. Therefore, WebDriver interface
allows users to write their logic in abstract methods provided by
WebDriver.
RemoteWebDriver class implements WebDriver interface which is
extended by Browser drivers.
4. How Selenium WebDriver works?
Ans: Selenium WebDriver works in three steps. They are as follows:
a. The first step is to send commands (programming code and
selenese commands) to the Selenium WebDriver server via
commands line associated with selenium server.

b. In the second step, Selenium WebDriver Server sends Javascripts


commands to Web Browser Driver. The interaction from Selenium
WebDriver server to driver elements of web browser is done with
the help of Javascript Libraries.
c. In the third step, Selenium Web browser driver elements interact
with web application using commands from selenium to perform
actions of users like entering text, clicking on button, etc.
5. What is the name of super interface of WebDriver?
Ans: SearchContext is the super interface of Webdriver. It is the top
most interface in selenium, which is extended by another interface
called WebDriver. It has only two methods named findElement() and
findElements().
6. What is RemoteWebDriver?
Ans: RemoteWebDriver is a class that extends object class and
implements WebDriver, and JavascriptExecutor interfaces.
7. What are Programming Languages supported by Selenium
WebDiver?
Ans: Selenium WebDriver supports multiple programming languages
like Java, C#, Python, Ruby, Perl, and PHP. We can write code in any
of these languages.
8. What are Operating Systems supported by Selenium
WebDriver?
Ans: Selenium WebDriver supports multiple operating systems such
as Windows, Linux, Mac OS, IOS, and Android.
9. How many types of WebDriver APIs are available in
Selenium?
Ans: There are several types of WebDriver APIs available in
Selenium WebDriver. They are FirefoxDriver, GeckoDriver,
InternetExplorerDriver, ChromeDriver, HTMLUnitDriver, OperaDriver,
SafariDriver, AndroidDriver, iPhoneDriver, and
EventFiringWebDriver.
10. What are testing frameworks supported by Selenium
WebDriver with Java?
Ans: Selenium WebDriver with Java supports two testing frameworks
such as JUnit and TestNG.
11. Is FirefoxDriver a class or an interface?
Ans: FirefoxDriver is a Java class that implements a WebDriver
interface.
12. How do we launch a web browser by using Selenium
WebDriver?
Ans: WebDriver is an Interface. We create an object of a required
driver class such as FirefoxDriver, ChromeDriver,
InternetExplorerDriver, etc by assigning WebDriver reference. For
example:
a. To launch Firefox Driver:
WebDriver driver = new FirefoxDriver()

b. To launch Chrome Driver:


WebDriver driver = new ChromeDriver();

c. To launch Internet Explorer Driver;


WebDriver driver = new InternetExplorerDriver();

13. Why do we assign Firefox instance to WebDriver


reference such as WebDriver driver = new FirefoxDriver();?
Ans: We assign the FirefoxDriver object to WebDriver reference
because it allows assigning driver object with different browser
drivers.
If we want to switch other browsers in the same program for
multiple browser testing, we will have to create multiple objects for
different browsers that are the worst kind of programming.
Therefore, we create a WebDriver reference and assign an object of
class.
14. What is difference between WebDriver and
FirefoxDriver?
Ans: WebDriver is an interface whereas, FirefoxDriver is a class that
implements WebDriver interface.
15. How to write test cases using Selenium WebDriver?
Ans: We can write test cases using element Locators, Selenium
WebDriver methods, and Java programming features. Element
locators are used to locating WebElements on the web page.
Selenium WebDriver methods are used to perform operations on
WebElement. Java is used to enhance programming features.
There are five basic steps to write test cases that can be applied to
any test case and any application under test (AUT). They are as
follows:
 Create a WebDriver instance.
 Navigate to a Web page.
 Locate an HTML element on the Web page using locators.
 Perform an action on an HTML element.
 Run tests.
16. What is Firebug?
Ans: Firebug is a Firefox addon which is used to inspect HTML web
elements on the web page during a test.
17. What are the limitations/drawbacks of WebDriver?
Ans: There are many limitations or drawbacks of WebDriver. They
are:
a. Selenium WebDriver can be used only to test web-based
applications. We can not test Windows-based applications or
desktop applications and any other software.
b. It is not possible to perform the testing on the image.
c. WebDriver does not generate automatically test result files.
d. WebDriver cannot support new browsers.
18. Which WebDriver implementation is the fastest?
Ans: HTMLUnit Driver is the fastest WebDriver implementation.
19. What is HTMLUnitDriver in Selenium?
Ans: HTMLUnitDriver is the fastest and most lightweight web
browser for implementation of WebDriver. It has no GUI (Graphical
User Interface).
Since, in HTML unit driver, test runs in the background without any
visual interruption, we cannot see test execution on the screen.
Hence, test execution becomes faster than other drivers.
20. What is the difference between HTMLUnitDriver and
FirefoxDriver?
Ans: There are following differences between HTMLUnitDriver and
FirefoxDriver.
 HTMLUnitDriver is a lightweight web browser whereas,
FirefoxDriver is a heavyweight browser.
 HTMLUnitDriver has no plugin whereas, FirefoxDriver has
plugin.
 HTMLUnitDriver does not GUI whereas, FirefoxDriver has.
 In the HTMLUnitDriver, test execution is fast whereas, slow
execution happens in the FirefoxDriver.
21. What are the differences between Selenium IDE,
Selenium RC, and WebDriver?
Ans:
Selenium IDE:
1. Selenium IDE is a Firefox plugin that supports only Firefox.
2. It is a Javascript-based framework.
3. It is not an object-oriented tool.
4. Selenium IDE supports record and playback features.
5. Selenium IDE does not need any server to be started before
executing the test script.
6. It does not support dynamic finders and listeners.
7. Selenium IDE does not support the testing of Andriod/iPhone
applications.
Selenium RC:
1. Selenium RC supports various types of browsers like Mozilla
Firefox, Google Chrome, Internet Explorer and Opera.
2. It is a Javascript-based framework.
3. Selenium RC is a semi-object-oriented tool.
4. It does not support record and playback feature.
5. Selenium RC requires server to be started before executing the
test scripts.
6. Selenium RC also not support dynamic finder and listener.
7. Selenium RC does not support the testing of iPhone/Android
applications.
WebDriver:
1. WebDriver supports almost all popular browsers like Mozilla
Firefox, Google Chrome, Internet Explorer, Opera, etc.
2. It is a pure object-oriented tool.
3. It does not support record and playback features.
4. It does not need any server to be started before execution of
test scripts.
5. WebDriver supports dynamic finders and the implementation
of listeners.
6. WebDriver is faster than Selenium RC.
7. WebDriver supports testing of iPhone/Android applications by
the available tool.

Interview Questions based on Selenium


WebDriver Commands

1. How to open a Website using Selenium WebDriver?


Ans: The get() method is used to open the specified URL in the
current browser window. The URL must be in the form of
http://www.xyz.com.
If the HTTP is not included then it will throw a message “Cannot
navigate to invalid URL”. The syntax is as follows:
WebDriver driver = new FirefoxDriver();
driver.get("https://www.xyz.com")

2. How to click on a button on the web page?


Ans: click() method is used to click on a button on the web page.
The syntax is given below:
driver.findElement(By.id("submit")).click();

3. How to get Page Title of web page using Selenium


WebDriver?
Ans: getTitle() method of WebDriver is used to get page title of any
web page. The syntax is as follows:
String pageTitle = driver.getTitle();

System.our.println(pageTitle);

4. How to get a text from a specified element or object on


web page?
Ans: The getText() method is used to retrieve inner text of specified
element on web page. The syntax is given below:
driver.findElement(By.locatorName("Specified
Element")).getText();

5. How to compare page title on web page with expected


title in Selenium WebDriver using Java?
Ans: We will verify or compare the title of the web page in Selenium
WebDriver using the String concept of Java. Let’s see the main
source code.
String actualTitle = driver.getTitle();

String expectedTitle="Facebook – log in or sign up"; // Use


equalsIgnoreCase() method of String class to verify actual title
with expected title.

if(actualTitle.equalsIgnoreCase(expectedTitle)) {

System.out.println("Verification is success" );
System.out.println("Home page title is:" + actualTitle );

} else {

System.out.println("Verification is failed, Matched not found");

6. What is the difference between driver.get() and


driver.navigate() method?
Ans: The difference between get() and navigate() methods of
Selenium WebDriver are as follows:
a) The driver.get() method is used to open a specified URL of web
application and wait until the whole page gets loaded whereas,
driver.navigate().to() method is used to navigate a specified URL of
web application and it does not wait till the whole page gets loaded.
b) driver.get() method does not maintain the browser history and
cookies whereas, driver.navigate() method maintains the browser
history and cookies.
c) We can not go forward or backward between the pages using the
driver.get() whereas, we can easily navigate between the pages
forward, back, and refresh using driver.navigate().
7. What is the difference between close and quit methods of
Selenium WebDriver?
Ans: The close() method is used to close only the browser window
that WebDriver is currently controlling whereas, the quit() method is
used to close all windows opened by WebDriver.
8. What are Navigation commands in Selenium WebDriver?
Ans: Navigation commands are those commands in Selenium that
are used to perform different operations such as backward, forward,
refresh, wait, etc in the browser’s history.
The navigation commands available in Selenium WebDriver are
back, forward, refresh, navigate, and to.
9. How to move forward and backward on the web page?
Ans: forward() method is used to move forward by one page on the
browser’s history.
back() method is used to move back by one page on the browser’s
history.
10. What is WebElement? Is WebElement class or interface?
Ans: The elements that are present on a web page are called
WebElement. It represents an HTML element. Text boxes, links,
buttons, dropdown buttons, radio buttons, labels, and forms are
called WebElement. It is an interface.
11. How many methods have been provided by Selenium
WebDriver to find WebElement?
Ans: There are two methods available in Selenium WebDriver to find
WebElement.
a. findElement(): This method is used to locate one web element in
the current web page using the locator provided in the parameter
list.
b. findElements(): This method is used to find a list of web
elements (i.e. multiple elements) on the current web page using the
locator provided in the parameter list.
12. What is the return type of findElement and
findElements?
Ans: The return type of findElement() method is a WebElement
object whereas, findElements() method returns a list of
WebElements.
13. Which input parameter does findElement() method take?
Ans: The findElement() method takes an input parameter of type By.
By is an instance of By class.
14. Which exception is thrown by WebDriver when it is
unable to find an element on web page?
Ans: Runtime exception named NoSuchElementException.
15. What is the difference between findElement and
findElements?
Ans: Refer to answer 11 and 12.
16. How will you find more than one WebElement on the list?
Ans: findElements() method of WebDriver can be used to find more
than one web element and save them into a list.
17. How to clear text in the text box using Selenium
WebDriver?
Ans: The clear( ) method provided by Selenium WebDriver is used to
clear the text entered or displayed in the text box.
18. How to submit a form using Selenium WebDriver?
Ans: The submit() method is used to submit a form with <form> tag.
It accepts nothing as a parameter and returns nothing. It will throw
NoSuchElementException if the current element is not present
within a form.
19. How to send user input in the text box using Selenium
WebDriver?
Ans: The sendKeys() method of Selenium WebDriver is used to type
or send text input in the text box. It accepts text or any sentence as
a parameter and returns nothing.
20. How will you identify/verify that element is
present/displayed/visible on the web page or not?
Ans: Selenium WebDriver provides a method isDisplayed() that can
be used to check the visibility of the certain element on web page.
This method will return true if the element is present on the web
page. Otherwise, it will throw NoSuchElementFound exception if the
element is not present on the page.
21. How to verify whether a certain element is present on
web page or not?
Ans: The isEnabled() method is used to check or verify whether a
certain element is enabled or not on web page.
22. How to verify whether checkbox, radio button or option
in the drop-down is selected on web page or not?
Ans: The isSelected() method is used to verify whether a certain
checkbox, radio button, or option in the drop-down box is selected
or not. It takes nothing as a parameter and returns a boolean value.

FAQs on Selenium Locators

1. What is locator in Selenium? What is the use of locators in


Selenium WebDriver?
Ans: Locator in selenium is like an address that is used to identify
the web element uniquely within the web page.
The basic use of locators is to identify the element or object on the
webpage accurately. Selenium WebDriver uses locators to interact
with elements present in a web page.
2. What are the types of locators available in Selenium
WebDriver?
Ans: There are eight types of locators to locate an element on the
web page. They are as follows:
 ID locator
 Name locator
 ClassName locator
 TagName locator
 LinkText locator
 Partial LinkText Locator
 CSS Selector
 XPath
For more details, go to this tutorial: Locators in Selenium WebDriver
3. Which is the best locator in Selenium WebDriver?
Ans: ID locator is king! It is the safest and fastest locator in Selenium
WebDriver. It should always be your first choice.
4. There is ID, name, CSS, or XPath locator, which one
should I use?
Ans: If there is a constant ID/name available, you should be used
instead of CSS and XPath locator. If not, the CSS locator should be
used instead of XPath because it is faster than XPath in the modern
browser.

5. Write a complete general syntax to find an element by


locator in Selenium WebDriver.
Ans: Selenium WebDriver provides two WebElement commands
such as findElement, and findElements. Both commands take an
input parameter By object and return an object of type WebElement.
By is an object of By class which can be used with various locator
strategies such as ID, Name, Class Name, Tag Name, Link Text,
Partial Link Text, and XPATH.
General Syntax:
WebElement elementName =
driver.findElement(By.locatorName("Attribute value")); // Identify
one web element within web page.

List<WebElement> elementName =
driver.findElements(By.locatorName("Attribute value")); //
Identify list of web elements within web page.

6. How to find links on the web page?


Ans: Selenium WebDriver provides two special methods to search
links on a web page.
a) Finding a link by its text:
By class of Selenium WebDriver provides linkText() method to locate
the link using text displayed for link. The syntax to locate Gmail link
on the Google Home page is as follows:
WebElement gmailLink = driver.findElement(By.linkText(“GMail”));
b) Finding a link by partial text:
By class of Selenium WebDriver also provides an additional method
partialLinkText() to locate links using partial text. This method is
useful to locate link using a fixed or known portion of the link text.
The general syntax to locate a link using the partialLinkText()
method is as follows:
WebElement inboxLink =
driver.findElement(By.partialLinkText(“Gmail”));

Interview Questions based on XPath in


Selenium

1. What is XPath in Selenium WebDriver?


Ans: XPath stands for XML (Extensible Markup Language) Path
language. It is a query language that is used to search and select
nodes in an XML document. It is used for the identification of any
element in an HTML or a web page.
2. Write the general syntax to find an element by XPath on
web page.
Ans: The general syntax for XPath is as follows:
XPath = //tagname[@Attribute = ‘Value’]

3. What are the types of XPath in Selenium WebDriver?


Ans: There are two types of XPath in Selenium WebDriver. They are:
 Absolute XPath
 Relative XPath
4. What is Absolute XPath in Selenium WebDriver?
Ans: XPath that begins with a single forward-slash (/) and selects an
element from the root HTML node is called absolute XPath.
It is the easiest and direct way to find an element but if any changes
happen in the path of element, this XPath gets failed. So, this is the
main disadvantage of using absolute XPath.
The general syntax to find an element using absolute XPath is as:
WebElement username =
driver.findElement(By.xpath("/html/body/div/div/form/input"));

5. What are the advantages and disadvantages of absolute


XPath in Selenium?
Ans: The advantage of using absolute XPath is that it identifies an
element very fast.
The disadvantage of using absolute XPath is that if anything goes
wrong or some other tag is added in between, this path will no
longer work.
6. What is Relative XPath in Selenium WebDriver?
Ans: XPath that starts from double forward-slash (//) and selects
elements from anywhere on the webpage is called relative XPath. It
is the best practice to find elements through relative XPath because
it helps us to reduce the chance of “ElementNotFoundException”.
The general syntax to locate an element using relative XPath is as
follows:
Relative XPath: //tag-name[@Attribute = 'Value']

7. What are the advantages and disadvantages of relative


XPath in Selenium WebDriver?
Ans: The advantage of using relative XPath is that you don’t have to
create long XPath. You can also start from the middle.
The disadvantage of using relative XPath is that it takes more time
in identifying the element as we specify the partial path, not the
exact path.
8. How to find elements using attribute values in XPath?
Ans: We can search for elements using their attribute values in the
XPath. Let’s take an example where we will identify username field
using ID attribute.
WebElement username =
driver.findElement(By.xpath("//input[@id = 'username']"));

9. What is a dynamic web element in web page?


Ans: An element whose attributes dynamically change on refresh or
any other operations on the web page is called dynamic web
element.
10. What are XPath axes in Selenium?
Ans: XPath axes in selenium are methods to identify those dynamic
elements which are not possible to find by normal XPath method
such as ID, Classname, Name, etc.
11. What are commonly useful XPath axes methods used in
Selenium WebDriver?
Ans: The commonly XPath axes methods used in Selenium
WebDriver are child, parent, ancestor, sibling, preceding, self,
namespace, attribute, etc.
12. What is atomic values?
Ans: The node which has no parents or children is called atomic
values. For example, Automation Testing, TestNG, POM.
13. What is Siblings?
Ans: The node that has the same parent is called siblings. In the
above XML document, title and body elements both are siblings.
For more practice on XPath axes methods, go to this tutorial: XPath
Axes in Selenium
14. How to handle Complex and Dynamic Elements in
Selenium using XPath?
Ans: There are following ways by which we can handle complex and
dynamic element in selenium. They are as follows:
 Basic XPath
 XPath Contains
 XPath Starts-with
 XPath Ends-with
 Using “OR” Statement
 Using “AND” Statement
 XPath Text
For more detail and Practice, go to this tutorial: XPath Contains Text

Interview Questions based on Select Class

1. What is Select in Selenium WebDriver?


Ans: Select is a class provided by Selenium which is used to work
with a dropdown element. The select class allows us to select an
element from the drop-down and lists that are created with the
HTML <select> element.
2. What is the super class of Select class?
Ans: Object class is the super class of Select class.
3. Which interface is implemented by Select class?
Ans: Select class implements ISelect interface.
4. How to create Object of Select Class in Selenium?
Ans: Since the select is an ordinary class, its object is created by
using the new keyword. After creating object, we will have to pass
the dropdown WebElement as parameter to its constructor.
The syntax to create an object of select class is as follows:
Select select = new Select( WebElement element);

5. Which exception is thrown by Select class when the


element is unable to be selected?
Ans: UnexpectedTagNameException will throw, when the element is
not a SELECT.
6. How many types of methods are provided by Select class
to select an element from the dropdown list?
Ans: The select class provides three methods to select an element
from the dropdown list. They are as follows:
 selectByValue
 selectByIndex
 selectByVisibleText
For more details, go to this tutorial: Select Class in Selenium | Select
Class Method
7. What is the use of deselectAll(), deselectByIndex(), and
deselectByValue, and deselectByVisibleText() methods?
Ans: a) deselectAll(): It is used to clear all selected entries.
b) deselectByIndex(): This method is used to deselect or clear an
option at the specified index.
c) deselectByValue(): It is used for deselecting all the options whose
“value” attribute matches the specified argument.
d) deselectByVisibleText(): It is used to deselect all options that
display text matching the parameter.
8. Which method of Select class is used to get the first
selected option from the list?
Ans: getFirstSelectedOption() method is used to get the first
selected option in the list.
9. Which method should be used to check that the list
supports multiple options or not?
Ans: isMultiple() method.
10. How to select dropdown value by visible text, value, and
index in Selenium WebDriver?
Ans: Refer to this tutorial for coding: How to select dropdown value
in Selenium.
11. How to select Multiple values in Dropdown using
Selenium Webdriver?
Ans: Refer to 10.
12. How to get Selected values from Dropdown in Selenium?
Ans: getAllSelectedOptions() of select class. For coding, go to
tutorial: how to select dropdown value.
13. How to deselect dropdown value in Selenium WebDriver?
Ans: For coding, go to this tutorial: Deselect dropdown value in
Selenium.

Interview Questions based on Alert


1. What is an Alert?
Ans: Alert is a small dialogs message box that displays an important
notification on the screen to give certain kinds of information to
users or ask for permission to perform a certain kind of operation.
2. Is Alert class or Interface?
Ans: Alert is an interface.
3. What are the methods provided by Alert interface in
Selenium?
Ans: Alert interface provides four methods to handle modal dialog
box. They are:
a) dismiss(): It is used to clicking on the ‘Cancel’ button of the alert.
b) accept(): It is used to clicking on the ‘Ok’ button of the alert.
c) getText(): This method is used to capture alert messages.
d) sendKeys(String stringToSend): It is used to send or input data to
the alert box.
4. How to handle simple Javascript, Confirmation, and
Prompt Alert boxes in Selenium?
Ans: For coding step by step, go to this tutorial: How to handle Alert
in Selenium WebDriver.

You might also like