Selenium Testing / FAQ

Selenium Interview Questions

Selenium is an open-source tool used as a free automation testing suite of tools. Licensing is not required and has more benefits than other testing+ tools.

The tests can be done in any operating system like Mac, Linux, and Windows. Selenium can be combined with some tools, such as TestNG in Selenium and JUnit, for managing test cases and generating reports.

Selenium is an automation tool and has some unique benefits that give it a competitive edge over others such as open source, multi-language support, platform support, multi-browser support, framework availability and flexibility, reusability, and integrated and parallel test execution.

a Firefox/Chrome plug-in was developed to speed up the creation of automation scripts. It records the user actions on the web browser and exports them as a reusable script.

Test automation or automation testing is the process of using specialized software to control the execution of tests and compare the results with expected outcomes. Automation testing can help reduce the time, cost, and effort required to test software applications by automating repetitive tasks and allowing testers to focus on more critical test cases.

There are many advantages of automation testing. Perhaps the most obvious is that it can save you time and effort. Automation testing can help to speed up the process of testing by automating repetitive tasks, such as running the same test cases multiple times or across different browsers.

Selenese is the set of Selenium commands that are used to test your web application. The tester can test the broken links, the existence of some objects on the UI, Ajax functionality, alerts, windows, list options, and a lot more using Selenese.

Action: Commands which interact directly with the application

Accessors: Allow the user to store certain values in a user-defined variable

Assertions: Verifies the current state of the application with an expected state

Unavailability of reliable tech support: Since Selenium is an open-source tool, it does not have dedicated tech support to resolve 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.

Selenium 2.0 is a tool that makes the development of automated tests for web applications easier. It represents the merger of the original Selenium project with the WebDriver project. Selenium RC was deprecated since the merge, however, was used for backward compatibility.

Selenium 3.0 is the extended version of Selenium 2.0. It is inherently backward compatible and does not involve Selenium RC. The new version came along with several bug fixes and increased stability.

Locator is a command that tells Selenium IDE which GUI elements ( say Text Box, Buttons, Check Boxes, etc) it needs to operate on. Locators specify the area of action.

Locator by ID: It takes a string parameter which is a value of the ID attribute that returns the object to the findElement() method.

Implicit wait - Implicit wait commands Selenium to wait for a certain amount of time before throwing a “No such element” exception.

driver.manage().timeouts().implicitlyWait(TimeOut, TimeUnit.SECONDS);

driver. navigate().to("https://www.ebay.in/"); - Navigates to the provided URL

driver.navigate().refresh(); - This method refreshes the current page

driver.navigate().forward(); - This method does the same operation as clicking on the Forward Button of any browser. It neither accepts nor returns anything.

driver. close()

This command closes the browser’s current window. If multiple windows are open, the current window of focus will be closed.

driver.quit()

When quit() is called on the driver instance and there are one or more browser windows open, it closes all the open browser windows.

Selenium is easy to use since it’s essentially developed in JavaScript.

Selenium can test web applications against browsers like Firefox, Opera, Chrome, and Safari, to name a few.

Selenium is an open-source, portable tool and freeware.

It supports many operating systems like Linux, Unix, Macintosh, and Windows.

Selenium supports Chrome, opera, safari, and Internet Explorer.

It supports many languages like Perl, Java, Python, Ruby, Groovy, JavaScript, VB Script, etc.

The exception test in Selenium is an exception that you expect will be thrown inside a test class. If you have written a test case in such a way that it should be thrown as an exception, then you can use the test annotation and specify the exception in the parameters.

Selenium is an open-source, portable tool and freeware.

It supports many operating systems like Linux, Unix, Macintosh, and Windows.

Selenium supports Chrome, opera, safari, and Internet Explorer.

It supports many languages like Perl, Java, Python, Ruby, Groovy, JavaScript, VB Script, etc.

One approach is to use the "implicit wait" command in Selenium, which instructs the web driver to wait a certain amount of time before throwing an error if the element is not found or loaded. Another option is to use the "explicit wait" command to wait for a specific element to appear on the page before proceeding with the script.

Selenium WebDriver is a popular tool for automating web browsers and has a program interface.

No, Selenium WebDriver is not a library.

Selenium WebDriver supports several popular web browsers, including Google Chrome, Mozilla Firefox, Microsoft Edge, Safari, and Opera.

It supports C#, PHP, Java, Perl, Python
It supports different OS like Windows, Linux, and Mac OS
It has powerful methods to locate elements (Xpath, DOM, CSS)
It has a high developer community supported by Google

Four parameters that you have to pass in Selenium are
Host
Port Number
Browser
URL

TestNG\.is a testing framework based on JUnit and NUnit to simplify a broad range of testing needs, from Unit Testing to Integration Testing. The functionality that makes it an efficient testing framework is Support for annotations
Support for data-driven testing
Flexible test configuration

Data-driven framework: In this framework, the test data is separated and kept outside the Test Scripts, while Test Case logic resides in Test Scripts. Test data is read from the external files ( Excel Files) and are loaded into the variables inside the Test Script. Variables are used for both for input values and for verification values.

Keyword-driven framework: The keyword-driven framework requires the development of data tables and keywords, independent of the test automation. In a keyword-driven test, the functionality of the application under test is documented in a table as well as step-by-step instructions for each test.

Yes. But not as effectively as a dedicated Performance Testing tool like Loadrunner.List the advantages of Webdriver over Selenium Server.

If you are using Selenium-WebDriver, you don’t need the Selenium Server as it uses different technology

Selenium Server provides Selenium RC functionality which is used for Selenium 1.0 backwards compatibility

Selenium Web driver makes direct calls to the browser using each browser's native support for automation, while Selenium RC requires a selenium server to inject Javascript into the browser

If you are using Selenium-WebDriver, you don’t need the Selenium Server as it uses different technology

Selenium Server provides Selenium RC functionality which is used for Selenium 1.0 backwards compatibility

Selenium Web driver makes direct calls to the browser using each browser's native support for automation, while Selenium RC requires a selenium server to inject Javascript into the browser

The 5 different exceptions you had in Selenium web drivers are
WebDriverException
NoAlertPresentException
NoSuchWindowException
NoSuchElementException
TimeoutException

You can use the “type” command to type in a file input box of the upload file. Then, you have to use the “Robot” class in JAVA to make file upload work.

getwindowhandles(): It is used to get the address of all the open browsers and its return type is Set <String>
get window handle(): It is used to get the address of the current browser where the control is and the return type is a string

List out different types of locators.

Different types of locators are

By.id()
By.name()
By.tagName()
By.className()
By.linkText()
By.partialLinkText()
By.xpath
By.cssSelector()

To identify and execute the functional requirement of an application from start to finish “use case” is used and the techniques used to do this are known as “Use Case Testing.”

SDLC deals with the development/coding of the software while STLC deals with the validation and verification of the software

The relationship between test cases and requirements is shown with the help of a document. This document is known as a traceability matrix.

White box testing technique involves the selection of test cases based on an analysis of the internal structure (Code coverage, branch coverage, path coverage, condition coverage, etc.) of a component or system. It is also known as Code-Based testing or Structural testing. Different types of white box testing are

Statement Coverage
Decision Coverage

In white box testing following steps are verified.
Verify the security holes in the code
Verify the incomplete or broken paths in the code
Verify the flow of structure according to the document specification
Verify the expected outputs
Verify all conditional loops in the code to check the complete functionality of the application
Verify the line-by-line coding and cover 100% testing

Static testing: During the Static testing method, the code is not executed, and it is performed using the software documentation.

Dynamic testing: To perform this testing the code is required to be in an executable form.

Verification is a process of evaluating software at the development phase. It helps you to decide whether the product of a given application satisfies the specified requirements. Validation is the process of evaluating software after the development process and checking whether it meets the customer's requirements.

Selenium is a suite of tools for automated web testing. It is composed ofSelenium IDE (Integrated Development Environment): It is a tool for recording and playing back. It is a Firefox plugin WebDriver and RC: It provides the APIs for a variety of languages like Java, .NET, PHP, etc. With most of the browsers Webdriver and RC works.

Grid: With the help of Grid you can distribute tests on multiple machines so that tests can be run parallel which helps cut down the time required for running in-browser test suites

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

In Selenium every object or control in a web page is referred to as an element, there are different ways to find an element on a web page they are

ID
Name
Tag
Attribute
CSS
Link text
PartialLink Text
Xpath etc

X-Path is used to find the WebElement in web pages. It is also useful in identifying the dynamic elements.

Refer to Complete Guide on XPath

It supports C#, PHP, Java, Perl, Python
It supports different OS like Windows, Linux, and Mac OS
It has powerful methods to locate elements (Xpath, DOM, CSS)
It has a high developer community supported by Google

Four parameters that you have to pass in Selenium are
Host
Port Number
Browser
URL

Data-driven framework: In this framework, the test data is separated and kept outside the Test Scripts, while Test Case logic resides in Test Scripts. Test data is read from the external files ( Excel Files) and are loaded into the variables inside the Test Script. Variables are used for both for input values and for verification values.

Keyword-driven framework: The keyword-driven frameworks require the development of data tables and keywords, independent of the test automation. In a keyword-driven test, the functionality of the application under test is documented in a table as well as step-by-step instructions for each test.

An object repository is an essential entity in any UI automation that allows a tester to store all objects that will be used in the scripts in one or more centralized locations rather than scattered all over the test scripts.

Selenium Grid sent the tests to the hub. These tests are redirected to Selenium Webdriver, which launches the browser and runs the test. With the entire test suite, it allows for running tests in parallel.

Yes. But not as effectively as a dedicated Performance Testing tool like Loadrunner.

If you are using Selenium-WebDriver, you don’t need the Selenium Server as it uses different technology

Selenium Server provides Selenium RC functionality which is used for Selenium 1.0 backwards compatibility

Selenium Web driver makes direct calls to the browser using each browser's native support for automation, while Selenium RC requires a selenium server to inject Javascript into the browser

The 5 different exceptions you had in Selenium web drivers are
WebDriverException
NoAlertPresentException
NoSuchWindowException
NoSuchElementException
TimeoutException

getwindowhandles(): It is used to get the address of all the open browsers and its return type is Set <String>

get window handle(): It is used to get the address of the current browser where the control is and the return type is a string

In Selenium IDE to insert a breakpoint
Select “Toggle breakpoint” by right click on the command in Selenium IDE
Press “B” on the keyboard and select the command in Selenium IDE
Multiple breakpoints can be set in Selenium IDE

The limitations of Selenium IDE
Exceptional handling is not present
Selenium IDE uses only HTML languages
External database reading is not possible with IDE
Reading from external files like .txt, and .xls is not possible
Conditional or branching statements execution like if, else, select statements is not possible

In selenium, there are mainly 4 locators that are used
X-path locators
CSS locators
Html id
Html name

When a locator has changed and Selenium IDE cannot locate the element

When the element Selenium IDE waiting to access did not appear on the web page and the operation timed out

When the element Selenium IDE was trying to access was not created

In two ways selenium IDE can be set
Press the “S” key on the keyboard and select the command in Selenium IDE
In Selenium IDE right click on the command and select “Set / Clear Start Point”

Selenium IDE has limitations in terms of browser support and language support. By using Selenium RC limitations can be diminished.
On different platforms and different web browsers for automating web applications, selenium RC is used with languages like Java, C#, Perl, Python
Selenium RC is Java-based and using any language it can interact with the web application
Using a server you can bypass the restriction and run your automation script running against any web application

Selenium IDE does not directly support many functions like condition statements, Iteration, logging and reporting of test results, unexpected error handling, and so on as IDE supports only HTML language. To handle such issues Selenium RC is used it supports languages like Perl, Ruby, Python, and PHP using these languages we can write the program to achieve the IDE issues.

The main difference between Selenium RC and Webdriver is that Selenium RC injects javascript function into browsers when the page is loaded. On the other hand, Selenium Webdriver drives the browser using browser built-in support

The advantages of RC are
Can read or write data from/ to .xls, .txt, etc
It can handle dynamic objects and Ajax-based UI elements
Loops and conditions can be used for better performance and flexibility
Support many Programming languages and Operating Systems
For any JAVA script-enabled browser Selenium RC can be used

To handle pop-ups in RC, using the select window method, a pop-up window will be selected and the window focus method will let the control from the current window to pop-up windows and perform actions according to the script

To identify an object using Selenium you can use
isElementPresent(String locator)
isElementPresent takes a locator as the argument and if found returns a Boolean

You can customize the TestNG report in two ways,
Using ITestListener Interface
Using IReporter Interface

Open chat
Hello
Can we help you?