Top Selenium Interview Questions & Answers

5.00 avg. rating (99% score) - 5 votes
Selenium-interview-questions

Selenium is a suite of tools to automate web browsers across many platforms. It is a free, open-sourced application which caters to different testing requirements. This application also supports authoring of tests without having to learn a scripting language and provides a domain-specific language to writes tests in a number of popular programming language. It also runs on most of the modern browsers.

Due to the many advantages Selenium has to offer, it is one of popular testing frameworks and Selenium professionals are in great demand across the IT industry. To prepare for your next interview on Selenium, here are some of the frequently-asked Selenium interview questions (with answers) to help you prepare well.

 

Q1. How many languages does Selenium support?

 

Ans. All major languages, including C#, Java, PHP, Ruby, Python.

 

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

 

Q3. What are the different ways to find an element?

 

Ans. ID, Name, Tag, Attribute, CSS, Linktext, PartialLink Text, X-path

 

Q4. What are the testing types supported by Selenium?

 

Ans. Functional testing and regression testing

 

Q5. What is the difference between implicit wait and explicit wait in selenium WebDriver?

 

Ans. When an implicit wait is implemented in tests, if WebDriver cannot find an element in the Document Object Model (DOM), it will wait for a defined amount of time for the element to appear in the DOM.

 

An explicit wait can be used where synchronization is needed, for example the page is loaded but we are still waiting for a call to complete and an element to appear.

 

Q6. Which is better – implicit wait or explicit wait?

 

Ans. Explicit waits are better than implicit wait. Unlike an implicit wait, you can write custom code or conditions for wait before proceeding further in the code.

 

Q7. When should I use Selenium IDE?

 

Ans. Selenium IDE is the simplest of all the tools in the package and should be a great tool for naïve users as it is easy to learn with minimal acquaintances in programming language.

 

Q8. Explain the difference between single (/) and double slash (//) in X-path?

 

Ans. Single slash (/) allows the creation of ‘absolute’ path expressions, while double slash (//) allows the creation of ‘relative’ path expressions.

 

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

 

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

 

Ans. Type key populates the value attribute using JavaScript whereas type commands emulate like actual user typing

 

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

 

Ans. Assert command allows to check whether an element is on the page or not. Verify command checks whether the element is on the page, otherwise the test will carry on executing.

 

Q12. What is heightened privileges browsers?

 

Ans. Heightened privileges browsers are similar to Proxy Injection, allows websites to do something that are not commonly permitted.

 

Q13. Explain what is Data-driven framework and Keyword driven?

 

Ans. In Data-driven framework, the test data is separated and kept outside the Test Scripts, while test case logic resides in Test Scripts.

Keyword driven frameworks requires the development of data tables and keywords, independent of the test automation.

 

Q14. What is Object Repository?

 

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

 

Q15. Mention 5 different exceptions you had in Selenium WebDriver?

 

Ans. The 5 different exceptions in Selenium WebDriver are WebDriver Exception, NoAlertPresentException, NoSuchWindowException, NoSuchElementException, TimeoutException

 

 

Q16. Which web driver implementation is fastest?

 

Ans. HTMLUnit Driver implementation is fastest

 

Q17. How to find more than one web element in the list?

 

Ans. It can be done using WebElement List. E.g.

List <WebElement> elementList = driver.findElements(By.xpath(“//div[@id=’example’]//ul//li”));

int listSize = elementList.size();

for (int i=0; i<listSize; i++)

{

serviceProviderLinks.get(i).click();

driver.navigate().back();

}

 

Q18. What is the difference between driver.close() and driver.quit() command?

 

Ans. Close() method closes the web browser window that the user is currently working on or the browser that WebDriver is currently accessing.

Quit() method closes down all the windows that the program has opened.

 

Q19. In which format does source view shows your script in Selenium IDE?

 

Ans. XML

 

Q20. What is Object Repository? How can we create Object Repository in Selenium?

 

Ans. Object Repository is a term used to refer to the collection of web elements belonging to Application Under Test (AUT) along with their locator values.

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

 

Q21. What is Selenese and what are the types of Selenese ?

 

Ans. Selenese is a selenium set of command which are used for running the test.

There are three types of Selenese – Actions, Assertions and Accessors

 

Q22. How you can convert any Selenium IDE tests from Selenese to another language?

 

Ans. The format option of Selenium IDE to convert tests into another programming language

 

Q23. To generate pdf reports mention what Java API is required?

 

Ans. API IText

 

Q24. What are the ways you can customize TestNG report?’

 

Ans. You can customize TestNG report in two ways,

  • Using ITestListener Interface
  • Using IReporter Interface

 

Q25. In Selenium what are Breakpoints and Startpoints?

 

Ans. A breakpoint is implemented to stop an execution to check if the code is working as expected till now.

A startpoint indicates the point from where the execution should begin.

 

Q26. What is Selenium composed of?

 

Ans. Selenium is a suite of tools for automated web testing and it is composed of Selenium IDE (Integrated Development Environment), WebDriver and RC, and Grid.

 

Q27. Can you tell me from where the term Selenium derived?

 

Ans. Well, it came from a joke made by Jason Huggins (the developer of Selenium) in an email, where he mocked one of his competitors named Mercury, saying that you can cure mercury poisoning by taking selenium supplements. This is from where the other email recipients took the name and the rest is history.

 

Also ReadTop QA Interview Questions and Answers
 

Q28. Why should you use Selenium as a test tool?

 

Ans. Selenium is a free and open source tool, and has a large user base. It helps communities and is compatible with every browser (Chrome, Firefox, Internet Explorer, etc.). Besides, it also has a great platform compatibility (Windows, Mac OS, Linux etc.)

 

Q29. What is Selenese?

 

Ans. Selenese is the language used to write test scripts in Selenium IDE.

 

Q30. How many programming languages does Selenium support?

 

Ans. Selenium supports multiple programming languages like Java, C#, Ruby, Python, Pearl, etc.

 

Q31. What are the different Selenium components?

 

Ans. Different components of Selenium are sets of tools, which include:

  • Selenium Integrated Development Environment (IDE)
  • Selenium Remote Control (RC)
  • Selenium WebDriver
  • Selenium Grid

 

Q32. Elaborate the functioning of Selenium Grid?

 

Ans. Selenium Grid sends tests to the hub, which are then redirected to Selenium Webdriver. It then launches the browser and runs the test. The tests run in parallel with entire test suite.

 

Q33. Can we use Selenium grid for performance testing?

 

Ans. Yes, but it is not as effective as Loadrunner, which is a dedicated Performance Testing tool.

 

Q34. Which testing types are supported by Selenium?

 

Ans. Selenium supports two types of testing:

  1. Functional Testing
  2. Regression Testing

 

Q35. How will you find an element using Selenium?

 

Ans. Every object or control in a web page is an element in Selenium, and some of the ways to find that element in a web page include using ID, Name, Tag, Attribute, CSS, Linktext, PartialLink Text and Xpath.

 

Q36. What is Page Object Model (POM)?

 

Ans. POM is a design pattern responsible for creating an Object Repository for web UI elements.

 

Q37. What is Page Factory?

 

Ans. Page Factory provides an optimized way to implement Page Object Model and it has a very good memory utilization and implementation is object-oriented.

 

Q38. What is an XPath?

 

Ans. XPath is a language which helps to locate and process items in Extensible Markup Language (XML) documents. It addresses syntax based on a path through the document’s logical structure or hierarchy. XPath is used to locate a web element based on its XML path. It also stores, organizes and transports arbitrary data.

 

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

 

Ans. “/” or Single Slash creates Xpath from the document node/start node.

“//” or Double Slash creates Xpath with relative path from anywhere within the document.

 

Q40. Which test types are supported by Selenium?

 

Ans. So, Selenium supports –

  • Functional Testing
  • Regression Testing
  • Sanity Testing
  • Smoke Testing
  • Responsive Testing
  • Cross Browser Testing
  • UI testing (black box)
  • Integration Testing

 

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

 

Ans. Type Keys trigger JavaScript event but the Type Command don’t. Type key simulates each keystroke using JavaScript, while whereas Type Command emulates actual user typing.

 

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

 

Ans. Assert command helps to check the availability of a certain element on the page. The test terminates at the point the check fails, i.e. if the element is unavailable.

Verify command also helps to check the availability of a certain element on the page, but here the test goes on as all the commands run is guaranteed even if the check fails.

 

Q43. Can Selenium handle windows based pop up?

 

Ans. Since it is an automation testing tool and supports only web application testing, it can’t handle windows pop up. However, third-party tools like AutoITm and Robot class are available to handle this.

 

Q44. How do we handle web-based pop up in Selenium?

 

Ans. We can use WebDriver, which provides an efficient way to handle these pop-ups using Alert interface. Besides, there are four methods too that we can use –

void dismiss() – The accept() method clicks on the “Cancel” button when the pop-up window appears.

void accept() – The accept() method clicks on the “Ok” button when the pop-up window appears.

String getText() – The getText() method returns the text displayed on the alert box.

void sendKeys(String stringToSend) – The sendKeys() method enters the specified string pattern into the alert box.

Syntax:

// accepting javascript alert

Alert alert = driver.switchTo().alert();

alert.accept();
 

Q45. Tell me how can I take a screenshot in Selenium WebDriver?

 

Ans. You can do that by using the TakeScreenshot function and by using getScreenshotAs() method, you can save the screenshot.

 

Q46. Is it possible to enter a text without using sendKeys()?

 

Ans. Yes, we can enter/ send text using JavaScriptExecutor, and we don’t need to use sendKeys() method.

 

Q47. What is Junit?

 

Ans. It is a Java-based unit testing framework introduced by Apache.

 

Q48. What is Object Repository?

 

Ans. Object Repository refers to a collection of web elements belonging to Application Under Test (AUT) along with their locator values. Object Repository is used to store locators in a centralized location.

 

Q49. How can we create Object Repository in Selenium?

 

Ans. We can create Object Repository in an excel sheet that can be populated inside the script whenever required.

 

Q50. Does Selenium have any limitations?

 

Ans. Yes, it has.

 

  • It supports testing of only web-based applications
  • One cannot test mobile applications
  • Selenium can’t test Captcha and Barcode readers
  • It helps to generate reports using third-party tools like TestNG or JUnit
  • No ready vendor support
  • User must possess programming language knowledge

These are some of the popular questions asked in Selenium interviews. Always be prepared to answer all types of questions — technical skills, interpersonal, leadership or methodology. If you are someone who has recently started your career in software testing, you can always get certified in Selenium to get the requisite technical skills and experience.

About the Author

Hasibuddin Ahmed

Hasibuddin Ahmed

Hasib is a professional writer associated with learning.naukri.com. He has written a number of articles related to technology, marketing, and career on various blogs and websites. As an amateur career guru, he often imparts nuggets of knowledge related to leadership and motivation. He is also an avid reader and passionate about the beautiful game of football.