Must-Know Selenium Interview Questions & Answers [ STEP-IN ]
Selenium Interview Questions and Answers

Must-Know Selenium Interview Questions & Answers [ STEP-IN ]

Last updated on 03rd Jul 2020, Blog, Interview Questions

About author

Kernel (Sr Technical Project Manager )

Highly Expertise in Respective Industry Domain with 10+ Years of Experience Also, He is a Technical Blog Writer for Past 4 Years to Renders A Kind Of Informative Knowledge for JOB Seeker

(5.0) | 16547 Ratings 977

Selenium is an open source tool which is used for automating the tests carried out on web browsers (Web applications are tested using any web browser).

Wait, before you get carried away, let me reiterate that only testing of web applications is possible with Selenium. We can neither test any desktop (software) application nor test any mobile application using Selenium.

1. What is Selenium 3.0?

Ans: 

Selenium 3.0 is the latest version of Selenium. It has released 2 beta versions of selenium 3.0 with few of the below changes:

Here are few new features added to Selenium 3.0

Beta 1 updates Beta 2 updates (Only for Java)
Minimum Java version is now 8+ System property webdriver.gecko.driver now forces the server in marionet or legacy firefox driver mode, ignoring any related Desired Capability
It will support for Firefox Via Mozilla’s geckodriver Grid fixes NPE’s on registration when -browser not specified
Support for Edge is provided by MSIt now support Safari on MacOS via Apple’s own Safari driver Update GeckoDriver –port argument in all bindings

2. How will you find an element using Selenium?

Ans: 

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

  • ID
  • Name
  • Tag
  • Attribute
  • CSS
  • Linktext
  • PartialLink Text
  • Xpath etc

3. List out the test types that are supported by Selenium?

Ans: 

For web based application testing selenium can be used

The test types can be supported are

  • Functional, Learn More about Functional Testing.
  • Regression

For post release validation with continuous integration automation tool could be used

  • Jenkins
  • Hudson
  • Quick Build
  • CruiseCont

4. Explain what is assertion in Selenium and what are the types of assertion?

Ans: 

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”.

5. What is the use of X-path?

Ans: 

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

Refer Complete Guide on XPath

6. Explain the difference between single and double slash in X-path?

Ans: 

Single slash ‘/ ’

  • Single slash ( / ) start selection from the document node
  • It allows you to create ‘absolute’ path expressions

Double Slash ‘// ’

  • Double slash ( // ) start selection matching anywhere in the document
  • It enables to create ‘relative’ path expressions

7. List out the technical challenges with Selenium?

Ans: 

Technical challenges with Selenium are

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

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

Ans: 

TypeKeys() will trigger JavaScript event in most of the cases whereas .type() won’t. Type key populates the value attribute using JavaScript whereas .typekeys() emulates like actual user typing

9. What is the difference between verify and assert commands?

Ans: 

  • Assert:  Assert allows to check whether an element is on the page or not. The test will stop on the step failed, if the asserted element is not available. In other words, the test will terminated at the point where check fails.
  • Verify: Verify command will check whether the element is on the page, if it is not then the test will carry on executing.  In verification, all the commands are going to run guaranteed even if any of test fails.

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

Ans: 

In JAVA a special form of syntactic meta-data can be added to Java source code, this is know as Annotations.  Variables, parameters, packages, methods and classes are annotated some of the Junit annotations which can be useful are

  • Test
  • Before
  • After
  • Ignore
  • BeforeClass
  • AfterClass
  • RunWith

11. While using click command can you use screen coordinates? 

Ans: 

To click on specific part of element, you would need to use clickAT command.  ClickAt command accepts element locator and x, y co-ordinates as arguments- clickAt (locator, cordString)

12. What are the advantages of Selenium?

Ans: 

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

13.  Why testers should opt for Selenium and not QTP?

Ans: 

Selenium is more popular than QTP as

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

14. What are the four parameter you have to pass in Selenium?

Ans: 

Four parameters that you have to pass in Selenium are

  • Host
  • Port Number
  • Browser
  • URL

15.  What is the difference between setSpeed() and sleep() methods?

Ans: 

Both will delay the speed of execution.

Thread.sleep () :  It will stop the current (java) thread for the specified period of time.  Its done only once

  • It takes a single argument in integer format

Ex: thread.sleep(2000)- It will wait for 2 seconds

  • It waits only once at the command given at sleep

SetSpeed () :  For specific amount of time it will stop the execution for every selenium command.

  • It takes a single argument in integer format

Ex: selenium.setSpeed(“2000”)- It will wait for 2 seconds

  • Runs each command  after setSpeed delay by the number of milliseconds mentioned in set Speed

This command is useful for  demonstration purpose or if you are using a slow web application

16. What is same origin policy? How you can avoid same origin policy?

Ans: 

  • The “Same Origin Policy” is introduced for security reason, and it ensures that content of your site will never be accessible by a script from another site.  As per the policy, any code loaded within the browser can only operate within that website’s domain.
  • To avoid “Same Origin Policy” proxy injection method is used, in proxy injection mode the Selenium Server acts as a client configured HTTP proxy , which sits between the browser and application under test and then masks the AUT under a fictional URL

17. What is heightened privileges browsers?

Ans: 

The purpose of heightened privileges is similar to Proxy Injection, allows websites to do something that are not commonly permitted.  The key difference is that the browsers are launced in a special mode called heightened privileges.  By using these browser mode, Selenium core can open the AUT directly and also read/write its content without passing the whole AUT through the Selenium RC server.

18. How you can use “submit” a form using Selenium ?

Ans: 

You can use “submit” method on element to submit form-

  • element.submit () ;

Alternatively you can use click method on the element which does form submission

19. What are the features of TestNG and list some of the functionality in TestNG which makes it more effective?

Ans: 

Testing is a testing framework based on JUnit and NUnit to simplify a broad range of testing needs, from Unit Testing to Integration Testing. And the functionality which makes it efficient testing framework are

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

20. Mention what is the difference between Implicit wait and Explicit wait?

Ans: 

Implicit Wait: Sets a timeout for all successive Web Element searches. For the specified amount of time it will try looking for element again and again before throwing a NoSuchElementException.  It waits for elements to show up.

Explicit Wait :  It is a one-timer, used for a particular search.

Subscribe For Free Demo

21. Which attribute you should consider throughout the script in frame for “if no frame Id as well as no frame name”?

Ans: 

You can use…..driver.findElements(By.xpath(“//iframe”))….

This will return list of frames.

You will need to  switch to each and every frame and search for locator which we want.

Then break the loop

22. Explain what is the difference between find elements () and find element () ? find element ():

Ans: 

It finds the first element within the current page using the given “locating mechanism”.  It returns a single WebElement

findElements () :

Using the given “locating mechanism” find all the elements within the current page.  It returns a list of web elements.

23. Explain what are the JUnits annotation linked with Selenium?

Ans: 

The JUnits annotation linked with Selenium are

  • Before public void method() – It will perform the method () before each test, this method can prepare the test
  • Test public void method() – Annotations Test identifies that this method is a test method environment
  • After public void method()- To execute a method before this annotation is used, test method must start with test Before

24. Explain what is Datadriven framework and Keyword driven?

Ans: 

Datadriven 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.

Keyworddriven framework: The keyword driven frameworks 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.

25. What are the Selenium suite components?

Ans: 

Selenium IDE

It is a Firefox/Chrome plug-in that 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.

Selenium Remote Control (RC)

RC is a server that allows users to write application tests in various programming languages. The commands from the test script are accepted by this server and are sent to the browser as Selenium core JavaScript commands. The browser then behaves accordingly.

Selenium WebDriver

WebDriver is a programming interface that helps create and run test cases. It makes provision to act on web elements. Unlike RC, WebDriver does not require an additional server and interacts natively with the browser applications.

Selenium Grid

Grid was designed to distribute commands to different machines simultaneously. It allows the parallel execution of tests on different browsers and different operating systems. It is exceptionally flexible and is integrated with other suite components for simultaneous execution.

26. What are the limitations of Selenium testing? 

Ans: 

  • 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. 

27. What are the testing types supported by Selenium? 

Ans: 

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.

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 

28. What is the difference between Selenium 2.0 and Selenium 3.0? 

Ans: 

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 got 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. 

29. What is the same-origin policy and how is it handled?

Ans: 

Same Origin policy is a feature adopted for security purposes. According to this policy, a web browser allows scripts from one webpage to access the contents of another webpage provided both the pages have the same origin. The origin refers to a combination of the URL scheme, hostname, and port number.

Same Origin Policy prevents a malicious script on one page to access sensitive data on another webpage. 

Consider a JavaScript program used by google.com. This test application can access all Google domain pages like google.com/login, google.com/mail, etc. However, it cannot access pages from other domains like yahoo.com 

Selenium RC was introduced to address this. The server acts as a client configured HTTP proxy and “tricks” the browser into believing that Selenium Core and the web application being tested come from the same origin.

30. What is Selenese? How is it classified?

Ans: 

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.

selenium-commands

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

Course Curriculum

Get On-Demand Selenium Training & Become An Expert Selenium Tester

  • Instructor-led Sessions
  • Real-life Case Studies
  • Assignments
Explore Curriculum

31. Mention the types of Web locators.

Ans: 

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 whichand returns the object to findElement() method.

  •  driver.findElement(By.id(“user”));

Locator by the link: If your targeted element is a link text then you can use the by.linkText locator to locate that element.

  •   driver.findElement(By.linkText(“Today’s deals”)).click();

Locator by Partial link: The target link can be located using a portion of text in a link text element.

  •   driver.findElement(By.linkText(“Service”)).click();

Locator by Name: The first element with the name attribute value matching the location will be returned.

  •   driver.findElement(By.name(“books”).click());

Locator by TagName: Locates all the elements with the matching tag name

      driver.findElement(By.tagName(“button”).click());

Locator by classname: This finds elements based on the value of the CLASS attribute. If an element has many classes then this will match against each of them. 

  • driver.findElement(By.className(“inputtext”));

Locator by XPath: It takes a parameter of String which is a XPATHEXPRESSION and it returns an object to findElement() method.

  •   driver.findElement(By.xpath(“//span[contains(text(),’an account’)]”)).getText();

Locator by CSS Selector: Locates elements based on the driver’s underlying CSS selector engine.

  •   driver.findElement(By.cssSelector(“input#email”)).sendKeys(“myemail@email.com”);

32. What are the types of waits supported by WebDriver?

Ans: 

types-of-wait

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);

Explicit wait – Explicit wait is used to tell the Web Driver to wait for certain conditions before throwing an “ElementNotVisibleException” exception.

  • WebDriverWait wait = new WebDriverWait(WebDriver Reference, TimeOut);

Fluent wait – It is used to tell the web driver to wait for a condition, as well as the frequency with which we want to check the condition before throwing an “ElementNotVisibleException” exception.

  • Waitwait = new FluentWait(WebDriver reference).withTimeout(timeout, SECONDS).pollingEvery(timeout, SECONDS).ignoring(Exception.class);

33. Mention the types of navigation commands 

Ans: 

  • 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.navigate().back(); – This method does the same operation as clicking on the Back Button of any browser. It neither accepts nor returns anything.

34. What is the major difference between driver.close() and driver.quit()?

Ans: 

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.

35. What are the advantages and disadvantages of Selenium over other testing tools like QTP and TestComplete?

Ans: 

The differences are listed below.

Selenium vs HP QTP vs TestComplete

Features Selenium HP QTP TestComplete
License Open Source Required Required
Cost Free High High
Customer support Open source community Yes Yes
Release Cycles/Sprint Smaller release cycles with feedback Smaller release cycles Agility only
Coding skills Very High Low High
Environment support Windows, Linux, Mac Only Windows Windows only ( 7, Vista,     Server 2008 or later OS)
Language support Language support VB Script VB Script,JS Script, Delphi Script, C++ & C#

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

Ans: 

Selenium v1 included only three suite of tools: Selenium IDE, Selenium RC and Selenium Grid. Note that there was no WebDriver in Selenium v1. Selenium WebDriver was introduced in Selenium v2. With the onset of WebDriver, Selenium RC got deprecated and is not in use since. Older versions of RC is available in the market though, but support for RC is not available. Currently, Selenium v3 is in use, and it comprises of 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 used for recording and playback of tests, WebDriver is used for testing dynamic web applications via a programming interface and Grid is used for deploying tests in remote host machines.

37. What is exception test in Selenium?

Ans: 

An exception test is an exception that you expect will be thrown inside a test class. If you have written a test case in such 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 look at the example below: @Test(expectedException = NoSuchElementException.class)

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

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

Ans: 

The reason we use Excel sheets is because it can be used as data source for tests. An excel sheet can also be used to store the data 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 can store the following:

  • Application URL for all environments: You can specify the URL of the environment in which you want to do the testing like: development environment or testing environment or QA environment or staging environment or production/ pre-production environment.
  • User name 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 want to use them, you can decode them instead of leaving it plain and unprotected.
  • Test cases to be executed: You can list down the entire set of test cases in a column and in the next column, you can specify either Yes or No which indicates if you want that particular test case to be executed or ignored.

When you use the excel sheet for DataDriven Test, you can store the data for different iterations to be performed in the tests. For example while testing a web page, the different sets of input data that needs to be passed to the test box can be stored in the excel sheet.

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

Ans: 

Selenium provides a PROXY class to redirect 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); 

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

Ans: 

Page Object Model is a design pattern for creating an Object Repository for web UI elements. Each web page in the application is required to have it’s own corresponding page class. The page class is thus responsible for finding the WebElements in that page and then perform operations on those WebElements.

The advantages of using POM are:

  • Allows us to separate operations and flows in the UI from Verification – improves code readability
  • Since the Object Repository is independent of Test Cases, multiple tests can use the same Object Repository
  • Reusability of code

41. What is Page Factory?

Ans: 

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

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

The concept of separating the Page Object Repository and Test Methods is followed here also. Instead of having to use ‘FindElements’, we use annotations like: FindBy to find WebElement, and initElements method to initialize web elements from the Page Factory class.

FindBy can accept tagName, partialLinkText, name, linkText, id, css, className & xpath as attributes.

42. What are the different types of WAIT statements in Selenium WebDriver? Or the question can be framed like this: How do you achieve synchronization in WebDriver?

Ans: 

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

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

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

  • elementToBeClickable
  • elementToBeSelected
  • presenceOfElementLocated

43. Write a code to wait for a particular element to be visible on a page. Write a code to wait for an alert to appear.

Ans: 

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

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:

WebDriverWait wait=new WebDriverWait(driver, 20);Element = wait.until(ExpectedConditions.alertIsPresent());

44. What is the use of JavaScriptExecutor?

Ans: 

JavaScriptExecutor is an interface which 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:

JavascriptExecutor js = (JavascriptExecutor) driver;js.executeScript(Script,Arguments);

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

Ans: 

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

Example:

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

46. How to scroll down to a particular element?

Ans: 

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

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

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

Ans: 

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

MethodDescription
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.

48. What are different types of frameworks?

Ans: 

The different types of frameworks are:

  • Data Driven Framework:-
    When the entire test data is generated from some external files like Excel, CSV, XML or some database table, then it is called Data Driven framework.
  • Keyword Driven Framework:-
    When only the instructions and operations are written in a different file like an Excel worksheet, it is called Keyword Driven framework.
  • Hybrid Framework:-
    A combination of both the Data Driven framework and the Keyword Driven framework is called Hybrid framework.

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

Ans: 

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

50. How can you fetch an attribute from an element? How to retrieve typed text from a textbox?

Ans: 

We can fetch the attribute of an element by using the getAttribute() method. Sample code:

  • WebElement eLogin = driver.findElement(By.name(“Login”);String LoginClassName = eLogin.getAttribute(“classname”);

Here, I am finding the web page’s login button named ‘Login’. Once that element is found, getAttribute() can be used to retrieve any attribute value of that element and it can be stored it in string format. In my example, I have retrieved ‘classname’ attribute and stored it in LoginClassName.

Similarly, to retrieve some text from any textbox, we can use getText() method. In the below piece of code I have retrieved the text typed in the ‘Login’ element.

  • WebElement eLogin = driver.findElement(By.name(“Login”);String LoginText = Login.getText ();

In the below Selenium WebDriver tutorial, there is a detailed demonstration of locating elements on the web page using different element locator techniques and the basic methods/ functions that can be applied on those elements.

Course Curriculum

Best JOB Oriented Selenium Certification Training from Real-Time Experts

Weekday / Weekend BatchesSee Batch Details

51. Describe Selenese?

Ans: 

Selenese is the set of selenium commands which are used to test your web application.

You can even make use of:

  • Actions: Used for performing operations
  • Assertions: Used as checkpoints
  • Accessors: Used for storing a value in a particular variable

52. Can Selenium handle window pop-ups?

Ans: 

Selenium does not support handling pop-ups. Alert is used to display a warning message. It is a pop-up window that comes up on the screen.

A few methods using which this can be achieved:

  • Void dismiss(): This method is called when the ‘Cancel’ button is clicked in the alert box.
  • Void accept(): This method is called when you click on the ‘OK’ button of the alert.
  • String getText(): This method is called to capture the alert message.
  • Void sendKeys(String stringToSed): This is called when you want to send some data to alert

53. What is Automation Testing?

Ans: 

Automation testing or Test Automation is a process of automating the manual process to test the application/system under test. Automation testing involves the use of a separate testing tool which lets you create test scripts which can be executed repeatedly and doesn’t require any manual intervention.

54. What are the benefits of Automation Testing?

Ans: 

Benefits of Automation testing are:

  • Supports execution of repeated test cases
  • Aids in testing a large test matrix
  • Enables parallel execution
  • Encourages unattended execution
  • Improves accuracy thereby reducing human-generated errors
  • Saves time and money

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

Ans: 

Selenium

  • is a 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

56. What are the different Selenium components?

Ans: 

Selenium is one of the most popular automated testing suites. Selenium is designed in a way to support and encourage automation testing of functional aspects of web-based applications and a wide range of browsers and platforms. Due to its existence in the open source community, it has become one of the most accepted tools amongst the testing professionals.

Selenium is not just a single tool or a utility, rather a package of several testing tools and for the same reason, it is referred to as a Suite. Each of these tools is designed to cater different testing and test environment requirements.

The suite package constitutes the following sets of tools:

  • Selenium Integrated Development Environment (IDE) – Selenium IDE is a record and playback tool. It is distributed as a Firefox Plugin.
  • Selenium Remote Control (RC) – Selenium RC is a server that allows a user to create test scripts in the desired programming language. It also allows executing test scripts within the large spectrum of browsers.
  • Selenium WebDriver – WebDriver is a different tool altogether that has various advantages over Selenium RC. WebDriver directly communicates with the web browser and uses its native compatibility to automate.
  • Selenium Grid – Selenium Grid is used to distribute your test execution on multiple platforms and environments concurrently.

57. What are the 2 major testing types that can be supported by Selenium?

Ans: 

Selenium supports the following types of testing:

  • Functional Testing
  • Regression Testing

58. What are the limitations of Selenium?

Ans: 

Following are the limitations of Selenium:

  • Selenium supports testing of only web-based applications
  • Mobile applications cannot be tested using Selenium
  • Captcha and Barcode readers cannot be tested using Selenium
  • Reports can only be generated using third-party tools like TestNG or JUnit.
  • As Selenium is a free tool, thus there is no ready vendor support through the user can find numerous helping communities.
  • The user is expected to possess prior programming language knowledge.

59. What is the difference between Selenium IDE, Selenium RC, and WebDriver?

Ans: 

Feature Selenium IDE Selenium RC WebDriver
Browser Compatibility Selenium IDE comes as a Firefox plugin, thus it supports only       Firefox Selenium RC supports varied range of versions of Mozilla Firefox, Google     Chrome, Internet Explorer, Opera. WebDriver support varied range of versions of Mozilla Firefox, Google Chrome, Internet Explorer,Opera.   Also support HtmlUnitDriver which is a GUIless/headless browser.
Record and Playback Selenium IDE supports record   and playback feature Selenium RC doesn’t supports record and playback feature. WebDriver doesn’t support record and playback feature
Server Requirement Selenium IDE doesn’t require     any server to be started before   executing the test scripts Selenium RC requires server to start   before executing the test scripts. WebDriver doesn’t require any       server to start before executing 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 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 doesn’t explicitly provides aids to handle alerts,   navigations, dropdowns Selenium RC doesn’t explicitly provide aids to handle alerts, navigations,       dropdowns. WebDriver offers a wide range of   utilities and classes that helps in    handling alerts, navigations, and   dropdowns efficiently and               effectively.
WAP(iPhone/Android)Testing Selenium IDE doesn’t support     testing of iPhone/Andriod           applications Selenium RC doesn’t support testing of iPhone/Android applications. WebDriver is designed in a way to efficiently support testing of           iPhone/Android applications. The   tool comes with a large range of     drivers for WAP based testing. For example, AndroidDriver, iPhone-     Driver
Listener Support Selenium IDE doesn’t support     listeners Selenium RC doesn’t support istener. WebDriver supports the                   implementation of Listeners
Speed Selenium IDE is fast as it is         plugged in with a web-browser that launches the test. Thus, the IDE and browser communicates directly SeleniumRC is slower than WebDriver as it doesn’t communicates directly     with the browser; rather than it sends selenese commands over to Selenium Core which in turn communicates       with the browser. WebDriver communicates directly with the web browser.Thus making it much faster.

60. When should I use Selenium IDE?

Ans: 

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

61. What are the types of web locators

Ans: 

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. Their types are as follows:

  • Locator by ID
  • Locator by the link
  • Locator by Partial link
  • Locator by Name
  • Locator by TagName
  • Locator by classname
  • Locator by XPath
  • Locator by CSS Selector

62. What programming languages does Selenium allow to use?

Ans: 

Selenium Webdriver supports the following programming languages.

  • Python
  • Java
  • C-Sharp
  • JavaScript
  • Ruby
  • PHP
  • Perl

63. What are the OS/platforms does Selenium support?

Ans: 

Following is the list of OS/platforms which Selenium supports.

  • Windows Desktop
  • Windows Mobile
  • Linux
  • Mac OS X
  • IOS
  • Android

64. What types of cases can you automate with Selenium?

Ans: 

We can use Selenium for automating the following types of cases.

  • Functional cases
  • Regression test cases
  • Acceptance tests
  • Sanity test cases
  • Smoke testing
  • End-to-end test cases
  • Cross-browser tests
  • Integration tests
  • Responsiveness cases

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

Ans: 

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

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

Ans: 

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

67.  When should I use Selenium Grid?

Ans: 

Selenium Grid can be used to execute same or different test scripts on multiple platforms and browsers concurrently so as to achieve distributed test execution, testing under different environments and saving execution time remarkably.

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

Ans: 

Selenium RC and WebDriver, in a combination, are popularly known as Selenium 2. Selenium RC alone is also referred to as Selenium 1.

69. Which is the latest Selenium tool?

Ans: 

WebDriver

70. How do I launch the browser using WebDriver?

Ans: 

The following syntax can be used to launch Browser:

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

Selenium Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download

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

Ans: 

The different drivers available in WebDriver are:

  • FirefoxDriver
  • InternetExplorerDriver
  • ChromeDriver
  • SafariDriver
  • OperaDriver
  • AndroidDriver
  • IPhoneDriver
  • HtmlUnitDriver

72. What are the different types of waits available in WebDriver?

Ans: 

There are two types of waits available in WebDriver:

  • Implicit Wait
  • Explicit Wait

Implicit Wait: Implicit waits are used to provide a default waiting time (say 30 seconds) between each consecutive test step/command across the entire test script. Thus, the subsequent test step would only execute when the 30 seconds have elapsed after executing the previous test step/command.

Explicit Wait: Explicit waits are used to halt the execution till the time a particular condition is met or the maximum time has elapsed. Unlike Implicit waits, explicit waits are applied for a particular instance only.

73. How to type in a textbox using Selenium?

Ans: 

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”);

74. How can you find if an element in displayed on the screen?

Ans: 

WebDriver facilitates the user with the following methods to check the visibility of the web elements. These web elements can be buttons, drop boxes, checkboxes, radio buttons, labels etc.

  • isDisplayed()
  • isSelected()
  • isEnabled()

Syntax:

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

  • isSelected():
  • boolean buttonSelected = driver.findElement(By.id(“gbqfba”)).isSelected();

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

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

Ans: 

Get command is used to retrieve the inner text of the specified web element. The command doesn’t require any parameter but returns a string value. It is also one of the extensively used commands for verification of messages, labels, errors etc displayed on the web pages.

Syntax:

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

76.  How to select value in a dropdown?

Ans: 

The value in the dropdown can be 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);

77. What are the different types of navigation commands?

Ans: 

Following are the navigation commands:

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

Sample code:

  • driver.navigate().back();

navigate().forward() – This command lets the user to navigate to the next web page with reference to the browser’s history.

Sample code:

  • driver.navigate().forward();

navigate().refresh() – This command lets the user to refresh the current web page there by reloading all the web elements.

Sample code:

  • driver.navigate().refresh();

navigate().to() – This command lets the user to launch a new web browser window and navigate to the specified URL.

Sample code:

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

78. How to click on a hyper link using linkText?

Ans: 

  • 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.

79. How to handle frame in WebDriver?

Ans: 

An inline frame acronym as iframe is used to insert another document within the current HTML document or simply a web page into a web page by enabling nesting.

Select iframe by id

  • driver.switchTo().frame(“ID of the frame“);

Locating iframe using tagName

  • driver.switchTo().frame(driver.findElements(By.tagName(“iframe”).get(0));

Locating iframe using index

  • frame(index)
  • driver.switchTo().frame(0);
  • frame(Name of Frame)
  • driver.switchTo().frame(“name of the frame”);
  • frame(WebElement element)

Select Parent Window

  • driver.switchTo().defaultContent();

80. What is a Framework?

Ans: 

A framework defines a set of rules or best practices which we can follow in a systematic way to achieve the desired results. There are different types of automation frameworks and the most common ones are:

  • Data Driven Testing Framework
  • Keyword Driven Testing Framework
  • Hybrid Testing Framework
  • Behavioural Driven Framework

81. Have you created any Framework?

Ans: 

If you are a beginner: You can say “No, I didn’t get a chance to create framework from the scratch. I have used the framework which is already available. My contribution is mostly in creating test cases by using the existing framework.”

If you are a beginner but have good knowledge on creating framework: You can say “Yes, I have involved in developing framework along with other automation tester in my company.”

If you are an experienced tester: You can say “I have contributed in developing framework.” or You can say “Yes, I have created framework from the scratch. There was no automation process in my previous company. I designed the framework from the scratch.”

Why WebDriver driver = new FirefoxDriver();

82. Why do you prefer Selenium Automation Tool?

Ans: 

I prefer Selenium Automation Tool because some of the benefits of Selenium to do automation testing are

  • Free and open source – It is a free open source tool. There is no need to allot budget for this tool
  • Help – Have large user base and helping communities.
  • Cross-browser compatibility – It works on almost all popular browsers such as Chrome, Firefox, Internet Explorer, and Safari.
  • Cross Platform compatibility – It works on platforms such as Windows, Linux, Mac.
  • Multiple programming languages – It supports programming languages such as Java, Phyton, Perl, Php, C#, Ruby, etc.,
  • Parallel Execution – Selenium Grid supports parallel execution of Selenium Scripts.
  • Continuous Integration – We can achieve nightly execution using Jenkins.

83. What are the benefits of Selenium automation?

Ans: 

There are many benefits of using Selenium for automated testing.

  • Open source: Since it is an OSS, so we don’t have to bear any licensing cost for using it.
  • Cross-browser: It works on all standard browsers such as Chrome, FF, IE, and Safari. We can run same the test script in all browsers.
  • Multi-language: We can choose a familiar programming language from Java, Python, C#, Ruby to use with Selenium.
  • Cross-platform: It provides test compatibility across Windows, Linux, and Mac OSX. We can run same the test script on all platforms.
  • Concurrency: With Selenium Grid, we can execute thousands of tests in parallel.
  • CLI support: We can create a test suite with hundreds of tests and launch it with a single command.
  • CI support: Jenkins is the best CI tool. It provides a Selenium plugin to configure tests for nightly execution.
  • Free help: We can get quick technical support from its large community.
  • Tester friendly: A non-programmer can also automate using Selenium. It is not too complicated to be used only by a programmer.
  • Ongoing project: Active development and bug fixes on the latest project.

84. What are some downsides to Selenium automation?

Ans: 

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

  • Doesn’t support automation of Windows applications
  • 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

85. Which is the only browser that supports Selenium IDE to be used?

Ans: 

Firefox

86. What is Selenium RC?

Ans: 

Selenium RC AKA Selenium Remote control / Selenium 1. Selenium Remote Control was the main Selenium project for a long time before the WebDriver merge brought up Selenium 2. Selenium 1 is still actively supported (in maintenance mode). It relies on JavaScript for automation. It supports Java, Javascript, Ruby, PHP, Python, Perl and C#. It supports almost every browser out there.

87. Which of the WebDriver APIs is the fastest, and why?

Ans: 

It is none other than the HTMLUnitDriver, which is faster than all of its counterparts.

The technical reason is that the HTMLUnitDriver doesn’t execute in the browser. It employs a simple HTTP request-response mechanism for test case execution.

This method is far quicker than starting a browser to carry out test execution.

88.  How can you use Selenium RC API along with Selenium 2.0/3.0?

Ans: 

We can still invoke Selenium 1.0 API (RC) from the Selenium 2.0 code. But there might be a few Selenium 1.0 methods missing.

However, we first need to create a Selenium instance from WebDriver and call Selenium functions.

The old methods might slow down the execution due to the API transitioning happening in the background.

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

Ans: 

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

  • Selenium IDE: A Firefox extension to record and play the user actions performed on a web page.
  • Selenium RC: A Selenium Remote Control which exposes APIs for scripting tests in different languages and also runs them in browsers.
  • Selenium Webdriver: These are native APIs that directly interact with the browser. They give more control and 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.

90. What are the benefits does WebDriver has over Selenium RC?

Ans: 

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

  • Selenium RC is slow because it has an additional JavaScript layer known 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 has a mature set of APIs but suffers from redundancies and complicated 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 produce HTML reports. Web Driver doesn’t have any built-in reporting ability.

91.  What are the advantages of Selenium Grid?

Ans: 

  • It allows running test cases in parallel thereby saving test execution time.
  • It allows multi-browser testing
  • It allows us to execute test cases on multi-platform.

92. What is a node in Selenium Grid?

Ans: 

Node is the machine which is attached to the hub. There can be multiple nodes in Selenium Grid.

93  What are the types of WebDriver APIs available in Selenium?

Ans: 

  • Firefox Driver
  • Gecko Driver
  • InternetExplorer Driver
  • Chrome Driver
  • HTMLUnit Driver
  • Opera Driver
  • Safari Driver
  • Android Driver
  • iPhone Driver
  • EventFiringWebDriver

94. Which WebDriver implementation claims to be the fastest?

Ans: 

The fastest implementation of WebDriver is the HTMLUnitDriver. It is because the HTMLUnitDriver does not execute tests in the browser. Starting a browser and running test cases took more time compared to running the scripts without a browser. HTMLUnitDriver took a simple HTTP request-response mechanism for test case execution.

95. What are the Programming Languages supported by Selenium WebDiver?

Ans: 

  • Java
  • C#
  • Python
  • Ruby
  • Perl
  • PHP

96. Which language is not supported by selenium?

Ans: 

Selenium supports all major programming languages such as Java, C#, Perl, Python, Ruby, PHP, Scala and Groovy. As of today, others are not compatible.

97. What are the Operating Systems supported by Selenium WebDriver?

Ans: 

  • Windows
  • Linux
  • Mac OS X
  • iOS
  • Android

98. What are the testing types that can be supported by selenium?

Ans: 

Testing types that can be supported by Selenium are as follows:

  • Functional Testing
  • Regression Testing
  • Retesting
  • Acceptance Testing
  • End-to-End Testing
  • Smoke Testing
  • Sanity Testing
  • Responsive Testing
  • Cross Browser Testing
  • UI Testing
  • Integration Testing

99. What is the latest Selenium Webdriver architecture?

Ans: 

Below block diagram explains the latest architecture Selenium Webdriver supports

selenium-webdriver-architecture

Are you looking training with Right Jobs?

Contact Us
Get Training Quote for Free