Selenium

Selenium is an open-source & one of the most well-known automation testing tool for web applications. We have listed down the top interview questions on selenium automation testing to help you to prepare for an Automation testing role.



Q.1 What is the use of selenium?

Selenium is an open source software which automates web browser interaction and hence, testing of web applications.

Various users can access web or mobile applications on multiple web browsers like Chrome, Firefox, Safari, Internet Explorer, etc. and on different versions of each web browser.

It is very difficult task to check the functionality, load and performance of the web application on each of the web browser and their respective versions.


Selenium

  • Executes on popular web browsers and operating systems
  • can be accessed by different programming languages and testing frameworks.


Selenium can be used to

  • Test web applications
  • Test mobile applications, running on web browsers
  • Run regression tests
  • Execute functional tests
  • Has headless browser option
  • Can also be used for web scraping
  • Gives complete data capture and logging
  • Provides graphical snapshot as well
  • Compatible with all major programming languages


Supported programming language and testing frameworks, are

  • C# - NUnit
  • Haskell
  • Java - JUnit, TestNG
  • JavaScript - WebdriverJS, WebdriverIO, NightwatchJS, NemoJS
  • Objective-C
  • Perl
  • PHP - Behat + Mink
  • Python - unittest, pyunit, py.test, robot framework
  • R
  • Ruby - RSpec, Test::Unit

    Supported web browsers are
  • Firefox - Support for Firefox is the latest release, the previous release, the latest ESR release and the previous ESR release.
  • Internet Explorer - Versions 7, 8, 9, 10 and 11 are supported. Version 11 requires additional configuration.
  • Safari - SafariDriver requires Safari 5.1+
  • Opera - OperaChromiumDriver can be used without extra setup on Chromium-based versions of Opera starting from version 26.
  • Chrome - Version 70 onwards

    Operating Systems
  • Microsoft Windows - Most versions starting from Windows 7
  • Apple OS X - Recent version of OS
  • Linux - Ubuntu latest stable release

Q.2 What is meant by selenium?

Selenium refers to a set of software tools which automates software testing of web application.

Selenium supports various web browsers and their versions. Selenium can be used with different test frameworks and operating systems.

Selenium as a chemical is mainly used as catalyst, similarly Selenium software tools are used as catalyst for testing of web applications.

Q.3 Which programming language is best for selenium?

Java, is the programming language best for selenium.

Why Java, because Selenium has been developed in Java programming language.

You will be able to understand and access Selenium internals, which are in Java programming language.

Hence, Java programming language is the programming language best for selenium.

Q.4 What is selenium driver?

Selenium driver refer to the programming language bindings which link to Selenium WebDriver.

Selenium driver are library for each programming language being supported by Selenium. Selenium driver or the library exposes Selenium Webdriver’s API to the supported programming language.

Supported programming language and testing frameworks, are

  • C# - NUnit
  • Haskell
  • Java - JUnit, TestNG
  • JavaScript - WebdriverJS, WebdriverIO, NightwatchJS, NemoJS
  • Objective-C
  • Perl
  • PHP - Behat + Mink
  • Python - unittest, pyunit, py.test, robot framework
  • R
  • Ruby - RSpec, Test::Unit

For example, Selenium driver for C# will have Selenium Webdriver API in C# so as to control Selenium from  C# program or test case.

Q.5 What is selenium mainly used for?

Selenium is mainly used for testing web applications in different web browsers and versions.

Selenium refers to multiple tools used for cross-browser testing.

As per Selenium developers, Selenium automates browsers.

There are many web browsers which are popular like Chrome, Firefox, Internet Explorer, Safari, etc

Each web browser has also different versions.

Hence, testing on multiple browsers with multiple versions is a difficult task and automating it, reduces testing efforts and effectiveness.

Selenium is mainly used for automation testing of web and mobile application.

Q.6 What is TestNG in selenium?

TestNG in Selenium is used to generate reports on various tests being executed by Selenium. Selenium automates web browser application testing.

Both TestNG and Selenium are integrated to run automated tests for testing web or mobile application while combining various tests into test suites and generating comprehensive test results in various formats especially in HTML.

TestNG in Selenium is used to make it easier for Selenium test reports are generated by TestNG.

Q.7 What exactly is selenium?

Selenium is a test automation tool. Selenium automates testing of web application against multiple web browsers and different versions of web browsers.

Selenium is open source hence very popular in open source community and is the most popular web application testing tool.

Q.8 Which is better selenium with Java or C#?

Selenium with Java is better as Selenium has been developed in Java programming language.

Selenium with Java is better integrated and software testing professionals who are conversant with Java, are able to quickly grasp Selenium.

Multiple Java frameworks are supported by Selenium

Q.9 Is Selenium with Python good?

Yes, Selenium with Python provides the functionality of automating the testing of web application, to Python programming language.

Selenium is open source web application testing tool, which tests web application against multiple web browsers like Chrome, Firefox, Safari, etc and their multiple versions.

Web applications developed with Python programming language can be tested against multiple web browsers like Chrome, Firefox, Safari, etc and their multiple versions.

Q.10 What is default maximum number of browsers that can run in parallel on the node under Selenium Grid?
5 number of browsers
Q.11 What are the basics of selenium?

The basics of Selenium is, Selenium Web Driver is an intermediary which can take input of a test case in different programming languages like C#, PHP, Python, etc and executes them on web browsers, as per configuration.

Selenium can test web application against multiple web browsers like Chrome, Firefox, Safari, etc and their multiple versions.

 Selenium supports multiple programming languages by various “drivers” or library for each programming language to connect to Selenium API.

Q.12 What are the advantages of linear framework of software testing?

The advantages of linear framework of software testing are :

1. Automation expertise is not necessary, as we are just using ‘Record‘ and ‘Playback‘ feature.

2. Test scripts can be easily written and it will consume minimal time to write these scripts.

3. Understanding the flow is comparatively easy as the scripts are written in a linear manner.

Q.13 What kind of tests have you automated?

The main point of focus is to automate test cases to perform Regression testing, Smoke testing, and Sanity testing.

At times the tests are based on the project and the test time estimation, with focus on End to End testing.

Q.14 What is the correct syntax to instantiate a Edge browser session?
The correct syntax to instantiate a Edge browser session is WebDriver driver = new EdgeDriver();
Q.15 How many test cases have you automated in a day?

This purely depends on Test case scenario complexity and length. I have automated 4-5 test scenarios in a day such that the complexity is limited.

But at times only 2 or fewer test scenarios in a day such that the complexity is high.

Q.16 Web application caters to which domain?
Web application caters to B2C or e-commerce, B2B or trading websites and organizational internal needs.
Q.17 How do you define Framework?

We can define framework as a set of rules or best practices that can be followed in a systematic way to achieve desired results.

It offers different type of automation frameworks like Data Driven Testing Framework, Keyword Driven Testing Framework and Hybrid Testing Framework.

Q.18 Is Selenium a free tool?

Yes Selenium is open source tool for testing of web application against multiple web browsers like Chrome, Firefox, Safari, etc and their multiple versions.

You do not pay any license fees for using the tool. There is no license fee or metered usage of the tool.

Only expense for Selenium is the time and amount spent on learning and assessing yourself on the tool.

Q.19 Which object prototype in Selenium, is used for extending Selenium?
PageBot object prototype
Q.20 Have you created any Framework, in the past?

Given the interview question following scenarios are applicable -

1. In case you are a beginner: As a beginner you can clearly say “No, I didn’t get a opportunity to create framework from the scratch. But I have used the framework that are already available. I have contributed mostly in creating test cases by using the existing framework.
2. In this case you are a beginner but have good knowledge on creating framework: You can start by saying that “Yes, I have involved in developing framework along with other automation tester in my company.”
3. In case you are an experienced tester: As an experienced professional; you can say that “Yes, I have created framework from the scratch. As there were no automation process in my previous company."

Q.21 Is Java required for selenium?

No, Java is not required for Selenium

Java programming language is used for development of Selenium and knowledge of Java programming language is helpful in understanding Selenium internals.

Selenium provides facility to write program for test case in your choice of programming language like C#, PHP, Python, etc

Q.22 What are the reason to prefer Selenium Automation Tool?
Sample Answer - The reason to prefer Selenium Automation Tool are -
1. It is free and open source
2. It has a large user base and helping communities
3. It has Cross-browser compatibility
4. It has Platform compatibility
5. It has multiple programming languages support such as Java, Perl, Phyton, Php, C# etc.,
Q.23 What is the use of xpath in Selenium?

XPath in Selenium is used to locate elements on a webpage using the HTML DOM data structure.

XPath expands to XML Path. XPath is a Selenium selector for selecting specific elements on a web page. XPath uses XML path expression for finding element on a webpage.

XPath is the most used selector in Selenium.

Q.24 What do you understand by Selenium IDE?

Selenium IDE also refers as Selenium Integrated Development Environment is a Firefox plugin. Selenium IDE is the simplest framework in the Selenium Suite.

It permits to record and playback the scripts. Although we can create scripts using Selenium IDE, we still are required to use Selenium RC or Selenium WebDriver to write more advanced and robust test cases.

Q.25 Can we use Python in selenium?

Yes, Selenium supports Python programming language.

Selenium has a Python driver, using which test cases for testing web applications can be made in Python programming language.

Selenium supports following Python frameworks

  • Unittest
  • Pyunit
  • py.test
  • robot framework

Q.26 How do you define Selenium RC?
Selenium RC or Selenium Remote Control was one of the main Selenium project for a long time period prior to the WebDriver merge brought up Selenium.
Q.27 What is Selenium WebDriver?

Selenium WebDriver is a browser automation framework that accepts commands and sends them to a browser. Selenium WebDriver is implemented through a browser-specific driver.


Such that it controls the browser by directly communicating with it. Selenium WebDriver supports Java, C#, PHP, Python, Perl, Ruby.

Q.28 How do you define Selenium Grid?

Selenium Grid is referred as a tool used together with Selenium RC used to run tests on different machines against different browsers in parallel.

In other words, running multiple tests at the same time against different machines running different browsers and operating systems. It is primarily, used to distribute your test execution on multiple platforms and environments concurrently.

Q.29 When should we use Selenium Grid?
Selenium Grid is primarily used to execute same or different test scripts on multiple platforms and browsers concurrently in order to achieve distributed test execution
Q.30 What is Selenium Automation Testing?

Selenium Automation Testing involves using Selenium automation tool for of web application against multiple web browsers like Chrome, Firefox, Safari, etc and their multiple versions.

With spread of internet and e-commerce, web application development is in great demand and testing of application in different web browsers and their versions.

Selenium automates this arduous task and is open source.

Selenium also provides facility to write program for test case in your choice of programming language like C#, PHP, Python, etc

Q.31 According to which WebDriver implementation claims to be the fastest?
HTMLUnitDriver claims to be the fastest implementation of WebDriver is because the HTMLUnitDriver does not execute tests in the browser.
Q.32 What do you know about XPath?
XPath is mainly used to locate the elements. With the help of XPath, we can navigate through elements and attributes in an XML document and thereby locate web elements like textbox, button, checkbox, Image etc., in a web page.
Q.33 Can you differentiate between “/” and “//” in Selenium?

Single Slash “/” – Single slash is primarily used to create XPath with absolute path this means the XPath would be created to start selection from the document node/start node.


Double Slash “//” – On the other hand, Double slash is used to create XPath with relative path this means the XPath would be created to start selection from anywhere within the document.

Q.34 Which verification points should be considered \in Selenium?

Selenese Verify and Assert Commands are used as Verification points, in Selenium IDE. Note that in Selenium WebDriver, there is no built-in features for verification points.

It totally depends on the coding style sued. some there Verification points are -
1. Check for page title
2. Check for certain text
3. Check for certain element (text box, button, drop down, etc.)

Q.35 How will you launch a browser using Selenium WebDriver?

Selenium WebDriver is an Interface where we create an Object of a required driver class like FirefoxDriver, ChromeDriver, InternetExplorerDriver etc.,
Therefore,

1. In order to launch Firefox Driver:
WebDriver driver = new FirefoxDriver();


2. In order to Chrome Driver:
WebDriver driver = new ChromeDriver();

3. In order to Internet Explorer Driver:
WebDriver driver = new InternetExplorerDriver();

4. In order to Safari Driver:
WebDriver driver = new SafariDriver();

Remember in case you use the geckodriver with Selenium, you must upgrade to Selenium 3.3.

Q.36 How would you differentiate driver.get() and driver.navigate.to(“url”)?
Following are the points of difference -
driver.get() is used to open an URL and it will wait till the whole page gets loaded driver.navigate.to() is used to navigate to an URL and It will not wait till the whole page gets loaded
Q.37 In Selenium WebDriver, can you navigate back and forth in a browser?
We can use Navigate interface in order to do navigate back and forth in a browser. Following are some methods to move back, forward as well as to refresh a page.
1. driver.navigate().forward(); – It is used to navigate to the next web page with reference to the browser’s history
2. driver.navigate().back(); – It is used to take back to the previous webpage with reference to the browser’s history
3. driver.navigate().refresh(); – It is used to refresh the current web page thereby reloading all the web elements
4. driver.navigate().to(“url”); – It is used to launch a new web browser window and navigate to the specified URL
Q.38 How can we capture Screenshot in Selenium WebDriver?
While executing the test scripts, test cases may fail. While executing the test cases manually you can just take a screenshot and then place in a result repository. The same can be done by using Selenium WebDriver.

Some scenarios required to capture a screenshot using Selenium WebDriver are
1. Application issues
2. Assertion Failure
3. Difficulty to find Webelements on the web page
4. Timeout to find Webelements on the web page

Also selenium offers an interface referred as TakesScreenshot that has a method referred as 'getScreenShotAs' that can be used to take a screenshot of the application under test. Now in Selenium 3, there is a possibility of certain issues while capturing Screenshots. In order to overcome this situation we may use aShot utility.
Q.39 How will you handle windows based pop up?

Selenium does not support windows based applications. Since it is an automation testing such that both tool supports only web application testing.

We can also handle windows based popups in Selenium using some third party tools such as AutoIT, Robot class etc.

Q.40 How can you read test data from excel?
We can read test data efficiently by using JXL or POI API. POI API has many advantages than JXL.
Q.41 What is the benefit of automation testing?
Automation testing enables repetitive and parallel testing of test cases without huge resource engagement as automation helps in reducing the resource requirement. Automation testing supports performance and functional testing to be performed on application thus, providing better testing of the application with improved accuracy and efficiency due to little manual intervention. Thus, automation testing is able to perform efficient and effective testing as well as save time for testing with reduced finance requirements.
Q.42 Which test scenario is not apt for Selenium automation testing tool?
The Selenium is not suitable for test scenarios if the test application’s UI will change considerably or application has a very tight deadline for testing then, it is more suitable to go for manual testing
Q.43 Describe Selenium tool Suite and its components
Selenium tool suite has different software tools for specific role, as: Selenium 2 or Selenium Webdriver (it uses cohesive and objects oriented WebDriver API with support for Selenium 1's RC technology), Selenium 1 or Selenium RC or Remote Control ( it is deprecated and not actively supported, was used before Selenium 2), Selenium IDE or Integrated Development Environment (it is rapid prototyping tool for building test scripts and is a Firefox plugin with UI to quickly develop automated tests, has a recording feature to generate test scripts but no support for iteration or conditional statements) and Selenium-Grid (enables parallel tests to be performed, provides scalability by dividing test suite and execute different tests at the same time using different machines)
Q.44 What is Selenese?
Selenese is the language to write Selenium commands for testing the application are called as Selenese. Selenese are used in the Selenium IDE or RC.
Q.45 List various Selenium command types
3 types of Selenium commands are present and are: Accessors (Verify and store application state), Actions (change the state) and Assertions (compare expected and actual results)
Q.46 What is a locator in Selenium automation testing tool?
A locator is a mechanism to selecting an object on a web page
Q.47 List locator types supported by the Selenium automation testing tool
A locator is used for locating an object and locator types are: the element’s ID, the element’s name attribute, an XPath statement, by a links text and document object model (DOM).
Q.48 Differentiate amongst assert and verify Selenium commands
The assert and verify Selenium commands differ in the treatment when the check fails. With assert, the test will stop at that point and will not continue with rest checks but with verify command, the test will continue till completion.
Q.49 What are XPath Absolute and XPath Relative in Selenium testing tool?
An absolute xpath starts with root node or '/' but a relative xpath finds the closed id to the DOM element and generates xpath starting from that element.
Q.50 Differentiate amongst the Selenium commands: driver.close() and driver.quit()
The driver.quit() method will close all opened windows but the driver.close() method only closes the current window being controlled.
Q.51 Describe the navigation commands of Selenium automation testing tool
The navigation commands of Selenium automation testing tool includes: to (to load a new web page in the current browser window), forward(similar to clicking on the Forward Button of web browser), back ((similar to clicking on the Back Button of web browser) and refresh(to refresh the current web page)
Q.52 What is same-origin policy?
The same origin policy is a security feature of web browser to prevent execution of scripts or resource access by script in a web page from another domain. The term origin refers to grouping of port number, hostname and URL scheme.
Q.53 How Selenium manages same-origin policy?
The Selenium server acts as a client with HTTP proxy, which is between the AUT (Application under test) and the web browser so that both are seen from same domain.
Q.54 Differentiate amongst findElement() and findElements() of Selenium testing tool
The findElement() method of Selenium testing tool finds the first matching web element as per the provided search criteria but the findElements() method finds all web elements matching the search criteria.
Q.55 Which method provides all the cookies for the current domain?
The getCookies method of Selenium automation testing tool
Q.56 Which HTML5 element is used for drawing charts and data-driven diagrams?
The Canvas HTML5 element is used for drawing charts and data-driven diagrams
Get Govt. Certified Take Test