Blog Detail

  • selenium-interview-questions_903.png

    Selenium Interview Questions

    1. What is automation testing, and what are its advantages?

    Automation testing or Test Automation is a process of automating the manual testing process of an application or a system by using testing tools that allow you to create scripts that can be executed repeatedly, generating detailed test reports of the application or system under test.

    Advantages of automated testing are:

    It supports both the performance and functional testing of an application or system.
    It facilitates the execution of repeated test cases.
    It allows the parallel execution of the test cases.
    It improves the accuracy and efficiency of the system by reducing the manual intervention of humans to generate test cases.
    It helps in testing a large-scale test matrix.
    It saves valuable time and money for the testing team involved in the project.



    2. Why should Selenium be selected as a testing tool for web applications or systems?

    Selenium provides the following advantages, which make it an excellent automated testing framework:

    It is free and open-source software with a large user base and supports providing community.
    It has cross-browser compatibility and supports multiple browsers like Google Chrome, Mozilla Firefox, Internet Explorer, Edge, Opera, Safari, etc.
    It supports multiple operating systems such as Windows, Linux, macOS, etc.
    It facilitates the usage of multiple programming languages including Scala, Ruby, Python, PHP, Perl, Java, Groovy, C#, etc.
    It provides support for distributed testing as well.

    3. Name some of the commonly used Automation Testing tools that are used for Functional Automation.

    The lists of the top 10 used automation testing tools for Functional Automation are as follows.

    Teleric Test Studio, Developed by Teleric.
    TestingWhiz
    HPE Unified Functional Testing (HP - UFT formerly QTP)
    Tosca Testsuite
    Watir
    Quick Test Professional, provided by HP.
    Rational Robot, provided by IBM.
    Coded UI, provided by Microsoft.
    Selenium, open-source.
    Auto It, Open Source.

    4. What are the disadvantages of using Selenium as a testing tool?

    The following are the disadvantages of using Selenium as a testing tool:

    Tests web applications only: Selenium supports the testing of only web-based applications. Mobile applications, Captcha, and Barcode readers cannot be tested using Selenium unless integrated with third-party tools like Appium and TestNG.
    No built-in reporting and test management facility: Selenium can generate reports only using third-party tools like TestNG or JUnit.
    Unavailability of reliable tech support: Since Selenium is an open-source tool, no dedicated support for user issues is available.
    May require the knowledge of programming languages: Some prior programming knowledge is required to use Selenium.

    5. What is meant by Selenium Suite and what are its different components?

    Selenium is a package of several testing tools and is therefore often referred to as a Selenium Suite with each of these tools designed to cater to a different testing requirement.

    Following are the different components of Selenium Suite:

    Selenium Integrated Development Environment (IDE): It is a Firefox/Chrome plug-in that is developed to speed up the creation of automation scripts by recording the user actions on the web browser and exporting them as a reusable script.
    Selenium Remote Control (RC): It is a server that enables users to generate test scripts in their preferred programming language. It accepts commands from the test scripts and sends them to the browser as Selenium core JavaScript commands, for the browser to behave accordingly.
    Selenium WebDriver: It is a programming interface that helps create and run test cases by directly communicating with the web browser and using its native compatibility to automate. Unlike RC, it doesn’t require an additional server to create and run test cases.
    Selenium Grid: It allows parallel execution of tests on different browsers and operating systems by distributing commands to different machines simultaneously.

    6.Name some of the commonly used Automation Testing tools that are used for Functional Automation.

    The lists of the top 10 used automation testing tools for Functional Automation are as follows.

    Teleric Test Studio, Developed by Teleric.
    TestingWhiz
    HPE Unified Functional Testing (HP - UFT formerly QTP)
    Tosca Testsuite
    Watir
    Quick Test Professional, provided by HP.
    Rational Robot, provided by IBM.
    Coded UI, provided by Microsoft.
    Selenium, open-source.
    Auto It, Open Source.

    7.What is Selenium?

    Selenium is a portable framework for software testing. Selenium tool facilitates a playback tool for authoring functional tests without the need to learn a test scripting language.

    Selenium is one of the most widely used open-source Web UI (User Interface) automation testing suites. Jason Huggins developed Selenium in 2004 as an internal tool at Thought Works. Selenium supports automation across different browsers, platforms, and programming languages.

    8. What are the different components of Selenium?

    Selenium is not just a single tool but a suite of software's, each having a different approach to support automation testing. It comprises four major components which include:

    Selenium Integrated Development Environment (IDE)
    Selenium Remote Control (Now Deprecated)
    WebDriver
    Selenium Grid

    9. List out the names of programming languages, browsers, and operating systems that are supported by Selenium.

    Selenium supports various operating systems, browsers, and programming languages. Following is the list:

    Programming Languages: C#, Java, Python, PHP, Ruby, Perl, JavaScript.
    Operating Systems: Android, iOS, Windows, Linux, Mac, Solaris.
    Browsers: Google Chrome, Mozilla Firefox, Internet Explorer, Edge, Opera, Safari, etc.

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

    Selenium v1.0:

    Version 1.0 was the initial release of Selenium.
    It included three tools: Selenium IDE, Selenium RC, and Selenium Grid.
    Selenium v2.0:

    Selenium WebDriver was introduced replacing Selenium RC in version "2.0".
    With the onset of WebDriver, RC got deprecated and moved to the legacy package.
    Selenium v3:

    The latest release Selenium 3 has new added features and functionalities.
    It includes Selenium IDE, Selenium WebDriver, and Selenium Grid.

    11. List some of the test types that are supported by Selenium.

    Different types of testing are that we can achieve through Selenium are.

    Functional Testing
    Regression Testing
    Sanity Testing
    Smoke Testing
    Responsive Testing
    Cross Browser Testing
    UI testing (black box)
    Integration Testing

    12. What is Selenium IDE?

    Selenium IDE is implemented as a Firefox extension which provides record and playback functionality on test scripts. It allows testers to export recorded scripts in many languages like HTML, Java, Ruby, RSpec, Python, C#, JUnit, and TestNG.

    Selenium IDE has limited scope, and the generated test scripts are not very robust, and portable.

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

    The list of WebDriver API's which are used to automate browser include:

    AndroidDriver
    ChromeDriver
    EventFiringWebDriver
    FirefoxDriver
    HtmlUnitDriver
    InternetExplorerDriver
    iPhoneDriver
    iPhoneSimulatorDriver
    RemoteWebDriver

    14. List out some of the Automation tools which could be integrated with Selenium to achieve continuous testing.

    Selenium can be used to automate functional tests and can be integrated with automation test tools such as Maven, Jenkins, &Docker to achieve continuous testing. It can also be integrated with tools such as TestNG, &JUnit for managing test cases and generating reports.

    15. What do you mean by XPath?

    XPath is also defined as XML Path. It is a language used to query XML documents. It is an important approach to locate elements in Selenium. XPath consists of a path expression along with some conditions. Here, we can easily write XPath script/query to locate any element in the webpage. It is developed to allow the navigation of XML documents. The key factors that it considered while navigating are selecting individual elements, attributes, or some other part of an XML document for specific processing. It also produces reliable locators. Some other points about XPath are as follows.

    XPath is a language used for locating nodes in XML documents.
    XPath can be used as a substitute when you don't have a suitable id or name attribute for the element you want to locate.
    XPath provides locating strategies like:
    XPath Absolute
    XPath Attributes

    16. Explain XPath Absolute and XPath attributes.

    XPath Absolute:

    XPath Absolute enables users to mention the complete XPath location from the root HTML tag to the specific elements.
    Syntax: //html/body/tag1[index]/tag2[index]/.../tagN[index]
    Example: //html/body/div[2]/div/div[2]/div/div/div/fieldset/form/div[1]/input[1]
    XPath Attributes:

    XPath Attributes is always recommended when you don't have a suitable id or name attribute for the element you want to locate.
    Syntax: //htmltag[@attribute1='value1' and @attribute2='value2']
    Example: //input[@id='passwd' and @placeholder='password']

    17. What is the difference between "/" and "//" in XPath?

    Single Slash "/": Single slash is used to create XPath with absolute path.

    Double Slash "//": Double slash is used to create XPath with the relative path.

    18. What are the different types of annotations which are used in Selenium?

    JUnit annotations that can be used are:

    Test
    Before
    After
    Ignore
    BeforeClass
    AfterClass
    RunWith

    19. What are the WebDriver supported Mobile Testing Drivers?

    WebDriver supported "mobile testing drivers" are:

    AndroidDriver
    IphoneDriver
    OperaMobileDriver

    20. What are the popular programming languages supported by Selenium WebDriver to write Test Cases?

    Selenium WebDriver supports the below languages to write Test Cases.

    JAVA
    PHP
    Python
    C#
    Ruby
    Perl

    21. What is the difference between type keys and type commands?

    TypeKeys() will trigger JavaScript event in most of the cases whereas .type() won't.

    22. What is the difference between "type" and "typeAndWait" command?

    The "type" command is used to type keyboard key values into the text box of the software web application. It can also be used for selecting values of the combo box whereas the "type and wait" command is used when your typing is completed and the software web page starts reloading. This command will wait for the software application page to reload. If there is no page reload event on typing, you have to use a simple "type" command.

    23. What is the difference between findElement() and findElements()?

    findElement(): It is used to find the first element within the current page using the given "locating mechanism". It returns a single WebElement.

    findElements(): It uses the given "locating mechanism" to find all the elements within the current page. It returns a list of web elements.

    24. What is the wait? How many types of waits in selenium?

    Selenium Webdriver introduces the concept of waits for the AJAX-based application. There are two types of waits:

    Implicit Wait
    Explicit Wait

    25. What is meant by Selenese? Explain different types of Selenium commands

    The language used for writing test scripts in Selenium IDE is called Selenese. It is a set of commands used to test your web application or system. Selenium commands could be divided into 3 major categories:

    Actions: These are the commands interacting directly with web applications.
    Accessors: These are the commands which allow users to store values to a user-defined variable.
    Assertions: They enable a comparison of the current state of the application with its expected state.

    26. What is meant by a locator and name a few different types of locators present in Selenium.

    A locator is an address for uniquely identifying web elements within a web page. There are different type of locators present in Selenium to identify web elements uniquely and accurately like:

    ID
    ClassName
    Name
    TagName
    LinkText
    PartialLinkText
    Xpath
    CSS Selector
    DOM

    27. State the major difference between “assert” and “verify” commands in Selenium.

    Both “assert” and “verify” commands check whether the given condition is true or false and the only difference between them is that:

    Assert: assert condition stops the execution of the testing if the given condition is false else would continue with the further tests.
    Verify: verify the condition doesn’t stop the flow of execution irrespective of the condition being true or false.

    28. What is meant by an exception test in Selenium?

    An exception test is a test that expects an exception to be thrown inside a test class. It expects a @Test annotation followed by the expected exception name in the brackets.

    Eg: @Test(expectedException = NoSuchElementException.class) is an exception test for missing elements in Selenium.

    29. Can selenium be used to launch web browsers?

    Yes, Selenium provides good support to launch web browsers like Google Chrome, Mozilla Firefox, Internet Explorer, etc.

    The following commands can be used to launch web browsers using Selenium:

    WebDriver driver = new FirefoxDriver();
    WebDriver driver = new ChromeDriver();
    WebDriver driver = new InternetExplorerDriver();

    30. What is the main disadvantage of implicit wait?

    The main disadvantage of implicit wait is that it slows down test performance.

    Another disadvantage of implicit wait is:

    Suppose, you set the waiting limit to be 10 seconds, and the elements appear in the DOM in 11 seconds, your tests will be failed because you told it to wait a maximum of 10 seconds.

    31. What is Selenium Grid?

    Selenium Grid facilitates you to distribute your tests on multiple machines and all of them at the same time. So, you can execute tests on Internet Explorer on Windows and Safari on Mac machine using the same text script. It reduces the time of test execution and provides quick feedback.

    32. What are the limitations of Selenium testing?

    Unavailability of reliable tech support: Since Selenium is an open-source tool, it does not have dedicated tech support to resolve the user queries.
    Tests web applications only: Selenium needs to be integrated with third-party tools like Appium and TestNG to test desktop and mobile applications.
    Limited support for image testing.
    No built-in reporting and test management facility: Selenium has to be integrated with tools like TestNG, or JUnit among others to facilitate test reporting and management.
    May require the knowledge of programming languages: Selenium WebDriver expects the user to have some basic knowledge about programming.

    33. What are the testing types supported by Selenium?

    Selenium supports Regression testing and Functional testing.

    Regression testing - It is a full or partial selection of already executed test cases that are re-executed to ensure existing functionalities work fine.

    The steps involved are -

    Re-testing: All tests in the existing test suite are executed. It proves to be very expensive and time-consuming.
    Regression test selection: Tests are classified as feature tests, integration tests, and the end to end tests. In this step, some of the tests are selected.
    Prioritization of test cases: The selected test cases are prioritized based on business impact and critical functionalities.
    Functional testing - Functional Testing involves the verification of every function of the application with the required specification.

    The following are the steps involved:

    Identify test input
    Compute test outcome
    Execute test
    Compare the test outcome with the actual outcome

    34. What is an object repository?

    An object repository allows testers to accumulate web elements of the application under test (AUT), along with their locator values, in one or more centralized locations as restricted to hard-coding them within the test scripts.