Selenium Interview Question – 3
This is the third post in the series of Selenium interview preparation. In case you missed first two posts below are the link.
Selenium Interview Question – 1
Selenium Interview Question – 2
This section is mainly focused on Interview Questions from topics like Advance Selenium WebDriver APIs, Design Patterns like POM (Page Object Model), Enhanched POM – Page Factory, and designing Frameworks.
People with experience 2-7 years can expect these kinds of questions.
Ques1: What type of test cases have you automated?
- Regression and Functional tests are generally automated using any automation tools because these type of tests are more stable and are less prone to change. Also, as organizations are moving towards the Agile way of working, writing automation as an when functionality is being developed is a new trend. Integrating selenium with tools like cucumber or Specflow where we write BDD (Behavior-driven development) gives stakeholders confidence in development.
Ques2: Have you worked on any framework? Describe the framework designed for your project?
- Here, they want to test that whether you have actually worked on some frameworks or not. The Answer to this question will be the framework which you have designed for your project. If you have not worked on any framework. Please go through Selenium Tutorials to understand some standard frameworks designed with Selenium Automation Tool. Writing Data Driven, Hybrid Driven or customized framework using design patterns like POM or enhanced POM (Page Factory) is a trend.
Ques3: Explain the directory structure of your project?
- Here, the interviewer is expecting to know what kind of directory structure and class structure you are following in your project. While explaining the answer to this question mention the reason for having the directory structure you are following.
- The interviewer wants to test whether you have used Object-oriented programming concepts, design patterns, configuration files, Helper classes or Utility classes. How structured your code is? How modular your code is? How easily it can be maintained, what logging functionality are you using? what reporting mechanism you are using in your project?
Ques4: How are you handling logging in your project?
- Logging is one of the essential features of any framework (project). For logging feature, there are many third-party tools available, one of them is the log4j.jar file. It supports logs at various levels – INFO, ERROR, DEBUG, EXCEPTION, etc.
- Recently, I came across another good tool – Extent Report which provides me features like generating HTML report, logs and also you can attach screenshots. You can try extent report also in your projects.
Ques5: Which design patterns do you use?
- Most frequently used design patterns is POM (Page Object Model). In this type of design pattern, one class file is created for each page of the application under test. In each class, first, an object repository is created which will have all the WebElements of the respective page then in the constructor, all these WebElements are initialized.
- Enhanced POM, also known as Page Factory can be used which helps you in resolving stale element exception, also provides cache management.
- Both POM and Page Factory design patterns are inspired through Abstraction (i.e the implementation is hidden from other classes)
- After that, all the possible scenarios are created as methods in that class.
Ques6: Explain different exception in Selenium WebDriver?
To answer this question, please follow http://qatechhub.com/exception-handling-in-selenium-webdriver/ link.
Ques7: What approach will you follow to pick a date from Date Picker?
In most of the calendars which use date picker, month and year are generally in form of a drop-down and the dates are in some table. Sometimes directly using xpath works and sometimes you have to iterate over this table to select a date from the calendar.
Ques8: Have you integrated AutoIt tool in your project? Why is this tool used?
- AutoIT is a tool which is used to automate windows based application. In some scenarios like downloading and uploading an image, there is a requirement to integrate something which can interact with windows based application. For a better understanding follow this link – http://qatechhub.com/integrating-autoit-tool-selenium-webdriver-upload-image-scenario/
Ques9: Have you heard of Continuous Integration, Continuous Delivery, and Continuous Deployment? Which tool are you using for same?
- Continuous Integration – On every code commit an event is triggered which builds the code of your application (tools like Maven for Java, MSBuild for C sharp etc) are used the unit tests are executed, code metrics are calculated and artifacts are created.
- Continuous delivery is deploying code on multiple environments for doing some kind of testing like Integration Testing, Manual Testing, Functional Testing, Performance testing, Security test and another level testing which your organization support.
- Continuous Deployment extends continuous delivery, after completion of automated testing the code is deployed to the production.
- To learn it in detail, follow Continuous Delivery Article
Ques10: Write a code to read properties file using JAVA?
public static Properties getProperties(String sPropertiesFile){ try { InputStream oFileReader; Properties oProperty; oFileReader = new FileInputStream(sPropertiesFile); oProperty = new Properties(); oProperty.load(oFileReader); return oProperty; } catch (Exception e) { e.printStackTrace(); // log.debug(e.getMessage()); return null; }
Ques11: Have you used Excel Sheet in your project? What are you using for the same?
- POI apache jar file is used to read from an excel sheet. There are many other open sources and paid tools available in the market like JXL, but POI from apache is most widely used.
- In Working with Excel article, I have covered all possible methods which you need to work with an excel sheet.
Ques12: What are the challenges you faced while working with Selenium Automation Tool?
Synchronization:
- One of the biggest challenges faced while working with Selenium is Synchronization.
- An application under test has its own speed of execution whereas the code written with selenium has its own.
- Keeping both in sync is a big task.
- Selenium provides us some wait statements (Page load Timeout, Implicit wait, Explicit wait and Fluent wait) which help us to improve synchronization.
- To learn Wait commands in detail follow: Wait Command in Selenium.
Maintainability:
- Another challenge which generally an automation engineer face is Maintaining the code.
- If your application is more prone to change like html elements of the page changes, some new components are being added and so on, this may affect your code especially locators.
- To get rid of these situations we have certain design patterns like POM (Page Object Model), Page Factory.
Ques13: Have you ever worked with Sikuili? How does it work?
- Selenium can only automate the Web-based application, but sometimes you may require interacting with Windows-based applications as well. In a such a scenario we have to use some third-party tool like Sikuli, which is an open source tool. This tool works with image recognization mechanism. It interacts with web elements through images.
Ques14: If you have ten elements on a page, and you have defined implicit wait as 10 sec. How much minimum and maximum time will your script take to interact with all the Web Elements?
- Minimum time will be almost zero seconds – if all these 10 web elements are already available, then selenium will interact with all of them in no time.
- Maximum time will be (10 * 10 = 100) seconds – if each element appears on the page at the 10th second, then the max time will be 100 seconds (10 sec for each web element).
Ques15: How to identify dynamic web elements (let us say these web elements does not have any Id or classname) on a page?
- To identify a dynamic web element first an element which is stable on the screen is identified using basic xpath concepts and then using functions or methods like text(), starts-with(), contains() and axes like parent, child, siblings, preceding, following, preceding-sibling you can reach to the desired element.
Quest16: Can you perform Mobile Automation Testing using Selenium?
- Yes, there is a tool called Appium, a wrapper written over Selenium which can be used to automate Mobile applications.
Ques17: What is Selenium Grid used for?
- Selenium Grid is the fourth component of Selenium suite and it is used for parallel testing or distributive testing on the same system or on different systems.
- To learn Selenium Grid in detail follow – Working with Selenium Grid.
Ques18: What is POM (Page Object Model)? Is it some framework? What is it used for?
- POM stands for Page object model, it’s not a framework but a design pattern. To learn page object model follow – POM in Selenium Frameworks.
Ques19: What benefit you get by using Page Factory?
- Page Factory is an enhanced way of achieving POM. To learn more about it follow – Enhanced POM in Selenium.
Ques20: Let us consider that there is a web page which has a web element let say a button which when u try to locate using some locator in browsers console or firebug or firepath, it can easily be located but when selenium tries to interact with this element, it throw Element Not Found Exception. What could be the possible reason for this?
Stay tuned to this place for more updates on Interview Questions.
PS: For any questions, queries or comments feel free to write us at saurabh@qatechhub.com or support@qatechhub.com. Happy Learning 🙂