Selenium Interview Questions

Selenium Interview Questions and Answers

Since there is so much dependency on the web today, ensuring the up-time and functioning of web apps is an evident need. Selenium is an automation testing tool developed precisely for that purpose, and this blog lists the commonly asked Selenium Interview Questions for those(freshers & experienced) getting into the testing domain.

Before I begin discussing the questions, I’d like to emphasize that Manual testing is time-consuming, tedious, boring, and prone to errors. This gives stand up to automation testing and in-turn, call for Selenium automation testers.

Benefits Of Automation Testing

benefits of automation testing - selenium interview questions

Putting the technical questions aside, you would possibly even be asked a few Selenium tricky interview questions, concerning why only Selenium, and not the other tool? That is because Selenium is open source and its easy adoption has earned itself the tag of being the poster child of web testing tools. With a huge 300 per cent growth in job postings over the past three years, testing has presented itself as an entry point into the IT world for professionals from various domains. Organizations are hunting for professionals with Selenium certification.

So, read the whole list of Java interview questions for Selenium covered during this blog and prepare yourself for an employment interview of a Selenium tester. Let’s get started!

  1. What is Selenium? Why is it used?

Selenium may be a cross-platform and portable automation testing framework created by Jason Huggins in 2004.

It has seen specific improvement since then, WebDriver 2.0 in 2011, and 3.0 in 2016. Check the below Selenium timeline.

Selenium Timeline

We can use Selenium to write down automation scripts for testing web applications. It helps in reducing manual testing efforts, improves productivity and quality.

Cross-platform means a Selenium script written on one OS say Windows can run on other supported systems like Linux or Mac OS without making any changes. Mobile means the same script created for a desktop-constructed device can go on different supported devices such as tablets, mobiles, etc.

  1. What is Selenium RC, and how does it talk to a browser?

Selenium RC a.k.a. Remote Control came out in early 2004.

It exposed a group of client APIs which use to send commands to a server to perform actions on the browser.

  1. What is Selenium 2.0, and why is it superior to RC?

Selenium 2.0 a.k.a. WebDriver may be a set of native APIs which directly send commands to the browser rather than delegating to a server.

Its release came out in 2011. It furnished the native WebDriver API interface and returned the old client-server API model.

  1. What is Selenium 3.0, and why is it superior to 2.0?

It was a major WebDriver upgrade which landed up in 2016.

It is superior to 2.0 because it implemented the W3C specifications for Webdriver APIs to make them a global standard.

Until 3.0, it had been the Selenium community that was supplying Web drivers for specific browsers. But now, they supply their respective drivers that support the quality Web driver API interface.

  1. What is the latest Selenium Webdriver architecture?

Below diagram explains the newest architecture Selenium Webdriver supports.

Selenium Webdriver Architecture

  1. What are the different components of the Selenium framework?

Selenium is an automation development kit that comprises the subsequent components.

  • Selenium IDE:

A Firefox extension to record and play the user actions performed on an internet page.

  • Selenium RC:

A Selenium remote which exposes APIs for scripting tests in several languages and also runs them in browsers.

  • Selenium Webdriver:

These are mother APIs that directly interconnect with the browser. They give more control and are faster than the RC APIs.

  • Selenium Grid:

It provides concurrency. With its help, we can split testing and run a set of cases on one machine and some on another.

  1. What are the benefits WebDriver has over Selenium RC?

Selenium RC had a posh architecture, whereas WebDriver removed those complications. The below points discuss why WebDriver is best than the RC.

  • Selenium RC is slow because it’s a further JavaScript layer referred to as the core. On the contrary, WebDriver is fast as it natively interacts with the browser by utilizing its built-in engine.
  • Selenium core can’t ignore the disabled elements, whereas WebDriver handles the page elements more realistically.
  • Selenium RC features a mature set of APIs but suffers from redundancies and sophisticated commands. On the other hand, WebDriver APIs have a cleaner interface and do not have any such problems.
  • Selenium RC doesn’t provide support for the HtmlUnit browser, whereas the WebDriver has a headless HtmlUnit driver.
  • Selenium RC includes a test result generator to supply HTML reports. Web Driver doesn’t have any built-in reporting ability.
  1. What are the benefits of Selenium automation?

There are numerous benefits of using Selenium for automated testing.

  • Open source: Since it’s an OSS, so we don’t need to bear any licensing cost for using it.
  • Cross-browser: It works on all standard browsers like Chrome, FF, IE, and Safari. We can run the same test script altogether browsers.
  • Multi-language: we will choose a well-known programing language from Java, Python, C#, Ruby to use with Selenium.
  • Cross-platform: It supplies test similarity across Windows, Linux, and Mac OSX. We can hasten the same test script on all platforms.
  • Concurrency: With Selenium Grid, we will execute thousands of tests in parallel.
  • CLI support: we will create a test suite with many tests and launch it with one command.
  • CI support: Jenkins is the best CI tool. It supplies a Selenium plugin to design tests for nightly execution.
  • Free help: we will get quick technical support from its large community.
  • Tester friendly: A non-programmer also can automate using Selenium. It is not too complicated to be used only by a programmer.
  • Ongoing project: Active development and bug fixes on the newest project.
  1. What are some downsides to Selenium automation?

Selenium may be a perfect clinical tool to impersonate user actions during a browser. However, it also has a few limitations given below.

  • Can’t perform mobile automation on its own
  • Lacks a good built-in reporting
  • Not 100% perfect for handling dynamic web elements
  • Poses challenges while processing popups or frames
  • Not that efficient in coping with the page load
  • Can’t automate a captcha
  1. What are the advantages and disadvantages of Selenium over other testing tools like QTP and TestComplete?

The differences are listed below.

Selenium vs HP QTP vs TestComplete

Features

Selenium

HP QTP

TestComplete

License

Open Source

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

Selenium v1 included only three suites of tools: Selenium IDE, Selenium RC and Selenium Grid. There was no WebDriver in Selenium v1. Selenium WebDriver was introduced in Selenium v2. With the onset of WebDriver, Selenium RC got deprecated and isn’t in use since. Older versions of RC are available in the market though, but support for RC is not available. Currently, Selenium v3 is in use, and it comprises IDE, WebDriver and Grid. Selenium 4 is actually the latest version. The release is not yet announced but was announced in a conference in October 2019.

IDE is hired for recording and playback of tests, WebDriver is hired for testing agile web applications via a programming link and Grid is employed for deploying tests in remote host machines.

  1. Explain the different exceptions in Selenium WebDriver.

Exceptions in Selenium are almost like exceptions in other programming languages. The most common exceptions in Selenium are:

  • TimeoutException: This exception is thrown when a command performing an operation doesn’t complete within the stipulated time
  • NoSuchElementException: This exception is thrown when a component with given attributes isn’t found on the online page
  • ElementNotVisibleException: This exception is thrown when the element is present in DOM (Document Object Model), but not visible on the online page
  • StaleElementException: This exception is thrown when the element is either deleted or not attached to the DOM
  1. What is an exceptional test in Selenium?

An exception test is an exception that you simply expect to be thrown inside a test class. If you have written a test case in such a way that it should throw an exception, then you can use the @Test annotation and specify which exception you will be expecting by mentioning it in the parameters. Take a glance at the instance below: @Test(expectedException = NoSuchElementException.class)

Do record the syntax, where the exception is suffixed with .class

  1. Why and how will you use an Excel Sheet in your project?

The reason we use Excel sheets is that it can be used as a data source for tests. An excel sheet also can be wont to store the info set while performing DataDriven Testing. These are the two main reasons for using Excel sheets.

When you use the excel sheet as data source, you’ll store the following:

  • Application URL for all environments: you’ll specify the URL of the environment during which you would like to try to do the testing like development environment or testing environment or QA habitat or putting on environment or production/ pre-production environment.
  • Username and password credentials of different environments: You can store the access credentials of the different applications/ environments in the excel sheet. You can store them in encoded format and whenever you would like to use them, you’ll decode them rather than leaving it plain and unprotected.
  • Test cases to be executed: you’ll list down the whole set of test cases during a column and within the next column, you’ll specify either Yes or No which indicates if you would like that specific test suit to be executed or ignored.
  • When you use the excel sheet for DataDriven Test, you’ll store the info for various iterations to be performed within the tests. For example while testing an internet page, the various sets of input file that must be passed to the test box are often stored within the excel sheet.
  1. How can you redirect browsing from a browser through some proxy?

Selenium supplies a PROXY class to switch browsing from a proxy. Look at the example below:

String PROXY = “199.201.125.147:8080”;

org.openqa.selenium.Proxy proxy = new.org.openqa.selenium.Proxy();

proxy.setHTTPProxy(Proxy)

.setFtpProxy(Proxy)

.setSslProxy(Proxy)

DesiredCapabilities cap = new DesiredCapabilities();

cap.setCapability(CapabilityType.PROXY, proxy);

WebDriver driver = new FirefoxDriver(cap);

  1. What is POM (Page Object Model)? What are its advantages?

Page Object Model may be a design pattern for creating an Object Repository for web UI elements. Each website within the application is required to possess its own corresponding page class. The page class is thus liable for finding the WebElements therein page then perform operations on those WebElements.

The advantages of using POM are:

  • Allows us to separate operations and flows within the UI from Verification – improves code readability
  •  
  • Since the thing Repository is independent of Test Cases, multiple tests can use an equivalent Object Repository
  •  
  • Reusability of code
  1. What is Page Factory?

Page Factory gives an optimized thanks to implementing the Page Object Model. When we say it is optimized, it refers to the fact that memory utilization is very good and also the implementation is done in an object-oriented manner.

Page Factory is employed to initialize the weather of the Page Object or instantiate the Page Objects itself. note for elements also can be generated (and recommended) because the describing properties might not always be descriptive enough to differentiate one object from the opposite.

The concept of splitting the Page Object depot and Test Methods is followed here also. Instead of having to use

@FindBy will accept tagName, partialLinkText, name, linkText, id, css, class & xpath as attributes.

  1. What are the different types of WAIT statements in Selenium WebDriver? Or the question or often framed like this: How does one achieve synchronization in WebDriver?

There are basically two sorts of wait statements: Implicit Wait and Explicit Wait.

Implicit wait instructs the WebDriver to attend for a few by polling the DOM. Once you have declared implicit wait, it’ll be available for the whole lifetime of the WebDriver instance. By default, the value will be 0. If you set a longer default, then the behaviour will poll the DOM on a periodic basis depending on the browser/ driver implementation.

Selenium Certification Training

Instructor-led Sessions

Assessments

AssignmentLifetime Access

Explicit wait instructs the execution to attend for a few time until some condition is achieved. Some of those conditions to be attained are:

elementToBeClickable

elementToBeSelected

presenceOfElementLocated

  1. Write a code to wait for a particular element to be visible on a page. Write a code to attend for being aware of appearing.

We can write code such that we specify the XPath of the online element that must be visible on the page and then ask the WebDriver to attend for a specified time. Look at the sample piece of code below:

1

2

WebDriverWait wait=new WebDriverWait(driver, 20);

Element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath( “<xpath”)));

Similarly, we can write another piece of code asking the WebDriver to wait until an error appears like this:

1

2

WebDriverWait wait=new WebDriverWait(driver, 20);

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

  1. What is the use of JavaScriptExecutor?

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

1

2

JavascriptExecutor js = (JavascriptExecutor) driver;

js.executeScript(Script,Arguments);

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

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

1

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

  1. How to scroll down to a particular element?

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

1

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

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

We can handle special keyboard and mouse events 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. Most commonly used keyboard and mouse events provided by the Actions class are in the table below:

Selenium functions and their explanation

 

Method

Description

clickAndHold()

Clicks (without releasing) the current mouse location.

dragAndDrop()

Performs click-and-hold at the location of the source element, moves.

source, target()

Moves to the location of the target element, then releases the mouse.

 

  1. What is Selenese? How is it classified?

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

Action: Commands which interact directly with the application

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

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

 

  1. Why should Selenium be selected as a test tool?

Selenium

  • is free and open-source
  • have a large user base and helping communities
  • have cross Browser compatibility (Firefox, Chrome, Internet Explorer, Safari etc.)
  • have great platform compatibility (Windows, Mac OS, Linux etc.)
  • supports multiple programming languages (Java, C#, Ruby, Python, Pearl etc.)
  • has fresh and regular repository developments
  • supports distributed testing
  1. What are the testing types that can be supported by Selenium?

Selenium supports the following types of testing:

Functional Testing

Regression Testing

  1. What are the limitations of Selenium?

Following are the limitations of Selenium:

  1. Selenium supports testing of only web-based applications
  2. Mobile applications cannot be tested using Selenium
  3. Captcha and Barcode readers cannot be tested using Selenium
  4. Reports can only be generated using third-party tools like TestNG or JUnit.
  5. As Selenium is a free tool, thus there is no ready vendor support through which the user can find numerous helping communities.
  6. The user is expected to possess prior programming language knowledge.
  1. What is the difference between Selenium IDE, Selenium RC, and WebDriver?

Feature

Selenium IDE

Selenium RC

WebDriver

Browser Compatibility

Selenium IDE comes as a Firefox plugin, therefore it underpins just Firefox

Selenium RC supports various versions of Google Chrome, Internet Explorer, Mozilla Firefox and Opera.

WebDriver supports a varied range of versions of Mozilla Firefox, Google Chrome, Internet Explorer and Opera.

Record and Playback

Selenium IDE supports record and playback feature

Selenium RC doesn’t support record and playback features.

WebDriver doesn’t support record and playback feature

Server Requirement

Selenium IDE does not require any server to be initiated before running the test scripts

Selenium RC requires the server to be started before executing the test scripts.

WebDriver does not require any type of server to be started before running the test scripts

Architecture

Selenium IDE is a Javascript based framework

Selenium RC is a JavaScript based Framework.

WebDriver uses the browser’s native compatibility to automation

Object Oriented

Selenium IDE is not an object oriented tool

Selenium RC is a semi object oriented tool.

WebDriver is a purely object oriented tool

Dynamic Finders

(for locating web elements on a webpage)

Selenium IDE doesn’t support dynamic finders

Selenium RC doesn’t support dynamic finders.

WebDriver supports dynamic finders

Handling Alerts, Navigations, Dropdowns

Selenium IDE does not explicitly provides aids to navigations, handle alerts, dropdowns

Selenium RC does not explicitly provide aids to navigations, handle alerts, dropdowns.

WebDriver provides a wide range of classes and utilities that guides in navigations, handling alerts, and dropdowns effectively and efficiently.

WAP (iPhone/Android) Testing

Selenium IDE doesn’t support testing of iPhone/Android applications

Selenium RC doesn’t support testing of iPhone/Android applications.

The tool comes with a huge number of drivers for WAP based testing.

For example, AndroidDriver, iPhoneDriver

Listener Support

Selenium IDE doesn’t support listeners

Selenium RC doesn’t support listeners.

WebDriver supports the implementation of Listeners

Speed

IDE and browser communicates directly

Selenium RC is slower than WebDriver.

WebDriver communicates directly with the web browsers. Thus making it much faster.

  1. When should I use Selenium IDE?

Selenium IDE is the simplest and easiest of all the tools within the Selenium Package. Its record and playback feature makes it exceptionally easy to learn with minimal acquaintances to any programming language. Selenium IDE is a perfect tool for a naïve user.

  1. What is Selenese?

Selenese is the language which is employed to write down test scripts in Selenium IDE.

  1. What are the different types of locators in Selenium?

The locator is often termed as an address that identifies an internet element uniquely within the webpage. Thus, to mark online elements correctly and absolutely we’ve differing types of locators in Selenium:

  • ID
  • ClassName
  • Name
  • TagName
  • LinkText
  • PartialLinkText
  • Xpath
  • CSS Selector
  • DOM
  1. What is the difference between assert and verify commands?

Assert: declare command checks whether the given condition is correct or wrong. Let’s say we assert whether the given element is present on the online page or not. If the condition is true then the program control will execute the subsequent test step but if the condition is fake, the execution would stop and no further test would be executed.

confirm: confirm command also checks whether the given condition is true or false. Irrespective of the condition being correct or wrong, the program execution doesn’t halt i.e. any failure during verification wouldn’t stop the execution and every one the test steps would be executed.

  1. What is an XPath?

XPath is employed to locate an internet element supporting its XML path. XML stands for Extensible terminology and is employed to store, organize and transport arbitrary data. It stores data during a key-value pair which is extremely much almost like HTML tags. Both being markup languages and since they fall into an equivalent umbrella, XPath are often wont to locate HTML elements.

The basic behind finding elements using XPath is that the traversing between various elements across the whole page and thus enabling a user to seek out a component with the reference of another element.

  1. What is the difference between “/” and “//” in Xpath?

Single Slash “/” – Single slash is employed to make Xpath with absolute path i.e. the xpath would be created to start out the selection from the document node/start node.

Double Slash “//” – Double slash is employed to make Xpath with relative path i.e. the xpath would be created to start out the selection from anywhere within the document.

  1. What is Same origin policy and how it can be handled?

The problem of same-origin policy disallows access to the DOM of a document from an origin that’s different from the origin we try to access the document.

So, so as to handle the same-origin policy, a Selenium remote was introduced.

  1. When should I use Selenium Grid?

Selenium Grid is often wont to perform the same or differently. trial scripts on different platforms and browsers simultaneously so on achieve give out test execution, testing under different environments and saving execution time remarkably.

  1. What do we mean by Selenium 1 and Selenium 2?

Selenium RC and WebDriver, during a combination, are popularly referred to as Selenium 2. Selenium RC alone is additionally mentioned as Selenium 1.

  1. Which is the latest Selenium tool?

WebDriver

  1. How do I launch the browser using WebDriver?

The following syntax are often wont to launch Browser:

WebDriver driver = new FirefoxDriver();

WebDriver driver = new ChromeDriver();

WebDriver driver = new InternetExplorerDriver();

  1. What are the different types of Drivers available in WebDriver?

The different drivers available in WebDriver are:

  • FirefoxDriver
  • InternetExplorerDriver
  • ChromeDriver
  • SafariDriver
  • OperaDriver
  • AndroidDriver
  • IPhoneDriver
  • HtmlUnitDriver
  1. What are the different types of waits available in WebDriver?

There are two sorts of waits available in WebDriver:

Implicit Wait

Explicit Wait

  • Implicit Wait: Implicit waits are wont to provide a default waiting time (say 30 seconds) between each consecutive test step/command across the whole test script. Thus, the next test step would only execute when the 30 seconds have elapsed after executing the previous test step/command.
  • Explicit Wait: Explicit waits are wont to halt the execution till the time a specific condition is met or the utmost time has elapsed. Unlike Implicit waits, explicit waits are applied for a specific instance only.
  1. How to type in a textbox using Selenium?

The user can use sendKeys(“String to be entered”) to enter the string in the textbox.

Syntax:

WebElement username = drv.findElement(By.id(“Email”));

// entering username

username.sendKeys(“sth”);

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

WebDriver facilitates the user with the subsequent methods to see the visibility of the online elements. These web elements are often buttons, drop boxes, checkboxes, radio buttons, labels etc.

isDisplayed()

isSelected()

isEnabled()

Syntax:

isDisplayed():

boolean buttonPresence = driver.findElement(By.id(“gbqfba”)).isDisplayed();

isSelected():

boolean butt driver.findElement(By.id(“gbqfba”)).isSelected();

isEnabled():

boolean searchIconEnabled = driver.findElement(By.id(“gbqfb”)).isEnabled();

  1. How can we get a text of a web element?

Get command is employed to retrieve the inner text of the required web element. The command doesn’t need any parameters but give back a string value. It is also one among the extensively used commands for verification of messages, labels, errors etc displayed on the online pages.

Syntax:

String Text = driver.findElement(By.id(“Text”)).getText();

  1. How to select value in a dropdown?

The values within the dropdown are often selected using WebDriver’s Select class.

Syntax:

selectByValue:

Select selectByValue = new Select(driver.findElement(By.id(“SelectID_One”)));

selectByValue.selectByValue(“greenvalue”);

selectByVisibleText:

Select selectByVisibleText = new Select (driver.findElement(By.id(“SelectID_Two”)));

selectByVisibleText.selectByVisibleText(“Lime”);

selectByIndex:

Select selectByIndex = new Select(driver.findElement(By.id(“SelectID_Three”)));

selectByIndex.selectByIndex(2);

  1. Can you explain the difference between assert and verify commands in Selenium?

: Both assert and verify commands are responsible for checking whether the given condition is true or false. However, the most distinction between the 2 lies what each of them does after the condition checking is complete.

If the condition comes out to be false in the case of a verify command, then the execution stops and no further tests will be executed. However, if the condition is true then the program control will continue executing the next test step.

Verify command, on the other hand, does not care about the result of the condition checking. Whether it’s true or false, the program execution continues and every one the test steps are going to be completed.

  1. Please explain how to find if an element is displayed on the screen.

The WebDriver component of the Selenium suite facilitates checking the visibility of web elements, which may be buttons, checkboxes, drop boxes, labels, radio buttons, et cetera. WebDriver allows doing so with the following three methods:

isDisplayed()

boolean buttonPresence = driver.findElement(By.id(“some id”)).isDisplayed();

isEnabled()

boolean searchIconEnabled = driver.findElement(By.id(“some id”)).isEnabled();

isSelected()

boolean butt driver.findElement(By.id(“some id”)).isSelected();

  1. What do you mean by Same Origin Policy? How to handle it?

An Origin is a sequential combination of host, scheme, and port of the URL. The issue of the same-origin policy restricts accessing the DOM of a document from an origin that is different from the one that a user is trying to access the document.

The Selenium Core isn’t allowed to access the weather from an origin that’s different from where it had been launched. Selenium remote was introduced so as to handle the matter of Same Origin Policy.

  1. Can you use Selenium for testing Rest API or Web services?

Selenium supplies Native APIs for interacting with the browser utilizing actions and events. The Rest API and therefore the web services don’t have any UI and hence can’t be automated using Selenium.

  1. What are the different types of Web Driver APIs supported in Selenium?

Following are the web drivers supported in Selenium.

  • | WebDriver Name | WebDriver API | Supported Browser |
  • Gecko Driver (a.k.a. Marinetto) | FirefoxDriver() | Firefox
  • Microsoft WebDriver (a.k.a. Edge) | InternetExplorerDriver() | IE
  • Google Chrome Driver | ChromeDriver() | Chrome
  • HTML Unit Driver | WebClient() | {Chrome, FF, IE}
  • OperaChromium Driver | ChromeDriver() | Opera
  • Safari Driver | SafariDriver() | Safari
  • Android Driver, AndroidDriver() | Android browser
  • ios Driver | IOSDriver() | ios browser
  • EventFiringWebDriver | EventFiringWebDriver() | ALL
  1. What makes Selenium better than QTP?

The following characteristics of Selenium make it better than QTP:

 

Selenium

QTP

It is an open-source

It is a commercial tool

It is used for testing various web-based applications.

It is used for web-based applications and testing client-server applications.

It supports Safari, Opera, and Firefox on Linux, Mac, and Windows.

It supports only the Internet Explorer on Windows.

It supports different programming languages such as Python, Perl, and Ruby.

It supports only VB Script.

  1. Define the parameters in Selenium?

There are four parameters in Selenium which includes:

  •  
  •  
  • Port Number.
  •  
  1. What is the role of set Speed() and Sleep() methods in Selenium?

The part of set Speed() and Sleep() in Selenium is to detain the speed of execution.

  1. Define heightened privileges browsers?

Heightened privileges browsers act as proxy injections that allow different websites to try things that are normally not permitted. These browsers allow Selenium core to open the AUT directly and thereby read and write its content without passing the entire AUT through the Selenium RC server.

55.what is a Borland Silk Test Tool?

A Borland Silk Test Tool is employed for the client-server application employing a test scripting language.

  1. What is a Selenium Test Tool?

A Selenium Test Tool is employed for web applications and has the pliability to several languages, including JAVA, Perl, Ruby, and various others.

  1. How is Webdriver beneficial over Selenium Server?

Webdriver doesn’t require the Selenium Server because it uses a totally different technology. It supplies Selenium RC performance, which supplies backward compatibility to Selenium 1.0. Also, it makes a direct call to the various browsers for making automation. At an equivalent time, within the case of Selenium RC, it requires the Selenium Server to input the Javascript into the browser.

57. What are the major differences between Borland Silk Test Tool and Selenium Test Tool?

Borland Silk Test Tool

Selenium Test Tool

It is not a free testing tool.

It is a free testing tool.

It has to be applied manually.

It is an automation tool.

It supports only Internet Explorer and Firefox.

It supports all kinds of browsers, including Internet Explorer, Firefox, Safari, Opera, and various others.

It is specifically used for testing script language.

Can also be applied for testing programs in various languages.

It can be applied to a client-server application.

It can be applied only to web applications.

  1. What are the different types of navigation commands?

Following are the navigation commands:

navigate().back() – The above command requires no parameters and takes back the user to the previous webpage within the web browser’s history.

Sample code:

driver.navigate().back();

navigate().forward() – This command lets the user to navigate to the subsequent website with regard to the browser’s history.

Sample code:

driver.navigate().forward();

navigate().refresh() – This command lets the user to refresh the present website there by reloading all the online elements.

Sample code:

driver.navigate().refresh();

navigate().to() – This command lets the user to launch a replacement browser window and navigate to the required URL.

Sample code:

driver.navigate().to(“https://google.com”);

  1. How to click on a hyperlink using linkText?

driver.findElement(By.linkText(“Google”)).click();

The command finds the element using link text and then click on that element and thus the user would be redirected to the corresponding page.

The above-mentioned link can also be accessed by using the following command.

driver.findElement(By.partialLinkText(“Goo”)).click();

The above command finds the element based on the substring of the link provided in the parenthesis and thus partialLinkText() finds the web element with the specified substring and then clicks on it.

61.How to capture a screenshot in WebDriver?

import org.junit.After;

import org.junit.Before;

import org.junit.Test;

import java.io.File;

import java.io.IOException;

import org.apache.commons.io.FileUtils;

import org.openqa.selenium.OutputType;

import org.openqa.selenium.TakesScreenshot;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

public class CaptureScreenshot {

WebDriver driver;

@Before

public void setUp() throws Exception {

driver = new FirefoxDriver();

driver.get(“https://google.com”);

}

@After

public void tearDown() throws Exception {

driver.quit();

}

@Test

public void test() throws IOException {

// Code to capture the screenshot

File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

// Code to copy the screenshot in the desired location

FileUtils.copyFile&#40;scrFile, new File(“C:\\CaptureScreenshot\\google.jpg”&#41;)

62 What is Junit?

Junit may be a unit testing framework introduced by Apache. Junit is based on Java.

  1. What are Junit annotations?

Following are the JUnit Annotations:

  • @Test: Annotation lets the system know that the method annotated as @Test is a test method. There are often multiple test methods during a single test script.
  • @Before: Method annotated as @Before lets the system know that this method shall be executed every time before each of the test methods.
  • @After: Method annotated as @After lets the system know that this method shall be executed every time after each of the test methods.
  • @BeforeClass: practice annotated as @BeforeClass lets the system know that this practice shall be performed once before any of the test methods.
  • @AfterClass: Method annotated as @AfterClass lets the system know that this practice shall be performed once after any of the test methods.
  • @Ignore: Method annotated as @Ignore lets the system know that this practice shall not be executed.
  1. What is TestNG and how is it better than Junit?

TestNG is a complicated framework designed thanks to leveraging the advantages of both the developers and testers. With the beginning of the frameworks, JUnit gets huge popularity across the Java applications, Java developers and Java testers with remarkably increasing the code quality. In spite of being easy to use, JUnit has its own curb which makes the necessity of bringing TestNG into the image. TestNG is an open-source framework which is distributed under the Apache Software License and is quickly available for download.

TestNG with WebDriver supplies a successful test result format which will, in turn, be shared with the stakeholders to possess a glimpse on the product’s/application’s health thereby eliminating the drawback of WebDriver’s incapability to get test reports. TestNG has an innate deviation handling mechanism which lets the program to run without terminating unexpectedly.

There are different advantages that make TestNG senior to JUnit. Some of them are:

Added advance and easy annotation

Execution patterns can set

Concurrent execution of test scripts

Test case dependencies can be same

  1. How to set test case priority in TestNG?

Setting Priority in TestNG

Code Snippet

package TestNG;

import org.testng.annotations.*;

public class SettingPriority {

@Test(priority=0)

public void method1() {

}

@Test(priority=1)

public void method2() {

}

@Test(priority=2)

public void method3() {

}

}

Test Execution Sequence:

Method1

Method2

Method3

  1. How can I read test data from excels?

Test data can successfully be read from excel using JXL or POI API. See detailed tutorial here.

  1. What is the difference between POI and jxl jar?

#

JXL jar

POI jar

1

JXL supports “.xls” format i.e. binary-based format. JXL do not support Excel 2007 and “.xlsx” format i.e. XML based format

POI jar supports all of these formats

2

JXL API was last updated within the year 2009

POI is regularly updated and released

3

The JXL documentation isn’t as comprehensive as that of POI

POI features a well prepared and highly comprehensive documentation

4

JXL API doesn’t support rich text formatting

POI API supports rich text formatting

5

JXL API is faster than POI API

POI API is slower than JXL API 

  1. What is the difference between MaxSessions vs. MaxInstances properties of Selenium Grid?

Sometimes we get demented while differentiating between the MaxSessions vs. MaxInstances. Let’s understand the difference with clarity.

  1. MaxInstances: It is the no. of browser instances (of the same versions) that can run on the remote machine. Check the below commands.

-browser browserName=firefox,version=59,maxInstances=3,platform=WINDOWS

-browser browserName=InternetExplorer,version=11,maxInstances=3,platform=WINDOWS

It means we can run three instances of both Firefox and IE at the same time. So, a total of six different browsers (FF & IE) could run in parallel.

  1. MaxSession: It dictates what percentage browsers (independent of the sort & version) can run concurrently on the remote machine. It supersedes the “MaxInstances” setting.

In the previous example: If the worth of “maxSession” is one, then no quite one browser would run. While its value is two, then any of these combinations (2FF, 2IE, 1FF+1IE) can run at a time.

69.Can WebDriver test Mobile applications?

WebDriver cannot test Mobile applications. WebDriver may be a web-based testing tool, therefore applications on the mobile browsers are often tested.

70.Can captcha be automated?

No, captcha and barcode readers cannot be automated.

  1. What is Object Repository? How can we make an Object Repository in Selenium?

Object Repository may be a term to ask the gathering of web elements belonging to Application Under Test (AUT) alongside their locator values. Thus, whenever the element is required within the script, the locator values are often populated from the thing Repository. Object Repository is employed to store locators during a centralized location rather than hardcoding them within the scripts.

In Selenium, objects can be stored in an excel sheet that can be populated inside the script whenever required.

That’s all for now.

So this brings us to the top of the Selenium interview questions blog. Alternatively, you’ll inspect this video on Selenium interview questions delivered by an industry expert where he also talks about the industry scenario and the way questions are going to be twisted and asked in an interview. In this, we just state the timeout value only. We will make the tool to attend until a particular amount of your time then proceeds further.

Hope during this article you’ll find answers to most often asked Selenium and WebDriver Interview questions. The answers provided here also are helpful for understanding the Selenium basics and advanced WebDriver topics.

Do you have any Selenium Interview questions that aren’t answered here? Please let us know in the comments below and we will try to answer all.

 

 

 

WhatsApp chat

Schedule a demo

We will schedule the demo with an expert trainer as per your time convenience.

Have a query?

we'd love to assist and help you on anything related to IT courses.