45 Selenium Interview Questions To Hire Or Get Hired With
Selenium is a staple when it comes to automation testing for web applications. Web applications these days have complex user stories that solve broad problems. From fintech tools that connect to your checking account and web applications which buy homes right online. These types of robust solutions to big, broad, architectural challenges require software engineering to take on a robust form. Testing and automation help to ensure software that gets released as part of the agile software development lifecycle is functional and operates as expected. As an engineer, having these testing skills will be the way to land jobs at larger scale organizations that serve software to millions of people. Below is my Selenium Interview Question guide, with answers. With all answers to these Selenium questions, it's important that you use your own best judgment to the answer. Meaning, take these practical examples as a study guide — but I wouldn't recommend answering them verbatim. Mostly because it won't come across genuine and with confidence, and have that cadence to your interview can go a long way.
1. What is Selenium?
What are the different elements of Selenium? Selenium refers to a popular automated testing suite. It has been designed in a manner that it supports and encourages automation testing of the functional factors of web-based applications, not to mention a number of browsers and platforms. Because of its existence within the open source community, it has become a very accepted tool among testing professionals. It is not just one of the single tools or utilities but it is a package for the testing of several tools and for the same reason, it is referred to as the Suite. Each of these tools would be designed for the purpose of catering to different testing and test environmental requirements. As such, the suite package comes with a number of sets of tools.
• Selenium remote control: this is a server, which allows the user to initiate test scripts within the desired programming language. It also allows execution of the test scripts in a large range of browsers.
• Selenium integrated development environment; this is a record and playback type of tool, which is distributed as a Firefox type of plugin.
• Selenium WebDriver: this is a different tool and has a number of benefits over the Selenium RC. WebDriver could directly communicate with the web browser and utilizes the native compatibility for it to automate.
• Selenium Grid: Selenium Grid is utilized for the distribution of the test execution on different platforms and environments in a concurrent manner.
2. What is automation testing?
This is the process of testing the software of the application with the use of one automation testing tool in order to ascertain the defects. During this process, the execution of the test scripts and generation of the results would be done automatically through a number of automation tools. This is needed when there is a large amount of regression type test cases. Some of the popular type tools for automation testing would include Selenium WebDriver and HP QTP.
3. Describe the advantages of automation testing.
• Opportunity to reuse the code. It can be created one time and executed severally with limited maintenance.
• It saves time and money as automation testing is faster during implementation.
• Automation testing allows for easy reporting. It generates automatic reports after the test execution.
• It is strong and versatile. It allows the clients to integrate with Cross Browser Testing Tools and Github.
• It can be low cost maintenance and is cheaper compared to manual testing occurring during the long term.
• There is minimal manual intervention as the test scripts can be run without significant supervision.
• Automation testing is easy for compatibility testing. It allows for parallel execution within the combination of the different operating systems and browser environments
4. What are the disadvantages that come with Selenium WebDriver?
It is a tool, which automates the browser so that it imitates the real user actions of the web. Some of the challenges include;
• It is not possible to test the windows application.
• There is a limited amount of reporting.
• One may have to handle a page load.
• One may have to handle dynamic elements.
• It is not possible to test mobile applications.
5. What type of tests can be automated?
The main focus is the automation of the test cases for the purpose of doing regression testing, sanity testing, and smoke testing. At times, based on the project and the testing time estimation, there is a focus on the end-to-end testing.
6. How many test cases can be automated in a day?
This is dependent on the test case scenario complexity and the length. One can automate 2 to 5 test scenarios a day when the complexity is not that high. At times, it is only possible to manage one or even fewer test scenarios in a day when the level of complexity is high.
7. What is a framework?
The framework defines a set of rules r best practices, which can be followed in a systematic manner in order to achieve the desired effect. There are several different modes of automation frameworks and the ones which are most common include the following;
• Data-driven testing framework.
• Hybrid testing framework.
• Keyword driven testing framework.
8. Have you created a framework before?
• If you are a beginner: you can claim that you did not get an opportunity to create a framework from scratch. You may have used the framework, which is already available. The contribution would be in the creation of test cases with the use of existing frameworks. In the event you are a beginner but have good knowledge on the creation of frameworks, you can say that you were involved in the developing of frameworks along with other automation testers within the company.
• If you are an experienced tester, you may claim that you have contributed in the developing frameworks or claim that have created the framework from scratch. There may not have been any automation process within the previous company and you designed the framework from scratch.
9. What is the difference between assert and verify commands
• Verify: the verify command is there to check whether the element is on the page. In the event that it is not then the test will proceed in the executions. In the verification setting, every command would run guaranteed even in the event that any of the tests would fail.
• Asset: assert allows for checking whether elements are on the page or if they are not. The test would stop on the step there is a failure if the asserted element is not there. The test is going to be ended at the point where the check fails.
10. Why should the testers opt for Selenium and not QTP?
Selenium happens to be more popular for the following reasons:
• Selenium is an open source tool while QTP is commercially based which means you pay for it.
• Selenium supports Internet Explorer, Opera, Safari and Firefox on different operating systems such as Linux, Windows and Mac. QTP, on the other hand, is limited to supporting Internet Explorer, which is the most unpopular browser thus far.
• Selenium is used particularly for testing of web-based applications through QTP may be utilized for testing the client-server application as well.
• Selenium may support a number of programming languages such as Perl, Python, and Ruby though QTP supports only the VB script.
11. What is the difference between sleep() methods and setSpeed()?
• Thread.sleep (): it is going to stop the current (java) thread for the specified period. This is only done once.
• It takes a single argument in the integer format.
• It waits only once at the command given at sleep.
• Set Speed (): for the particular amount of time, it is going to stop the execution for each Selenium command.
• This would take a single argument within an integer format. • Each command would be run after setSpeed delay by the number of milliseconds mentioned within set Speed.
12. What is the same origin policy? How can one avoid it?
The same origin policy is introduced for security reasons because it makes certain the content of the site is never accessible through scripts from another site. According to the policy, any code that is loaded within the browser would only operate within the domain of the website. In order for one to avoid the ‘Same Origin Policy’, proxy injection can be used within the proxy injection mode the Selenium server would act as the client configured HTTP proxy, that sits between the browser and the application under test and then mask the AUT under a fictional type of URL.
13. What are the heightened privilege browsers?
The objective of the heightened privileges is similar to Proxy Injection as it allows the websites to do something which is not commonly permitted. The main difference is the browsers would be launch in a special mode, which is known as heightened privileges. Through the use of these browser mode, Selenium core can open the AUT in a direct manner and also read/ write the content without going through the entire AUT through the Selenium RC server.
14. What are the features of TestNG and list some of the functionality within TestNG that makes it more effective.
The TestNG is one of the testing frameworks based according to JUnit and NUnit for simplifying the range of testing needs from Unit Testing toward Integration Testing. Similarly, the functionality that makes it efficient when it comes to testing frameworks would include:
• Support for the data-driven testing.
• Support for annotations.
• Flexible test configuration.
• The ability for one to re-execute the failed test cases.
15. What is the difference between the explicit and the implicit wait?
The explicit wait is a one-timer and used for particular searches while the implicit wait sets a timeout for each of the successive web element searches. For the specified amount of time, it is going to try to look for element again before throwing a no such element type of exception. It waits for the elements to present themselves.
16. What are the keyword driven framework and the data-driven framework?
• The data-driven framework is where the test data has been separated and kept outside of the test scripts while the test case logic is in the Test Scripts. The test data is read from the external files and are loaded into the variables within the Test Script. The variables are utilized both for the input values and for the verification values.
• Keyword driven framework: the keyword driven framework needs the development of data tables as well as, keywords that are independent on the test automation. Within a keyword-driven test, the functionality of the application under the test is documented within a table and step by step instructions for each of the tests.
17. When should you use Selenium IDE?
Selenium IDE is one of the easiest and simplest tools within the Selenium package. Its recording and playback features make it very easy to learn with minimal acquaintances to the programming language. Selenium IDE is optimal for the naïve user.
18. What is Selenese?
Selenese is the language used to write test scripts within Selenium IDE.
19. What are the different locator types within Selenium?
The locator may be termed as an address, which identifies web elements in a unique manner within the web page. So in order to identify the web elements in an accurate manner and precisely there are different locator types when it comes to Selenium:
20. What is an Xpath?
An Xpath is used for locating a web element based according to the XML path. The XML is an abbreviation for extensible markup language and is utilized for storing and transporting the arbitrary data. It stores the data in a key-value pair that is similar to the HTML tags. Considering they are markup languages and because they go under the same umbrella, XPath can be used for the purpose of locating the HTML elements. The fundamentals that are behind the location of elements through XPath is traversing between different elements across the entire page and so enabling the user to find elements with the reference of another.
21. What is the difference between ‘single slash’ and ‘double slash’ within XPath?
Single slash is utilized for the creation of XPath with absolute path. That would be to claim the XPath would be initiated in order to begin the selection from the document node/ start node. Double slash is utilized for the creation of Xpath with a relative path. That would be to say the XPath has to be created in order to begin selection from any place in the document.
22. How is it possible to get a text of web element?
Get command would be utilized to retrieve the inner text of the particular web element. The command would not need parameters but returns as a string value. It is also one of the most extensively utilized commands for verification of messages, errors, labels that are displayed on the web pages.
23. How does one find more than one web element in the list?
At times, you may find elements of the same type such as multiple hyperlinks and images arranged in an ordered type lit. So it makes a lot of sense for one to deal with such elements through a single code piece and this would be implemented through the WebElement List.
24. What is the difference between the driver.close() and the driver.quit command?
• Quit(): not like the close () method, the quit () method closes all of the windows which the program has opened. In the same way as the close () method, the command neither needs any parameter nor does it return any particular value. • Close (): WebDriver’s close () approach closes the web browser window, which the user is currently working on or we can also claim the window, which is being accessed by the WebDriver. The command neither needs any parameter and it does not return any value.
25. Can Selenium handle windows based pop up?
Selenium is an automation testing type of tool that supports web application testing. That means windows pop up may not be handled with the use of Selenium.
26. How can you handle a web-based pop up?
The WebDriver offers the users with an efficient manner of handling the pop-ups with the use of the Alert interface. There are some methods, which can be used with the Alert interface.
• Void dismiss ()- the accept (0 method clicks on the cancel button as soon as the pop up window comes up.
• Void accept ()- the accept () method clicks on the ‘Ok’ button as soon as the pop up window comes up.
• String getText()- the getText (0 method allows for the returning of the text as illustrated on the alert box.
• Void sendkeys (String stringtoSend) – The sendKeys () method enters the particular string pattern into the alert box.
27. What are the different framework types?
• Library architecture testing framework: the basic fundamentals behind the framework would be determination of the common steps and then group them according to functions under a library and then call the functions in the test scripts when they are needed.
• Module based testing framework: this type of framework divides the ‘Application Under Test’ into the logical and isolated type modules. For each of the modules there is a separate and independent test script. So when these test scripts taken together it builds a larger test script, which gives a representation of more than one module.
• Data driven testing framework: the data-driven testing framework would assist the user so that they segregate the test script logic and the test data from each other. It allows the user to store the test data into a database, which is external. The data may also be conventionally be stored within ‘key-value’ pairs. So the key may be utilized for accessing and populating the data within the particular test scripts.
• Keyword driven testing framework: the keyword driven testing framework is an extension to the data-driven testing framework in the sense it not only segregates the test data from the particular scripts but also keeps particular sets of code that belong to the test script into an external datatype file.
• The behavior-driven development framework: this framework provides for the automation of the functional validations in an easily readable and understandable format to the developers and business analysts.
• Hybrid testing framework: the keyword driven testing framework is an extension to the data-driven testing framework in the sense that it does not only segregate the test data from the script but also keeps particular code belonging to the test script into an external type of data file.
28. What can be considered is the difference between the relative and the relative path?
• The absolute XPath begins from the root node and concludes with the desired descendant element node. It begins with the top HTML node and ends in an input node. It begins with a single forward slash. • Relative XPath begins from any node that is between the HTML page to the current elemental node, which is the last node of the element. It begins with a double forward slash.
29. Distinguish between the hard asset and soft assert.
• Soft assert: soft assert collects errors during the @test. It does not throw an exception when the assert fails and may continue with the next phase after the assert statement.
• Hard assert: it throws an AssertException immediately when an assert statement fails and the test suite proceeds with the next @test.
30. What are the verification points that are there in Selenium?
In Selenium IDE, one uses Selenese verify and assert type commands as the verification points. When it comes to the Selenium WebDriver, there does not happen to be any built in features for the verification points. This is dependent on the coding style. Some of the verification points in this scenario would be:
• Checking for particular text
• Checking for the page title
• Checking for certain elements
31. What are the exceptions that one has faced when it comes to Selenium WebDriver?
Some of the exceptions include:
Element Not visible Exception
This exception can be thrown when one is trying to locate particular elements on a webpage that would not be visible even in the event that it is present in the DOM. If one is trying to locate an element with the XPath that licks with two or more elements.
State element reference exception
A State Element Reference Exception can be thrown in one of two cases. The first is a bit more common as compared to the second. The reasons for the Stale Element reference include:
• The element may have been entirely deleted
• The element is not attached anymore to the DOM
You face this Stake Element Reference Exception at the time when the element that you are interacting with is destroyed and then recreated once more. When this occurs, the reference concerning the element in the DOM becomes stale. So you will not be able to get the reference to the element.
There are exceptions that are faced as one proceeds. These would include the:
32. What is Selenium Remote control?
Selenium IDE has limitations as concerns browser and language support. Through the use of Selenium RC limitation, this can be reduced.
• Selenium RC is java based and uses any language so that it can interact with the web application.
• On the different platforms and web browser for automating web application, Selenium RC can be used with Java, Python and Perl.
• Using the server is possible to bypass the restriction and run the automation script running against the web applications.
33. Why is Selenium RC utilized?
Selenium IDE does not particularly support a number of functions such as the condition statements logging and reporting of the test results and iteration as well as, error handling and so forth considering the IDE only supports the HTML languages. In order to handle these problems Selenium RC, it supports Python, Ruby and PHP, through which it is possible to write the program to achieve the IDE issues.
34. What are the advantages that come with RC?
• It is possible to read or write data from / to .xls,.txt and so forth.
• Loops and conditions may be utilized for the sake of performance and flexibility.
• Similarly there is a chance to support a number of programming languages and operating systems.
• For any JAVA script enabled browser, Selenium RC may be utilized.
35. In Selenium, what are the Startpoints and the Breakpoints?
• Breakpoints: When you implement a breakpoint within the code, the implementation is going to stop at that position. This would assist in verifying the code is working well. • Startpoints: this indicates the point from which the implementation is to start. The Startpoint would be utilized when a person wants to run the testscript from the middle of the code or the breakpoint.
36. Why would you choose Python as opposed to Java in Selenium?
• Java utilizes traditional braces in order to start and end the blocks while Python only utilizes indentation.
• Java programs can run slower when you compare them to the Python programs.
• Python seems to be simpler and more compact as opposed to Java.
• Java utilizes static typing though Python employs dynamic typing.
37. What are the issues, which are considered in Handling Ajax Call when it comes to Selenium WebDriver?
• It is hard to evaluate the risk that is linked with specific Ajax applications.
• Given the complete freedom to the developers so they modify the Ajax, application makes the entire testing process a challenge.
• The use of ‘pause’ command when handling Ajax call is not reliable. Long pause time makes the test very slow and it increases the time for testing. In this case, ‘waitforcondition’ command would be better in testing the Ajax applications.
• Creation of automated test requests can be hard when it comes to testing tools like Ajax applications because they utilize different serializations and encoding to submit their Post data.
38. What is Listeners in Selenium WebDriver?
In Selenium, WebDriver, the listeners ‘listen’ to the event as defined within the Selenium script and behave in the right manner thus. It allows for the customization of TestNG reports or logs. There are two types of listeners, which are the TestNG and the WebDriver Listeners.
39. What is the desired capability and how is it useful when it comes to Selenium?
The desired capability refers to a series of key pairs, which store the browser properties such as the browser name, version and the path of the browser driver in the system for determining the behavior of the browser during runtime. In the case of Selenium:
• It may be used for configuring the driver instance for the Selenium WebDriver.
• When you would like to run the test cases on different browsers with a number of different operating systems and versions.
40. Why would you need Session Handling when working with Selenium?
When you are working with Selenium, Session Handling is a requirement.
During test execution, the Selenium WebDriver would have to interact with the browser all of the time in order to execute particular commands. During the time of execution, it may also be possible that before the current execution is completed, another person may begin the execution of another script within the same machine and within a similar browser. In order to avoid this situation, Session Handling comes in handy.
41. What would be the advantage of using GitHub for the purposes of Selenium?
• Several people when working on the same project can update project details and then inform the other members of the team simultaneously.
• Jenkins can assist with building the project from the remote repository in a regular manner. That would help with keeping track of the failed type of builds.
42. What are the advantages that come with a Selenium Grid?
Selenium Grid allows for multibrowser testing, multiplatform testing, and parallel test case executions.
43. What is a hub within Selenium Grid?
This is a central point or a server, which controls the test executions on the different machines.
44. What is a node in Selenium Grid?
This is a hub attached machine, which has instances that are running the test scripts. Unlike the hub, there may be more than one node in the Selenium Grid.
45. Explain the line of code WebDriver= new FirefoxDriver();.
‘WebDriver is the interface and the task is to create an object of type WebDriver Instantiating an object of the FirefoxDriver class.
Phone Interviews have become a core part of the process when attempting to find a secured placement for an open position. Companies receive massive responses from potential..
Concerning a job search, you might receive numerous offers from your recruiters. Before you choose one, you need to assess all the conditions, for which it is vital that you know everything associated with the offered position..
Answering this question during a job interview requires more than knowing why you are unique as an individual. Yes, the true scientific answer is made up of two main components: your..
So, you have been in search of a job for a considerable time but are yet to be selected for one. If that's the case, don’t worry anymore because we have got you covered..
Open-ended questions like “what motivates you?” can elicit a deer-in-the-headlights reaction from job candidates if they are unprepared. It’s a broad question and can..
A lot of interviewers ask this question - how did you hear about this position? This way they can judge you if you are a passive or an active job seeker..