Selenium Interview Questions and Answers | Top 220 Selenium Questions

Top 220 Selenium Interview Questions for Job Interview.

Questions on Selenium framework, Selenium webdriver and Selenium automation testing :

1. What is Selenium and what is it made of?

Answer : Selenium is a suite of tools used for automated web testing. It is made out of

  • Selenium IDE (Integrated Development Environment is a tool for recording and playing back. It is a plugin that can be used only on Mozilla Firefox.
  • WebDriver and RC provide the APIs for almost all languages like Java, .NET, PHP, etc. Webdriver and RC works with almost all web browsers.
  • Grid helps todistribute tests on multiple machines so that test can be run parallel which helps in reducing the time required for executing in browser test suites.

2. What is Selenium 2.0?

Answer : The web testing tools Selenium RC and WebDriver are combined in a single tool known as the Selenium 2.0

3. Mention what is Selenium 3.0?

Answer : Selenium 3.0 is the latest version of Selenium which has released 2 beta versions for user testing. It has the follow updates compared to Selenium 2.0:

  • Minimum Java version required is 8+
  • It supports Firefox Via Mozilla’s geckodriver.
  • The grid fixes NPE’s on-registration when the browser is not specified.
  • The support for Edge is provided by the MS.
  • It supports Safari on MacOS via Apple’s own Safari driver.

4. How to find an element using Selenium?

Answer : In Selenium, every object of control in a web page is referred to as an element. There are different ways to find an element in a web page such as ID, Name, Tag, Attribute, etc.

5. List the test types supported by Selenium.

Answer : The test types supported by Selenium are Functional and Regression.

For the post-release validation with continuous integration, automation tools like Hudson, Jenkins and Quick Build can be used.

6. What is assertion in Selenium? What are the types of assertion?

Answer : Assertion is used as a verification point in Selenium. It verifies the state of the application that conforms to what is expected. The types of assertion are “assert”, “verify”, etc.

 7. Mention the use of X-path.

Answer : X-Path is used to find the Web element in corresponding web pages. It is also useful in identifying the dynamic elements.

8. Differentiate between a single and a double slash in X-path.

Answer : A Single slash (/) starts selection from the document node and allows you to create the ‘absolute’ path expressions. A Double Slash (//) starts selection matching anywhere in the document and enables to create ‘relative’ path expressions.

9. List the technical challenges faced by users of Selenium.

Answer : The technical challenges with Selenium are

  • It supports only web based applications
  • It does not support Bitmap comparison
  • For any reporting related capabilities, users have to depend on third party tools.
  • No vendor support is provided for tool compared to commercial tools like HP UFT.
  • Since there is no object repository concept in Selenium, the ability of maintaining objects becomes difficult

 8. Differentiate between TypeKeys and TypeCommands.

Answer : TypeKeys() trigger JavaScript event in most of the cases whereas .type() doesn’t do so. TypeKey() settles value attribute using JavaScript whereas .type() emulates the actual user typing.

9. Differentiate between verify and assert commands.

Answer : Theassert() checks whether an element is present on the page or not. The test will stop if the check fails. The verify() command checks whether the element is on the page. Even if the element is not present, the test will carry on executing.

10. What is JUnit Annotations? What are different types of annotations which are useful?

Answer : In JAVA a special form of syntactic meta-data can be added to Java source code known as Annotations. Variables, parameters, packages, methods and classes are annotated through this process.

11. When using the click command, can we use screen coordinate simultaneously? 

Answer : To click on specific part of element, you would need to use clickAT() command. The clickAt() command accepts the element locator along with the x, y co-ordinates as arguments. The syntax is as: clickAt (locator, cordString)

12.  What are the advantages of Selenium?

Answer :

  • It supports languages like C#, PHP, Java, Perl, Python.
  • It supports different Operating Systems like Windows, Linux and Mac OS.
  • It has powerful methods to locate elements through tools like Xpath, DOM and CSS.
  • It has a highly developed community supported by Google.

13. Why should testers opt for Selenium instead of QTP?

Answer : Selenium is more popular than QTP as

  • Selenium is an open source tool while QTP is a commercial tool.
  • Selenium is specially used for testing web based applications whereas QTP is used for testing client server applications as well as web-based applications.
  • Selenium supports browsers like Mozilla Firefox, IE, Opera, Safari on operating systems like Windows, Mac, Linux etc. QTP, however, is limited to Internet Explorer on Windows.
  • Selenium supports many programming languages like Ruby, Perl, Python while QTP supports only VB script.

14. What are the four parameter that a user has to pass in Selenium?

Answer : The four parameters that have to be passed in Selenium are Host, Port Number, Browser and URL.

15. Differentiate between setSpeed() and sleep() methods?

Answer : Both these functions delay the speed of execution.

Thread.sleep() stops the current thread for the specified period of time. It accepts a single argument in integer format.

Ex: Thread.sleep(2000) makes the thread wait for 2 seconds

SetSpeed() stops the execution for every selenium command for aspecific amount of time. It also accepts a single argument in integer format

Ex: Selenium.setSpeed(“2000”) makes the command wait for 2 seconds.

16. What is the Same Origin Policy? How you can avoid it?

Answer : The “Same Origin Policy” was introduced for security reasons, and it ensures that content of your site is inaccessible by a script of another site. According to this policy, any code loaded within the browser can only operate within that website’s domain.

To avoid this, proxy injection method is used. In this, mode the Selenium Server acts as a client-configured HTTP proxy. It is situated between the browser and application under test which guises the AUT under a fictional URL.

17. What are heightened privileges browsers?

Answer : Heightened privileges are similar to Proxy Injection which allow websites to execute things that are not permitted. The only difference is that browsers are launched in a special mode known as heightened privileges. The Selenium core can open the AUT directly and also read/write content without passing the whole AUT through Selenium RC server.

18. How can “Submit” be used to submit a form using Selenium?

Answer : The syntax element.submit (); is used to submit a form in Selenium.

Alternatively, the click method can be used on the element which completes the form submission.

19. What are the features of TestNG. List the functionalities of TestNG which make it more effective.

Answer : TestNG is a testing framework based on JUnit and NUnit used to shorten a broad range of testing needs. The functionalities which make it more efficient framework are:

  • Supporting annotations
  • Supporting data-driven testing
  • Flexible test configuration
  • Ability to re-execute failed test cases

20. Differentiate between Implicit wait and Explicit wait.

Answer : Implicit Wait sets a time limit for all successive Web Element searches. The specified amount of time is used for searching for the element again and again before throwing a NoSuchElementException().

Explicit Wait is a one-time method, used for a particular search.

21. Which attribute should be considered throughout the script if “if no frame Id as well as no frame name” is displayed?

Answer : The driver.findElements(By.xpath(“//iframe”)) can be used in such a case. It returns a list of frames. Switch to each and every frame and search for the required locator and finally break the loop.

22. Differentiate between findElements() and findElement().

Answer : findElement() finds the first element in the current page using the “locating mechanism” and returns a single Web Element. Using the given “locating mechanism”, findElements() finds all the elements in the current page and returns a list of web elements.

23. Explain the JUnits annotation linked with Selenium.

Answer : The JUnits annotation linked with Selenium are:

  • @Test public void method() – This identifies whether a method is a test method environment.
  • @Before public void method() – This executes before each test.
  • @After public void method()- This method is used to execute a method before an annotation is used.

24. Explain Data-driven and Keyword-driven framework.

Answer : In data-driven framework, the test data is separated and kept outside the Test Scripts. Test data is read from the external files and loaded into variables inside the Test Script. Variables are used for both input values and verification values. In the keyword-driven framework, the functionality of the application under test is documented in a table. It requires development of data tables and keywords, independent of test automation.

25. How to login into any site if an authentication popup for password and username id displayed.

Answer : In such a case, pass the username and password with the URL. The syntax is http://username:password@url.

26. How to assert text of any webpage?

Answer : To get test from element and store it in a text variable, use the following syntax: WebElement el = driver.findElement(“ElementID”))

To assert text from an expected webpage, use the following syntax:

String text = el.getText();

Assert.assertEquals(“Element Text”, text);

27. What is the difference between Borland Silk and Selenium?

Answer :

Silk Test Tool

Selenium Test Tool

Silk test supports Internet Explorer and Firefox.

Selenium supports many browsers like Internet Explorer, Firefox, Safari, Opera, etc.

Borland Silk test is a commercial testing tool.

Selenium is a free test automation tool.

Silk test can be used for client server applications.

Selenium can be used only for web applications.

Silk test uses test scripting languages.

Selenium suite has the flexibility to use multiple languages like Java, Ruby, Perl, etc.

28. What is Object Repository?

Answer : An object repository is an indispensable entity in any UI automation. It allows a tester to store all objects that are to be used in a script. These objects are stored in one or more centralized locations.

29. Explain the working of a Selenium Grid.

Answer : Selenium Grid send tests to the hub. These tests are redirected to the Selenium Webdriver, which launches the browser and runs the test. It also allows parallel testing.

30) Can Selenium grid be used for performance testing?

Answer : Yes, it can be used. However, it does not work as effectively as a dedicated Performance Testing tool like Loadrunner.

31.  List the advantages of Webdriver compared to Selenium Server.

Answer :

  • Selenium Server provides the Selenium RC functionality which is used for the compatibility of Selenium 1.0.
  • Selenium Web driver makes direct calls to a browser using the browser’s native support for automation while Selenium RC requires selenium server to inject JavaScript into the browser.

32.  Mention the capabilities of Selenium WebDriver.

Answer : The Selenium WebDriver should be used when the user requires improvement support for handling multiple frames, pop ups , multiple browser windows and alerts, page navigation and drag & drop, Ajax based UI elements and multi-browser testing.

33.  How can one find broken images in a page using Selenium Web driver?

Answer : To find broken images in a page using Selenium web driver, the following must be followed:

  • Get XPath and all the links in the page using the tag-name.
  • Click on each and every link within the page.
  • Search for 404/500 in the target page title.

34.  How can one handle colors in WebDriver?

Answer : To handle colors in web driver you can by send ‘color’ string as an argument in the getCssValue(arg0) method.

35.  Using web driver, how can one store a value already in a text box?

Answer : You can use the following command to store a value, stored in a text box using WebDriver: driver.findElement(“your Textbox”)).sendKeys(“your keyword”);.

36.  How can one switch between frames?

Answer : To switch between frames in WebDriver the driver.switchTo().frame() method is used along with one of the three possible arguments:

  • A number:  Selects the number by the zero-based index.
  • A number or ID: Selects a frame by its name or ID.
  • Previously found WebElement: Using its previously located, the WebElement selects a frame.

37.  Mention the 5 different exceptions in Selenium WebDriver?

Answer : The 5 different exceptions you in Selenium web drivers are:

  • WebDriverException
  • NoSuchElementException
  • TimeoutException
  • NoAlertPresentException
  • NoSuchWindowException

38.  Using WebDriver, how can one perform double click?

Answer : You can perform double click by using the given functions:

  • act.doubleClick(webelement);
  • Syntax- Actions act = new Actions (driver);

39. How can one use Selenium to upload a file?

Answer : The type() command can be used to type the name of a file input box of upload file. Then, the “Robot” class in JAVA can be used to make file upload work.

40. Which web driver implementation is the fastest?

Answer : The HTMLUnit Driver implementation is the fastest. The HTMLUnitDriver does not execute tests on a browser but a plain http request, which is quicker than launching a browser and executing tests on it.

41. How can one handle frames using Selenium 2.0?

Answer : To bring control in a HTML frame you can use the SwitchTo() frame method like this:


To specify a frame one can also use an index number:


42. Distinguish between getwindowhandles() and getwindowhandle() ?

Answer : The getwindowhandles() is used to get the address of all the open browser  windows and the return type is Set<String>. The getwindowhandle() is used to get the address of the current browser where the control is and the return type is string.

43. How can one switch back from a frame?

Answer : To switch back from a frame use the method as shown below: defaultContent()driver.switchTo().defaultContent();

44. List the different types of locators.

Answer : The different types of locators are,, By.tagName(), By.className(), By.linkText(), By.partialLinkText(), By.xpath and By.cssSelector().

45. What is the command used to display the values of a variable into the output console?

Answer : In order to display a constant string, the command that can be used is echo <constant string>. If order is used to display the value of a variable you can use command like echo ${variable name>>.

In case of Java, System.out.println() is used in place of echo.

46.   How can one use recovery scenario with Selenium?

Answer : Recovery scenarios depend upon the programming language being used. If Java is used, then exception handling can be used to overcome such situations.

47. How to iterate through options in a test script?

Answer : To iterate through options in a test script, one can loop features of the programming language.

48. How can one prepare customized HTML report using TestNG in a hybrid framework?

Answer : There are three ways to achieve this:

  • With the help of ANT in Junit.
  • Using inbuilt default.html to get the HTML report is TextNG. Also XST reports from ANT, Selenium,Testng combinations can be used for the same.
  • Using one’s own customized reports using XSL jar for converting XML content to HTML.

49. How can ONE create html test report from one’s test script?

Answer : To create HTML test report, there are three ways:

  • TestNG uses inbuilt default.html to get the HTML report. Also XLST reports from ANT, Selenium, TestNG combination is used.
  • Junit achieves the same with the help of ANT.
  • Using one’s own customized reports using XSL jar for converting XML content to HTML.

50.  How can one insert a break point in Selenium IDE?

Answer : In Selenium IDE to insert a break point, use the following:

  • Select “Toggle break point” by right clicking on the command in Selenium IDE.
  • Press “B” on the keyboard and select the command in Selenium IDE.
  • Multiple break points can also be set in Selenium IDE.

51.  In Selenium IDE, how can you debug the tests?

Answer :

  • Insert a break point at the location where you want to execute the test step by step.
  • Run the test case.
  • At the given break point, execution will be paused.
  • To continue with the next statement, click on the blue button.
  • Click on the “Run” button to continue executing all the commands.

52.  What is Selenese and what are its different types?

Answer : Selenese is a selenium set of command which are used to run the tests. It is of three types:

  • Actions: They are used for performing the operations and interactions with the target elements.
  • Assertions: They are used as a check points.
  • Accessors: They are used for storing the values in a variable.

53.  What are the limitations of Selenium IDE?

Answer : The limitations of Selenium IDE are:

  • Exceptional handling not present.
  • Selenium IDE uses only HTML.
  • External databases reading is not possible with this IDE.
  • Reading from the external files like is not supported.
  • The execution of conditional or branching statements is not supported.

54.  What are the two modes of views in Selenium IDE?

Answer : Selenium IDE can be opened as a pop up window or in a side bar.

55.  In selenium IDE what are the element locators that can be used to locate elements in a web page?

Answer : In Selenium IDE, the four locators used are X-path locators, CSS locators, HTML ID and HTML name.

56.  How can one generate random numbers and dates for test data in Selenium IDE?

Answer : In Selenium IDE you can generate random numbers by using Java Script:




javascript{new Date()}

57.  How can one convert any Selenium IDE tests from Selenese to another language?

Answer : The format option of Selenium IDE can be used to convert tests into another programming language.

58.  Using Selenium IDE, is it possible to get data from a particular HTML table cell ?

Answer : The storeTable() command can be used for this purpose.



Css=#table 0.2


59.  What can cause a Selenium IDE test to fail?

Answer : The following cases can cause a failure:

  • When a locator has changed and the Selenium IDE cannot locate the element.
  • When an element in Selenium IDE, waiting to access, did not appear on the web page and the operation timed out.
  • When an element in Selenium IDE, trying to be accessed, was not created.

60.  How can one debug tests in Selenium IDE?

Answer : The following steps need to be followed:

  • Insert a break point at the location where you want the execution to occur.
  • Execute the test case.
  • At the given break point, execution will be paused.
  • To continue with the next step, click on the Blue Button.
  • To run commands at a time, click on the run button.

61.  Using Selenium IDE, how can one execute a single line?

Answer : Single line command can be executed in two ways in Selenium IDE:

  • Select the “Execute this command” by right clicking on the command in Selenium IDE.
  • Press “X” key on the keyboard after selecting the command in Selenium IDE.

62.  In which format does a source view show the script in Selenium IDE?

Answer : In Selenium IDE, source view shows the script in XML format.

63.  How can one insert a start point in Selenium IDE?

Answer : A start point can be inserted in Selenium IDE in 2 ways:

  • Press “S” on the keyboard and select the command in Selenium IDE.
  • Right click on the command and then select  “Set / Clear Start Point”.

64.  How to test a user-created element locator?

Answer : To test the user-created locator, one can use the Find option of Selenium IDE. When you click on it, you can see an element being highlighted on the screen if the element-locator works correctly. Otherwise an error message will be displayed in case of a failed element-locator.

65.  What are Regular Expressions? How can one use regular expressions in Selenium IDE?

Answer : A regular expression is a special text string used for describing a search pattern. In Selenium IDE, regular expression can be used with the keyword regexp. It is usedas a prefix to the value. The pattern needs to be included for the expected values.

66.  What are Core Extensions?

Answer : If the user wants to extend the default functionalities provided by Selenium Function Library, a Core Extension is created. They are also called User Extensions. One can even download ready-made Core Extensions created by other Selenium enthusiasts.

67.  How can one handle working with multiple windows in Selenium?

Answer : We can use the command selectWindow() to switch between windows. This command uses the title of Windows to identify the different windows while switching.

68.  How can one verify the specific position of a web element?

Answer : The methods verifyElementPositionLeft() & verifyElementPositionTop() can be used for this. It does a pixel comparison of the position of the element from the Left and Top of page respectively.

69.  How can one retrieve the message in an alert box?

Answer : The storeAlert() command can be used here. It fetches the message of the alert pop up and stores it in a variable.

70. What is Selenium Remote Control (RC)?

Answer : Selenium IDE has certain limitations in terms of browser and language support. By using Selenium RC, these limitations can be diminished.

  • On different platforms and web browsers, for automating web application Selenium RC is used with languages like Java, C#, Perl, Python, etc.
  • Selenium RC is a Java-based application and uses all kinds of languages to interact with the web application.
  • Using this server, the restrictions can be bypassed.

71. Why is Selenium RC used?

Answer : Selenium IDE does not directly support many functions like conditional statements, iterations, logging and reporting of test results, unexpected error handling, etc. As an IDE, it supports only HTML language. To handle such issues, the Selenium RC is used. It supports languages like Perl, Ruby, Python, PHP, etc.

72. What is the main difference between Selenium WebDriver and RC?

Answer : Selenium RC injects JavaScript functions into browsers when the page is loaded. Selenium WebdDriver on the other hand drives the browser using browser’s in-built supports.

73. What are the advantages of Selenium RC?

Answer : Selenium RC has the following advantages:

  • Can read or write data from external files.
  • It handles dynamic objects and Ajax based UI elements easily.
  • Loops and conditions can benused for better performance and flexibility.
  • It supports multiple programming languages and operating systems.
  • Selenium RC can be used for any JavaScript enables browsers.

74. What is a framework? What are the frameworks available in Selenium RC?

Answer : A collection of libraries and classes is known as a framework. A framework is extremely useful in the situation where testers have to automate test cases. NUnit, JUnit, TestNG, Bromine, RSpec, unittest are some of the frameworks available in Selenium RC.

75. How can one handle pop-ups in RC?

Answer : To handle pop-ups in Selenium RC, the selectWindow() method is used. The pop-up window gets selected and the windowFocus() method lets the control from current window to the pop-up window.

76. What are the technical limitations one faces using Selenium RC?

Answer : Apart from Same Origin Policy restriction, Selenium RC is also restricted from exercising anything that is outside the browser.

77. Can one use Selenium RC to drive tests on two different browsers on one operating system without using Selenium Grid?

Answer : Yes, it is possible to do so. Using Java client driver of Selenium, TestNG allows one to drive tests on two different browsers. By using Parallel-test Attribute, one can set tests to be executed in parallel and can also define two different tests using different browsers.

78. Why should one use TestNG with Selenium RC?

Answer : In order to implement full automation against different server and client platforms, one needs a way to invoke the tests from a command line process. TestNG allows this and also provides reports that tell one what happened and provide flexibility while creating test suites.

79. Explain how one can capture server-side log Selenium Server?

Answer : To capture server-side log in Selenium Server, one can use the given command: java –jar .jar –log selenium.log.

80. Other than the default port 4444 how can one run Selenium Server?

Answer : One can run the Selenium server on java-jar selenium-server.jar-port instead of the default port.

81. How does the Selenium Grid hub keep in touch with the RC slave machine?

Answer : At a predefined time, the Selenium Grid hub keeps polling all RC slaves to make sure it is available for testing. The deciding parameter is called remoteControlPollingIntervalSeconds and is defined in the grid_configuration.yml file.

82. Using Selenium how can one handle network latency?

Answer : To handle network latency one can use driver.manage.pageloadingtime for network latency.

83. To enter values into text boxes what is the command that can be used?

Answer : To enter values into text boxes, one can use the command sendkeys().

84. How can one identify an object using Selenium?

Answer : To identify an object using Selenium one can use isElementPresent(String locator) and isElementPresent() method. The latter takes a locator as the argument and if the elment is found, it returns a Boolean.

85. In Selenium, what are Breakpoints and Startpoints?

Answer : Breakpoints are executed to stop implementation immediately. It helps to verify that the code is working as expected. Startpoints indicate the point from where execution should begin. They can be used when one wants to run the Test Script from the middle of the code or a breakpoint.

86. Why should one choose Python over Java in Selenium?

Answer : Python is better than Java in the following ways:

  • Java programs tend to run slower than Python programs.
  • Java uses traditional braces to start and end blocks while Python uses indentation to do the same.
  • Java employs static typing and Python is dynamically typed.
  • Python is simpler and more compact as compared to Java.

87. What are the challenges faced during handling Ajax Call in Selenium WebDriver?

Answer : The challenges faced while handling Ajax Call in Selenium Webdriver are:

  • Using the pause() command for handling Ajax call is not completely reliable. Pausing for a long time makes the test unacceptably slow and increases the testing time. The waitforcondition() method is more helpful in testing Ajax applications.
  • It is difficult to assess the risk associated with certain Ajax applications.
  • Since, developers are given full freedom to modify Ajax application, the testing process becomes challenging.
  • Creating automated test requests becomes difficult for testing tools such as AJAX applications. They often use different encoding or serialization technique to submit POST data.

88. What is IntelliJ?

Answer : Intellij is an IDE that helps one to write better and faster code in Selenium. It can be used as an option in NetBeans and Eclipse.

89. In what ways can you customize TestNG report?

Answer : You can customize a TestNG report in two ways:

  • Use the ITestListener Interface
  • Use the IReporter Interface

90. Which JAVA API is required to generate pdf reports?

Answer : To generate pdf reports, the Java API IText is required to be used.

91. What is Listeners in the Selenium WebDriver?

Answer : In Selenium WebDriver, Listeners are used to listen to the event defined in the Selenium script and behave accordingly. It allows the customization of TestNG reports or logs. There are two main listeners present- WebDriver Listeners and TestNG Listeners.

92. What are the types of Listeners in TestNG?

Answer : The following are the types of Listeners in TestNG:

  • IInvokedMethodListener
  • IInvokedMethodListener2
  • IMethodInterceptor
  • IAnnotationTransformer
  • IAnnotationTransformer2
  • IConfigurable
  • IConfigurationListener
  • IReporter
  • ISuiteListener
  • ITestListener
  • IExecutionListener
  • IHookable

93. What is desired capability? How is it useful in terms of Selenium?

Answer : Desired capability is a series of key/value pairs that stores the browser properties such as browser name, browser version, the path of the browser driver in the system, etc. It does all this to determine the behavior of the browser at run time.

For Selenium, it can be used to configure the driver instance of Selenium WebDriver and to run the test cases on a different browser with different operating systems and versions.

94. For Database Testing in Selenium Webdriver, which API is required?

Answer : For Database Testing in Selenium Webdriver, one needs JDBC (Java Database Connectivity) API. It allows one to execute SQL statements.

95. When should one use AutoIT?

Answer : Selenium is designed to automate web-based applications on different browsers. However, to handle window-based GUI applications and non-HTML popups in the application, one needs AutoIT.

96. Why does one need Session Handling while working with Selenium?

Answer : During test execution, the Selenium WebDriver has to interact with the browser all the time to execute given commands. At the time of execution, a situation might occur where before current execution completes, someone else starts execution of another script in the same machine and in the same type of browser. To avoid such a situation, one needs Session Handling.

97. What are the advantages of using GitHub for Selenium?

Answer : The advantages of Using GitHub for Selenium are as follows:

  • Multiple people can work on the same project and can update project details and inform other team members simultaneously.
  • Jenkins can also help to build the project from the remote repository regularly. This helps to keep track of failed builds.

97. What is Automation Testing?

Answer : Automation testing is the process through which software tools are used to execute pre-scripted tests on a software application before releasing it into production. Special softwares are used to control the test execution, the results and the predicted result comparisons, the test preconditions setting up, and other test reporting and test control functions.

97. What are the main advantages of Automation Testing?

Answer : Regression testing coverage, increased test effectiveness, reduction of the test interval, test engineer productivity, consistency in testing, reducing human-generated errors, test cases reusability, and reduced software maintenance cost are some of the main advantages of Automation Testing.

98. How many types of WebDriver APIs are available in Selenium?

Answer : The list of driver classes could be used for the browser automation.

  • AndroidDriver
  • HtmlUnitDriver
  • ChromeDriver
  • EventFiringWebDriver
  • iPhoneDriver
  • FirefoxDriver
  • InternetExplorerDriver
  • iPhoneSimulatorDriver
  • RemoteWebDriver

99. What kind of test types are supported by Selenium?

Answer : The following test types are supported by Selenium:

  1. Cross Browser Testing
  2. Functional Testing
  3. Regression Testing
  4. Sanity Testing
  5. UI testing (black box)
  6. Integration Testing
  7. Smoke Testing
  8. Responsive Testing

100. What is X-Path?

Answer : XPath is a language that describes a way to discover and develop items in XML documents by using an addressing syntax based on a path through the document’s logical hierarchy or structure.

101. What is an Absolute X-Path?

Answer : Absolute XPath is the direct way to find an element. However, XPath fails if there are any changes made in the path of the element.

Example: html/body/div[3]/div/div[1]/div/div/div[1]/div/input

102. What is a Relative X-Path?

Answer : Relative XPath allows users to start from the middle of the HTML DOM structure and doesn’t require long written XPath.

Example – input[@id=’email’].

103.  How can web element attributes be inspected in order to use them in different locators?

Answer : Firebug is a Firefox plugin that provides various development tools for debugging applications. Firebug is used specifically to inspect web-elements to use attributes like id, class, name etc. in different locators.

104. Mention the languages supported by Selenium?

Answer : Selenium supports Java, C#, Python, and Ruby and provides PHP and Perl WebDriver implementations, too.

105. What the WebDriver supported Mobile Testing Drivers do you know?

Answer : AndroidDriver, IphoneDriver and OperaMobileDriver are some of the Mobile Testing Drivers supported by the Selenium WebDriver.

106. Distinguish between X-Path and CSS Selector.

Answer : XPaths help to traverse up in the document while CSS selector allows only downward movement in the document.

107. How can you find if an element is displayed on the screen?

Answer : The following methods help the user to check the visibility of web elements: isDisplayed(), isEnabled() and isSelected(). The web elements can be buttons, drop boxes, checkboxes, radio buttons, labels etc.

108. What is the difference between type() and typeAndWait() command?

Answer : The type() command is used to type keyboard key values into a text field of the web application. It is also used to select values of the combo box. The typeAndWait() command is used when typing is completed and software web page starts reloading.

109. How can one clear text written in a text field?

Answer : Text written in a text field is deleted or cleared by using the clear() method.

110. How to check a checkBox in Selenium?

Answer : The click() method can be used for checking the checkbox and for clicking buttons or radio buttons.

111. How to verify if the checkbox/radio is checked or not?

Answer : The isSelected() method is used to verify whether the checkbox or radio button is checked or not.

112. Differentiate between close and quit command.

Answer : The driver.close() method is used to close the current browser having focus . To close all the browser instances, the driver.quit() method is used.

113. What are different navigation commands?

Answer : The different navigation commands are:

  • The navigate().back() method takes the user back to the previous webpage in the web browser’s history.
  • The navigate().forward() allows the user to move to the next web page in accordance with the browser’s history.
  • The navigate().refresh() method enables the user to refresh the current web page there by reloading all the web elements.
  • A user can launch a new web browser window and navigate to any specified URL by executing the navigate().to() method.

114.  How can one handle Web-based pop-ups?

Answer : There are four effective methods to handle Web-based pop-ups:

  • The string getText() method returns the text displayed on the alert box.
  • The void accept() method allows the user to click on the “Ok” button as soon as the pop-up window appears.
  • The void dismiss() method enables the user to click on the “Cancel” button as soon as the pop-up window appears.
  • The void sendKeys(String stringToSend) method allows the user to enter the specified string pattern into the alert box.

115. How to refresh browser while using Selenium?

Answer : The list of commands that help to refresh a page in Selenium are:

  • navigate().refresh()
  • navigate().to(driver.getCurrentUrl())
  • getCurrentUrl()
  • sendKeys(Keys.F5)

116. How to maximize browser window in Selenium?

Answer : The driver.manage().window().maximize(); command is used to maximize a browser window in Selenium.

117. How can we find the value of different attributes like name, class, value of an element?

Answer : The getAttribute(“{attributeName}”) method is used find the value of different attributes of any element.

118. Can cookies be deleted in Selenium?

Answer : The driver.manage().deleteAllCookies() command is used for deleting all cookies in Selenium.

119. How to perform right click using Selenium WebDriver?

Answer : Use the following steps to perform right click:

Actions act = new Actions(driver); // driver is WebDriver typeact.moveToElement(webElement).perform();act.contextClick().perform();

120. How to perform drag and drop using Selenium WebDriver?

Answer : Use the following steps to perform drag and drop:

  • Actions builder = new Actions(driver);
  • Action dragAndDrop= builder.clickAndHold(SourceElement)moveToElement(TargetElement)release(TargetElement)build();
  • dragAndDrop.perform();

121. What kind of mouse actions can be performed using Selenium?

Answer : Selenium supports multiple mouse actions:

  • mouseUp(WebElement element)
  • mouseDown(WebElement element)
  • mouseMove(WebElement element, long xOffset, long yOffset)
  • click(WebElement element)
  • contextClick(WebElement element)
  • doubleClick(WebElement element)
  • mouseMove(WebElement element)

122.  What kind of keyboard operations can be performed in Selenium?

Answer : Selenium supports multiple keyboard operations:

  • The .pressKey(“non-text keys”) method is used for keys like control, function keys, etc. that are non-text.
  • The .releaseKey(“non-text keys”) method is used in conjunction with key press events to simulate release of a key from a keyboard event.
  • The .sendKeys(“sequence of characters”) is used to pass a character sequence to an input or textbox element.

123.  What is JUnit?

Answer : Introduced by Apache, JUnit is an open source Java applications testing framework. A process of adding a special form of syntactic metadata to Java source code is called annotation. Junit provides a set of annotations in the form of variables, parameters, packages, methods and classes.

124.  What is TestNG? Why is it better than JUnit?

Answer : TestNG is a testing framework inspired from JUnit and NUnit. It uses the merits of both the developers and testers.

These are some of the functionalities that make it more powerful and easier to use as compared to JUnit:

  • It tests whether the code is multithread safe.
  • It supports data-driven testing.
  • It supports parameters.
  • It provides a variety of tools and plug-ins support.
  • The default JDK functions for runtime and logging are also provided.
  • It allows flexible test configuration.

125.  What kinds of annotations are used in TestNG?

Answer : The following annotations are used in TestNG:

  • Test
  • BeforeSuite
  • AfterSuite
  • BeforeTest
  • AfterTest
  • BeforeClass
  • AfterClass
  • BeforeMethod
  • AfterMethod

126.   How to set test case priority in TestNG?

Answer : The TestNG Priority is used to schedule all test cases. In order to achieve this, one needs to add an annotation as @Test(priority=<value>). The default value will be zero for priority. If the priority is not mentioned, all the test cases are taken as “priority=0” and executed accordingly.

127. Can a captcha and bar code reader be automated by using Selenium?

Answer : Neither captcha nor a bar code reader can be automated using Selenium.

128. How to verify tooltip text using Selenium?

Answer : The tooltip text in Selenium can be verified by fetching the value of the ‘title’ attribute.

129. How to locate a link using its text in Selenium?

Answer : The methods linkText() and partialLinkText() are used for link location.

130. Can we find all links on a web page?

Answer : As all links are of the anchor tag ‘a’, we can find all of them on a web page by locating elements of the tagName ‘a’. It can be executed as shown below:

List links = driver.findElements(By.tagName(“a”));

131. How can we capture screenshots in Selenium?

Answer : The following is an example where the getScreenshotAs method of TakesScreenshot interface is used to capture screenchots.

File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);FileUtils.copyFile(scrFile, new File(“C:\\screenshot1.jpg”));

132. What is Robot API?

Answer : The Robot API is used to control keyboard actions or mouse actions to interact with the OS windows like Download pop-ups, Alerts, Print Pop-ups, etc. or native Operation System applications like Notepad, Skype, Calculator, etc.

133. List methods of the Robot Class.

Answer : Some commonly used methods of Robot Class during web automation are:

  • keyPress() is the method with the press down arrow key of the keyboard.
  • keyRelease() is the method with the release down arrow key of the keyboard.
  • mouseRelease() is the method which will release the right click of the mouse.
  • mouseMove() is the method which will move mouse pointer to the specified X and Y coordinates.
  • mousePress() is the method which will press the right click of your mouse.

134.How to execute JavaScript in Selenium?

Answer : JavaScriptExecuter is used for JavaScript execution in Selenium. Follow the given example:

WebDriver driver = new FireFoxDriver();
if (driver instanceof JavascriptExecutor) {((JavascriptExecutor)driver).executeScript(“{JavaScript Code}”);}

135.  Which package can be imported while working with WebDriver?

Answer : The org.openqa.selenium java -cp bin;jars/* org.testng.TestNG testng.xml has to be imported while working with WebDriver.

136. How to get the width of a textbox?

Answer : You can get the width of the textbox by executing the following command in Selenium:

driver.findElement(By.xpath(“xpath of textbox ”)).getSize().getWidth();driver.findElement(By.xpath(“xpath of textbox ”)).getSize().getHeight();

137. What is the purpose of getOptions() method?

Answer : The getOptions() is used to get the selected option from the drop-down list.

138. How to Handle Alerts in Selenium WebDriver?

Answer : These are a few methods of Alerts handling which are widely used in Selenium Webdriver.

  • void dismiss() is used to click on the ‘Cancel’ button of the alert.
  • void accept() is used to click on the ‘OK’ button of the alert.
  • String getText() is used to capture the alert message.
  • void sendKeys(String stringToSend) is used to send some data to alert box.

139. What is the hybrid framework?

Answer : The combination of data-driven and keyword-driven framework is called the hybrid framework. In this design, we get the best of both the methodologies, and it is  practical in most of the automation cases.

140. What is a hub in Selenium Grid?

Answer : Selenium Grid hub is the central point or server that controls the test executions on different machines.

141.  What is a node in Selenium Grid?

Answer : Selenium Grid node is a hub attached machine. It has instances of running the test scripts. Unlike a hub, there can be innumerable nodes in Selenium Grid.

142. “Webdriver driver = new FirefoxDriver();” What does this line of code mean?

Answer : Through this line of code we create ‘WebDriver’ which is an interface along with an object of type WebDriver instantiating an object of FirefoxDriver class.

143. What is the testng.xml file used for?

Answer : The testng.xml file is used to configure the whole test suite. One can create a test suite, test groups, mark tests for parallel execution, add listeners and pass parameters to test scripts. It can be used for further test suite triggering.

144. What is the difference between @Factory and @DataProvider annotation?

Answer : The @Factory method creates test class instances and runs all test methods in that class with different data sets. The @DataProvider is concerned to individual test methods and run the specific methods for many times.

145. How can AJAX controls be handled in WebDriver?

Answer : AJAX allows the Web page to retrieve small amounts of data from the server without reloading the entire page. The different wait methods should be applied for testing Ajax application:

  • Explicit Wait
  • ThreadSleep
  • Implicit Wait
  • Fluent Wait
  • WebdriverWait

146. How can we make one test method dependent on other using TestNG?

Answer : One test method can run only after a successful execution of dependent test method by using dependsOnMethods parameter inside @Test annotation in TestNG: @Test(dependsOnMethods = { “preTests” })

147. What are Headless Drivers in Selenium RC?

Answer : Headless drivers offer the standard functions of any web browser. They are based on command-line tools without any screen output. Headless drivers are perfect for any automated setup.

148. How to launch IE/chrome browser?

Answer : One needs to download the executable file for chrome/IE and run commands as shown below:

System.setProperty(“”, “path to executable file”);

WebDriver driver = new ChromeDriver();

149. How to get the current page URL?

Answer : The driver.getCurrentURL() method is used to get the current page URL.

150. How to get typed text from a textbox?

Answer : One can select either method to get typed text from a textbox:

  • driver.findElement(“submitbutton”)).getAttribute(“text”);
  • driver.findElement(“submitbutton”)).getText();

151. How to get the title of the page?

Answer : The driver.getTitle() method is used to get the title of the page.

152. How to handle https website in Selenium?

Answer : The following must be executed in order to handle https websites in Selenium:

FirefoxProfile myProfile = allProfiles.getProfile(“CertificateIssue”);

153. What is the HtmlUnitDriver?

Answer : The HTML Unit Driver is the lightest weight and fastest implementation headless browser for WebDriver.

154. What is the use of AutoIt tool?

Answer : AutoIt v3 is a freeware with BASIC-like scripting language designed for automating Windows-based GUI and general scripting.

155. How to handle dynamic elements?

Answer : Relative xPaths are used to handle dynamic elements.

156. What is the Actions Class in WebDriver?

Answer : The Actions Class is a user-facing API for emulating complex user gestures. This class helps the user to use the keyboard or mouse directly instead of commands.

157. What are different forms of selenium?

Answer : The following are the different forms of Selenium:

  1. Selenium WebDriver – It is used to automate web applications using browser’s native methods.
  2. Selenium IDE – It is essentially a Firefox plugin that works on record and play-back principle.
  3. Selenium RC – It is officially deprecated by Selenium and is used to work on JavaScript to automate web applications.
  4. Selenium Grid – It allows to run parallel tests in selenium across multiple machines.

158. Can one test APIs or web services using Selenium WebDriver?

Answer : Since web services are headless, we cannot automate web services using selenium WebDriver. Hence, no Selenium WebDriver can be used to test any kind of APIs or web services.

159. What are the testing type supported by Selenium WebDriver?

Answer : The Selenium WebDriver can be used for performing automated functional and regression testing.

160. How can one locate an element by only partially matching its attributes value in X-Path?

Answer : By using contains() method, we can locate an element by partially matching its attribute’s value. This is helpful in the scenarios where the attributes have dynamic values with a one constant part.

161. How to locate elements using their text in XPath?

Answer : To locate the elements the text() method is used.

162. How to move to parent of an element using XPath?

Answer : By using the ‘..’ expression in XPath, one can move to parent of an element.

For example, the locator div[@id=”childId”]/.. moves to the parent of the div element with id value as ‘childId’.

163. How to move to the nth child element using XPath?

Answer : There are two ways of navigating to the nth element using XPath-

  • By using square brackets with the index position-
    For example, div[2] will find the second div element.
  • By directly using position()-
    For example, div[position()=3] will find the third div element.

164. What is the syntax of finding elements by class using CSS Selector?

Answer : By .className() method we can select all the element belonging to any particluar class. For example, .red() will select all elements in class ‘red’.

165. What is the syntax of finding elements by id using CSS Selector?

Answer : By using the idValue() method, we can select all the elements belonging to a particluar class. For example, userId() method will select the element having id – userId.

166. How can one select elements by their attribute value using CSS Selector?

Answer : By using the [attribute=value] method, we can select all the elements belonging to a particular class. For example, [type=small] will select the elements having attribute type of value small.

167. How can we move to nth child element using CSS selector?

Answer : By using the :nth-child(n) we can move to the nth child element. For example, the code ‘div:nth-child(2)’ will locate 2nd div element of its parent.

168. What is the use of driver.get(“URL”) and driver.navigate().to(“URL”) command? Is there any difference between the two?

Answer : Both the driver.get(“URL”) and driver.navigate().to(“URL”) commands are used to navigate to a URL passed as a parameter. There is no difference between these two commands.

169. How can we type text in a textbox element using selenium?

Answer : By using sendKeys() method we can type text in a textbox.

170. What are the significant changes in upgrades in various Selenium versions?

Answer : Selenium version 1 included only three suite of tools, the Selenium IDE, the Selenium RC and the Selenium Grid. There was no WebDriver in Selenium version 1. Selenium WebDriver was introduced in version 2. With the onset of WebDriver, the Selenium RC got deprecated and has not been in use since. Older versions of RC are available in the market but support for RC is not available. Currently, the third version of Selenium is in use, and comprises of IDE, WebDriver and Grid.

IDE is used for recording and for the playback of tests. The WebDriver is used for testing dynamic web applications via programming interface and the Grid is used for deploying tests in remote host machines.

171. What is exception test in Selenium?

Answer : An exception test is an exception that is expected to be thrown inside a test class. If a test case is written in such way that it should throw an exception, then one can use the @Test annotation and specify which exception is expected by mentioning it within the parameters.

Consider the given example:

@Test(expectedException = NoSuchElementException.class)

172. Why should one use an Excel Sheet in a Selenium project?

Answer : One must use Excel sheets because it can be used as data source for tests. An Excel sheet can also be used to store the data set while performing Data-Driven Testing.

173. How to use Excel Sheets in a Selenium Project?

Answer : When an Excel sheet is used as a data source, the following can be stored:

  • Application URL for all environments: Specifying the URL of the environment in which the testing is to be done.
  • User name and password credentials of different environments: One can store the access credentials of the different applications/ environments in an Excel sheet. It can be stored in encoded format and they can be easily decoded when being used.
  • Test cases to be executed: One can list the entire set of test cases in a column and in the next column, Yes or No can be specified which indicates whether that particular test case has to be executed or ignored.

When using an Excel sheet for Data-Driven Test, one can store the data for different iterations to be performed in the tests.

174. How can you redirect browsing from a browser through some proxy?

Answer : Selenium provides a PROXY class to redirect browsing from a proxy.

175. What is POM (Page Object Model)?

Answer : A Page Object Model or POM is a design pattern for creating an Object Repository for web UI elements. Each web page in an application is required to have it’s own corresponding page class. The page class is responsible for finding the Web Elements in that page and then perform operations on them.

176. What are the advantages of POM?

Answer : The advantages of using POM are:

  • It allows the separation of operations and flows in the UI from verification and hence, improves code readability.
  • Since the Object Repository is independent of Test Cases, multiple tests can be used with the same Object Repository.
  • It enables reusability of code.

177. What is Page Factory?

Answer : Page Factory provides an optimized way to implement Page Object Model. Optimization refers to the fact that memory utilization is very good and the implementation is done in an object oriented manner.

It is used to initialize the elements of the Page Object or instantiate the Page Objects itself. Annotations for elements can also be created (and recommended) as describing properties. They may not always be descriptive enough to differentiate one object from the other.

The concept of separating the Page Object Repository and Test Methods is followed here also.

178. How is synchronization achieved in WebDriver?

Answer : There are two types of wait statements which aid synchronization: Implicit Wait and Explicit Wait.

Implicit wait instructs the WebDriver to wait for some time by polling the DOM. Once implicit wait has been declared, it becomes available for the entire life of the WebDriver instance. By default, the value is 0. If longer default is set, then the behavior polls the DOM on a periodic basis depending on the browser/ driver implementation.

Explicit wait instructs the execution to wait for some time until some condition is achieved. Some of those conditions to be attained are elementToBeClickable, elementToBeSelected and presenceOfElementLocated.

179. What is the use of JavaScriptExecutor?

Answer : JavaScriptExecutor is an interface which provides a mechanism to execute Javascript through Selenium WebDriver. It provides “executescript” and “executeAsyncScript” methods, to run JavaScript in context of the currently selected frame or window.

180. How to scroll down a page using JavaScript in Selenium?

Answer : We can scroll down a page by using window.scrollBy() function.

For Example,

((JavascriptExecutor) driver).executeScript(“window.scrollBy(0,500)”);

181. How to scroll down to a particular element?

Answer : To scroll down to a particular element on a web page, we can use the function scrollIntoView(). Observe the given example:

((JavascriptExecutor)driver).executeScript(“arguments[0].scrollIntoView();”, element);
((JavascriptExecutor) driver).executeScript(“arguments[0].scrollIntoView();”, element);

182. How to handle keyboard and mouse actions using Selenium?

Answer : Special keyboard and mouse events can be easily handles by using Advanced User Interactions API. The Advanced User Interactions API contains the Actions and the Action Classes that are needed for executing these events.

183. Which files can be used as data source for different frameworks?

Answer : Some of the file types of the dataset that can be used are excel, xml, text, csv, etc.

184. How to resize a browser window using Selenium?

Answer : To resize the current window to a particular dimension, you can use the setSize() method. Observe the example:


Dimension d = new Dimension(420,600);


185. How to set a browser window to a particular size using Selenium?

Answer : To set the window to a particular size, use window.resizeTo() method. For example,

((JavascriptExecutor)driver).executeScript(“window.resizeTo(1024, 768);”);

186. How to select a value from dropdown?

Answer : To select a value from a dropdown follow the given steps:

  1. Identify the ‘select’ HTML element.
  2. Select an option from that dropdown element.

187. How to identify ‘select’ HTML element?

Answer : To identify the ‘select’ html element from the web page, we need to use findElement() method. Consider the given example:

WebElement mySelectElement = driver.findElement(“mySelect”));

Select dropdown = new Select(mySelectElement);

188. How to select an option from the dropdown element?

Answer : To select an option from that dropdown, either of the three ways can be followed:

  • dropdown.selectByVisibleText(“Bikes”);

Selecting an option from the text that is visible.

  • dropdown.selectByIndex(“1”);

Selecting an option by choosing the Index number of that option.

  • dropdown.selectByValue(“option2”);

Selecting an option by choosing the value of that option.

189. How to switch to a new window or tab which opens up after clicking on a link?

Answer : On clicking on a link in a web page, for changing the WebDriver’s focus to the new window the switchTo() command is used.

If the name of the window is unknown, the driver.getWindowHandle() command is used to get the name of all the windows that were initiated by the WebDriver. This command does not return the window names of browser windows which are not initiated by the WebDriver.

Once the name of the window is known, an enhanced for loop to switch to that window can be used.

190. Can text be entered without using sendKeys()?

Answer : Yes, text can be entered or sent without using sendKeys() method by using JavaScriptExecutor.

191. How to enter text without using sendKeys()?

Answer : By using DOM method of identification of an element, we can go to that particular document and then get the element by its ID and finally send the text by value. Look at the given example:

JavascriptExecutor jse = (JavascriptExecutor) driver;

jse.executeScript(“document.getElementById(‘Login’).value=Test text without sendkeys”);

192. How to login into any site if it is showing any authentication popup for username and password?

Answer : Since there is a popup for logging in, we need to use the explicit command and verify if the alert is actually present. If the alert is present, we need to pass the username and password credentials. The sample code is provided below:

WebDriverWait wait = new WebDriverWait(driver, 10);

Alert alert = wait.until(ExpectedConditions.alertIsPresent());

alert.authenticateUsing(new UserAndPassword(**username**, **password**));

193. How can one find broken links in a page using Selenium WebDriver?

Answer : The anchor tags <a> has to be used to determine the different hyperlinks on the web page. For each <a> tag, the attribute ‘href’ value is used to obtain the hyperlinks and then analyze the response received for each hyperlink when used in driver.get() method.

194. Which technique should be used throughout the script if there is neither frame id nor frame name?

Answer : If neither frame name nor frame id is available, then frame by index needs to be used. Follow the given syntax:

driver.switchTo().frame(int arg0);

195. What is parameterization in TestNG?

Answer : Parameterization is the technique of defining values in testng.xml file and sending them as parameters to the test class. This technique is especially useful when multiple login credentials of various test environments need to be passed.

196. How to pass parameters using testng.xml?

Answer : Understand the fllowing code in order to understand the process of passing parameters using testing.xml:

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE suite SYSTEM “”>
<suite name=”CustomSuite”><test name=”CustomTest”>
<parameter name=”myName” value=”John”/>
<class name=”ParameterizedTest1″ />

197. Explain DataProviders in TestNG.

Answer : DataProvider is a TestNG feature, which enables users to write Data-Driven tests. It supports Data-Driven testing. While using DataProviders, the same test method can run multiple times with different data-sets. DataProvider is another way of passing parameters to the test method.

198. How to use the DataProvider feature?

Answer : To use the DataProvider feature in any tests, a method annotated by @DataProviderand has to be declared and then used along with the said method in the test method using the DataProvider attribute in the Test annotation.

199. Can a single data provider method be called for multiple functions and classes?

Answer : Yes, the same DataProvider can be called to be used in multiple functions and classes by declaring DataProvider in separate class and then reusing it in multiple classes.

200. How to skip a method or a code block in TestNG?

Answer : To skip a particular test method, one can set the ‘enabled’ parameter false in test annotation.
Example: @Test(enabled = false)

By default, the value of ‘enabled’ parameter is true. It is not necessary to define the annotation while defining it.

201. What is soft assertion in Selenium?

Answer : Soft Assertions are used when multiple assertions need to be performed. They are customized error handlers provided by TestNG. They do not throw exceptions when assertion fails, and simply continue to the next test step.

202. How can you mark a test case as failed by using soft assertion?

Answer : To mark a test as failed with soft assertions, the assertAll() method must be called at the end of the test.

203. How does TestNG allow you to state dependencies?

Answer : Dependency is a feature that allows a test method to depend on a single or on a group of test methods. Method dependency only works if the part to be dependent is part of the same class or any of the inherited base classes.

204. Provide an example to state dependencies.

Answer : The following is an example to show state dependencies:


public void drive(){

system.out.println(“Driving the vehicle”);



public void changeGear() {

system.out.println(“Change Gears”);



public void accelerate(){



205. What does @Test(invocationCount=?) and @Test(threadPoolSize=?) indicate.

Answer : @Test(invocationCount=?) is a parameter that indicates the number of times a method must be invoked.
@Test(threadPoolSize=?) is used for executing suites in parallel. Every suite can be separately run in a separate thread.

206. What is Group Test in TestNG?

Answer : In TestNG, methods can be categorized into groups. When a particular group is being executed, all methods in that group are executed. A group can be executed by parameterizing its name in a group attribute of @Test annotation.

207. Give an example of Group Test in TestNG.

Answer : @Test(groups={“Car”})
public void drive()
system.out.println(“Driving the vehicle”);
public void changeGear()
system.out.println(“Change Gears”);
public void accelerate()

208. What are the advantages and disadvantages of Selenium over another testing tool known as RFT?

Answer : Selenium is open source, whereas IBM’s RFT is a licensed software. Selenium supports Windows OS, Linux OS, Solaris OS X (If browser & JVM or JavaScript support exists), whereas RFT works only on Windows OS. Selenium supports Java, C#, Ruby, Python, Perl, PHP and JavaScript, whereas RFT supports only Java and C#. Selenium consumes very less hardware resource, but RFT consumes a lot of hardware resource. For Selenium, coding skills should be very good along with technical capabilities of integrating the framework, whereas coding experience and skills are not that much needed for RFT.

209. Write a code to wait for an alert to appear.

Answer : The piece of code asking the WebDriver to wait until an error appears is something like this:

WebDriverWait wait=new WebDriverWait(driver, 20);

Element = wait.until(ExpectedConditions.alertIsPresent());

210. How to fetch an attribute from an element?

Answer : The attribute of an element can be fetched by using the getAttribute() method. Observe the given example:

WebElement eLogin = driver.findElement(“Login”);

String LoginClassName = eLogin.getAttribute(“classname”);

211. Which Selenium Tool is generally used?

Answer : Beginners generally start with Selenium IDE to learn Selenium location strategies and then move on to Selenium 2 as it is the most stable Selenium library and future of Selenium. Selenium Grid is used in the case when a particular test has to be distributed across multiple devices. Someone using Selenium 1.0 must transfer his/her test scripts to Selenium 2.0 and start using it.

212. What is Selenium 1.0?

Answer : Selenium 1.0, generally called Selenium Remote Control (Selenium RC) is the library available in almost every programming languages. The primary reason for the introduction of Selenium RC to the programming world was the incapability of the Selenium IDE to execute tests in the browser other than Selenium IDE. The programmatically limitations of language Selenese used in Selenium IDE also caused the advent of Selenium RC.

213. Can the speed and pause test execution be controlled in Selenium IDE?

Answer : Selenium IDE provides a slider with Slow and Fast pointers to enable control of speed of execution.

214. Where can the results of Test Execution be seen in Selenium IDE?

Answer : The result of test execution can be viewed in the log window in Selenium IDE.

215. Where can the description of commands used in Selenium IDE be seen?

Answer : The reference section is used to view the description of the commands.

216. Can a test suite be built using Selenium IDE?

Answer : Yes, a test suite can be built using Selenium IDE. It first records individual test cases and then groups all of them in a test suite. Following this, the entire test suite can be executed instead of executing individual tests.

217. What are the verification points are available with Selenium?

Answer : There are three types of verification points available with Selenium –

  • Checking for page title
  • Checking for certain text
  • Checking for certain elements like text box, drop down, table, etc.

218. What is the difference between Assertion and Verification?

Answer : A verification check lets the test execution continue even in the wake of failure with the check, while assertion stops the test execution in case of failure.

219. How to edit tests in Selenium IDE?

Answer : There are two ways to edit tests in Selenium IDE:

  • The table view
  • Looking into the source code of recorded commands

220. What is the syntax of the command used in Selenium?

Answer : There are three entities associated with a command –

  • Name of Command
  • Element Locator (also known as Target)

Value (required while using echo, wait etc)



With Automation testing taking the lead in QA space, Selenium has emerged as one of the most preferred technology for automation testing. As automation going to stay here for many more years, we forecast demand for Selenium will also be there. Above are top 220 Selenium interview questions for a Job interview.

Kiara is a career consultant focused on helping professionals get into job positions in the tech industry. She is also a skilled copywriter who has created well-crafted content for a wide range of online publications in the career and education industry.