- Blog Categories
- Software Development Projects and Ideas
- 12 Computer Science Project Ideas
- 28 Beginner Software Projects
- Top 10 Engineering Project Ideas
- Top 10 Easy Final Year Projects
- Top 10 Mini Projects for Engineers
- 25 Best Django Project Ideas
- Top 20 MERN Stack Project Ideas
- Top 12 Real Time Projects
- Top 6 Major CSE Projects
- 12 Robotics Projects for All Levels
- Java Programming Concepts
- Abstract Class in Java and Methods
- Constructor Overloading in Java
- StringBuffer vs StringBuilder
- Java Identifiers: Syntax & Examples
- Types of Variables in Java Explained
- Composition in Java: Examples
- Append in Java: Implementation
- Loose Coupling vs Tight Coupling
- Integrity Constraints in DBMS
- Different Types of Operators Explained
- Career and Interview Preparation in IT
- Top 14 IT Courses for Jobs
- Top 20 Highest Paying Languages
- 23 Top CS Interview Q&A
- Best IT Jobs without Coding
- Software Engineer Salary in India
- 44 Agile Methodology Interview Q&A
- 10 Software Engineering Challenges
- Top 15 Tech's Daily Life Impact
- 10 Best Backends for React
- Cloud Computing Reference Models
- Web Development and Security
- Find Installed NPM Version
- Install Specific NPM Package Version
- Make API Calls in Angular
- Install Bootstrap in Angular
- Use Axios in React: Guide
- StrictMode in React: Usage
- 75 Cyber Security Research Topics
- Top 7 Languages for Ethical Hacking
- Top 20 Docker Commands
- Advantages of OOP
- Data Science Projects and Applications
- 42 Python Project Ideas for Beginners
- 13 Data Science Project Ideas
- 13 Data Structure Project Ideas
- 12 Real-World Python Applications
- Python Banking Project
- Data Science Course Eligibility
- Association Rule Mining Overview
- Cluster Analysis in Data Mining
- Classification in Data Mining
- KDD Process in Data Mining
- Data Structures and Algorithms
- Binary Tree Types Explained
- Binary Search Algorithm
- Sorting in Data Structure
- Binary Tree in Data Structure
- Binary Tree vs Binary Search Tree
- Recursion in Data Structure
- Data Structure Search Methods: Explained
- Binary Tree Interview Q&A
- Linear vs Binary Search
- Priority Queue Overview
- Python Programming and Tools
- Top 30 Python Pattern Programs
- List vs Tuple
- Python Free Online Course
- Method Overriding in Python
- Top 21 Python Developer Skills
- Reverse a Number in Python
- Switch Case Functions in Python
- Info Retrieval System Overview
- Reverse a Number in Python
- Real-World Python Applications
- Data Science Careers and Comparisons
- Data Analyst Salary in India
- Data Scientist Salary in India
- Free Excel Certification Course
- Actuary Salary in India
- Data Analyst Interview Guide
- Pandas Interview Guide
- Tableau Filters Explained
- Data Mining Techniques Overview
- Data Analytics Lifecycle Phases
- Data Science Vs Analytics Comparison
- Artificial Intelligence and Machine Learning Projects
- Exciting IoT Project Ideas
- 16 Exciting AI Project Ideas
- 45+ Interesting ML Project Ideas
- Exciting Deep Learning Projects
- 12 Intriguing Linear Regression Projects
- 13 Neural Network Projects
- 5 Exciting Image Processing Projects
- Top 8 Thrilling AWS Projects
- 12 Engaging AI Projects in Python
- NLP Projects for Beginners
- Concepts and Algorithms in AIML
- Basic CNN Architecture Explained
- 6 Types of Regression Models
- Data Preprocessing Steps
- Bagging vs Boosting in ML
- Multinomial Naive Bayes Overview
- Gini Index for Decision Trees
- Bayesian Network Example
- Bayes Theorem Guide
- Top 10 Dimensionality Reduction Techniques
- Neural Network Step-by-Step Guide
- Technical Guides and Comparisons
- Make a Chatbot in Python
- Compute Square Roots in Python
- Permutation vs Combination
- Image Segmentation Techniques
- Generative AI vs Traditional AI
- AI vs Human Intelligence
- Random Forest vs Decision Tree
- Neural Network Overview
- Perceptron Learning Algorithm
- Selection Sort Algorithm
- Career and Practical Applications in AIML
- AI Salary in India Overview
- Biological Neural Network Basics
- Top 10 AI Challenges
- Production System in AI
- Top 8 Raspberry Pi Alternatives
- Top 8 Open Source Projects
- 14 Raspberry Pi Project Ideas
- 15 MATLAB Project Ideas
- Top 10 Python NLP Libraries
- Naive Bayes Explained
- Digital Marketing Projects and Strategies
- 10 Best Digital Marketing Projects
- 17 Fun Social Media Projects
- Top 6 SEO Project Ideas
- Digital Marketing Case Studies
- Coca-Cola Marketing Strategy
- Nestle Marketing Strategy Analysis
- Zomato Marketing Strategy
- Monetize Instagram Guide
- Become a Successful Instagram Influencer
- 8 Best Lead Generation Techniques
- Digital Marketing Careers and Salaries
- Digital Marketing Salary in India
- Top 10 Highest Paying Marketing Jobs
- Highest Paying Digital Marketing Jobs
- SEO Salary in India
- Brand Manager Salary in India
- Content Writer Salary Guide
- Digital Marketing Executive Roles
- Career in Digital Marketing Guide
- Future of Digital Marketing
- MBA in Digital Marketing Overview
- Digital Marketing Techniques and Channels
- 9 Types of Digital Marketing Channels
- Top 10 Benefits of Marketing Branding
- 100 Best YouTube Channel Ideas
- YouTube Earnings in India
- 7 Reasons to Study Digital Marketing
- Top 10 Digital Marketing Objectives
- 10 Best Digital Marketing Blogs
- Top 5 Industries Using Digital Marketing
- Growth of Digital Marketing in India
- Top Career Options in Marketing
- Interview Preparation and Skills
- 73 Google Analytics Interview Q&A
- 56 Social Media Marketing Q&A
- 78 Google AdWords Interview Q&A
- Top 133 SEO Interview Q&A
- 27+ Digital Marketing Q&A
- Digital Marketing Free Course
- Top 9 Skills for PPC Analysts
- Movies with Successful Social Media Campaigns
- Marketing Communication Steps
- Top 10 Reasons to Be an Affiliate Marketer
- Career Options and Paths
- Top 25 Highest Paying Jobs India
- Top 25 Highest Paying Jobs World
- Top 10 Highest Paid Commerce Job
- Career Options After 12th Arts
- Top 7 Commerce Courses Without Maths
- Top 7 Career Options After PCB
- Best Career Options for Commerce
- Career Options After 12th CS
- Top 10 Career Options After 10th
- 8 Best Career Options After BA
- Projects and Academic Pursuits
- 17 Exciting Final Year Projects
- Top 12 Commerce Project Topics
- Top 13 BCA Project Ideas
- Career Options After 12th Science
- Top 15 CS Jobs in India
- 12 Best Career Options After M.Com
- 9 Best Career Options After B.Sc
- 7 Best Career Options After BCA
- 22 Best Career Options After MCA
- 16 Top Career Options After CE
- Courses and Certifications
- 10 Best Job-Oriented Courses
- Best Online Computer Courses
- Top 15 Trending Online Courses
- Top 19 High Salary Certificate Courses
- 21 Best Programming Courses for Jobs
- What is SGPA? Convert to CGPA
- GPA to Percentage Calculator
- Highest Salary Engineering Stream
- 15 Top Career Options After Engineering
- 6 Top Career Options After BBA
- Job Market and Interview Preparation
- Why Should You Be Hired: 5 Answers
- Top 10 Future Career Options
- Top 15 Highest Paid IT Jobs India
- 5 Common Guesstimate Interview Q&A
- Average CEO Salary: Top Paid CEOs
- Career Options in Political Science
- Top 15 Highest Paying Non-IT Jobs
- Cover Letter Examples for Jobs
- Top 5 Highest Paying Freelance Jobs
- Top 10 Highest Paying Companies India
- Career Options and Paths After MBA
- 20 Best Careers After B.Com
- Career Options After MBA Marketing
- Top 14 Careers After MBA In HR
- Top 10 Highest Paying HR Jobs India
- How to Become an Investment Banker
- Career Options After MBA - High Paying
- Scope of MBA in Operations Management
- Best MBA for Working Professionals India
- MBA After BA - Is It Right For You?
- Best Online MBA Courses India
- MBA Project Ideas and Topics
- 11 Exciting MBA HR Project Ideas
- Top 15 MBA Project Ideas
- 18 Exciting MBA Marketing Projects
- MBA Project Ideas: Consumer Behavior
- What is Brand Management?
- What is Holistic Marketing?
- What is Green Marketing?
- Intro to Organizational Behavior Model
- Tech Skills Every MBA Should Learn
- Most Demanding Short Term Courses MBA
- MBA Salary, Resume, and Skills
- MBA Salary in India
- HR Salary in India
- Investment Banker Salary India
- MBA Resume Samples
- Sample SOP for MBA
- Sample SOP for Internship
- 7 Ways MBA Helps Your Career
- Must-have Skills in Sales Career
- 8 Skills MBA Helps You Improve
- Top 20+ SAP FICO Interview Q&A
- MBA Specializations and Comparative Guides
- Why MBA After B.Tech? 5 Reasons
- How to Answer 'Why MBA After Engineering?'
- Why MBA in Finance
- MBA After BSc: 10 Reasons
- Which MBA Specialization to choose?
- Top 10 MBA Specializations
- MBA vs Masters: Which to Choose?
- Benefits of MBA After CA
- 5 Steps to Management Consultant
- 37 Must-Read HR Interview Q&A
- Fundamentals and Theories of Management
- What is Management? Objectives & Functions
- Nature and Scope of Management
- Decision Making in Management
- Management Process: Definition & Functions
- Importance of Management
- What are Motivation Theories?
- Tools of Financial Statement Analysis
- Negotiation Skills: Definition & Benefits
- Career Development in HRM
- Top 20 Must-Have HRM Policies
- Project and Supply Chain Management
- Top 20 Project Management Case Studies
- 10 Innovative Supply Chain Projects
- Latest Management Project Topics
- 10 Project Management Project Ideas
- 6 Types of Supply Chain Models
- Top 10 Advantages of SCM
- Top 10 Supply Chain Books
- What is Project Description?
- Top 10 Project Management Companies
- Best Project Management Courses Online
- Salaries and Career Paths in Management
- Project Manager Salary in India
- Average Product Manager Salary India
- Supply Chain Management Salary India
- Salary After BBA in India
- PGDM Salary in India
- Top 7 Career Options in Management
- CSPO Certification Cost
- Why Choose Product Management?
- Product Management in Pharma
- Product Design in Operations Management
- Industry-Specific Management and Case Studies
- Amazon Business Case Study
- Service Delivery Manager Job
- Product Management Examples
- Product Management in Automobiles
- Product Management in Banking
- Sample SOP for Business Management
- Video Game Design Components
- Top 5 Business Courses India
- Free Management Online Course
- SCM Interview Q&A
- Fundamentals and Types of Law
- Acceptance in Contract Law
- Offer in Contract Law
- 9 Types of Evidence
- Types of Law in India
- Introduction to Contract Law
- Negotiable Instrument Act
- Corporate Tax Basics
- Intellectual Property Law
- Workmen Compensation Explained
- Lawyer vs Advocate Difference
- Law Education and Courses
- LLM Subjects & Syllabus
- Corporate Law Subjects
- LLM Course Duration
- Top 10 Online LLM Courses
- Online LLM Degree
- Step-by-Step Guide to Studying Law
- Top 5 Law Books to Read
- Why Legal Studies?
- Pursuing a Career in Law
- How to Become Lawyer in India
- Career Options and Salaries in Law
- Career Options in Law India
- Corporate Lawyer Salary India
- How To Become a Corporate Lawyer
- Career in Law: Starting, Salary
- Career Opportunities: Corporate Law
- Business Lawyer: Role & Salary Info
- Average Lawyer Salary India
- Top Career Options for Lawyers
- Types of Lawyers in India
- Steps to Become SC Lawyer in India
- Tutorials
- C Tutorials
- Recursion in C: Fibonacci Series
- Checking String Palindromes in C
- Prime Number Program in C
- Implementing Square Root in C
- Matrix Multiplication in C
- Understanding Double Data Type
- Factorial of a Number in C
- Structure of a C Program
- Building a Calculator Program in C
- Compiling C Programs on Linux
- Java Tutorials
- Handling String Input in Java
- Determining Even and Odd Numbers
- Prime Number Checker
- Sorting a String
- User-Defined Exceptions
- Understanding the Thread Life Cycle
- Swapping Two Numbers
- Using Final Classes
- Area of a Triangle
- Skills
- Software Engineering
- JavaScript
- Data Structure
- React.js
- Core Java
- Node.js
- Blockchain
- SQL
- Full stack development
- Devops
- NFT
- BigData
- Cyber Security
- Cloud Computing
- Database Design with MySQL
- Cryptocurrency
- Python
- Digital Marketings
- Advertising
- Influencer Marketing
- Search Engine Optimization
- Performance Marketing
- Search Engine Marketing
- Email Marketing
- Content Marketing
- Social Media Marketing
- Display Advertising
- Marketing Analytics
- Web Analytics
- Affiliate Marketing
- MBA
- MBA in Finance
- MBA in HR
- MBA in Marketing
- MBA in Business Analytics
- MBA in Operations Management
- MBA in International Business
- MBA in Information Technology
- MBA in Healthcare Management
- MBA In General Management
- MBA in Agriculture
- MBA in Supply Chain Management
- MBA in Entrepreneurship
- MBA in Project Management
- Management Program
- Consumer Behaviour
- Supply Chain Management
- Financial Analytics
- Introduction to Fintech
- Introduction to HR Analytics
- Fundamentals of Communication
- Art of Effective Communication
- Introduction to Research Methodology
- Mastering Sales Technique
- Business Communication
- Fundamentals of Journalism
- Economics Masterclass
Must Read 30 Selenium Interview Questions & Answers: Ultimate Guide 2024
Updated on 07 September, 2024
3.76K+ views
• 24 min read
Table of Contents
Introduction
Software testers and developers cannot live without Selenium, an open-source automated testing tool. They get the ability to effectively automate web applications, which helps them save time and effort. This article will give you five inspiring project ideas if you’re a newbie eager to get started with Selenium projects.
Are you attending an important interview and wondering what are all the Selenium interview questions you will go through?
We have created this most-read Selenium interview questions and answers guide to help you understand the depth of the questions and face it with confidence.
These days web apps are on the rise. With the growing need for web apps, there also is an inevitable requirement to test these web apps. That is where Selenium comes into action. Selenium is one of the commonly used automated testing tools which ensures the web app is working just right. If testing was to be done manually, it would utilize several man-hours and would increase the costing as well.
Further, since they are manual, they are prone to errors. Manual testing does not help in the long run, and so, automated testing like Selenium is gaining demand in the industry. If you are pursuing your career in automated testing, and have an upcoming interview in Selenium, this blog is meant for you.
In this blog, we shall discuss here the most common Selenium interview questions. These are for both – the beginners as well as Selenium interview questions for experienced.
Check out our free courses to get an edge over the competition.
Selenium Interview Questions & Answers 2022
Q.1) Why pick Selenium over other automated testing tools?
Selenium is open-source. It is very easy to adapt compared to other automated tools in the market. Due to this reason, many companies picked up Selenium automated testing over other traditional methods.
Refer to the key attributes of Selenium to understand its vast adaptability-
Key attribute | Description |
Open Source Platform | It is freeware and portable. There are no direct costs involved with Selenium. It can be downloaded for free and gets community-based support. |
Language Support | Supports various languages such as Java, Python, Ruby, C# and more. It has its script, but that is not a limitation, as programmers can work with any language. |
Browser support | There is a support across multiple browsers such as Chrome, Firefox,Internet Explorer, Opera and more. It becomes useful for programmers while testing. |
Operating Systems Support | It can be operated across multiple operating systems such as Windows, OS, Linux, etc. |
Device support | Supports tests across devices, as the test can be implemented on Android, iPhone and Blackberry. |
Reusability and add-ons | The programmers can use scripts that can be tested across multiple browsers. Multiple tests can be executed using Selenium, which covers almost all the aspects of functionality testing by implementing the add-on tools. |
Programming languages support | It can be integrated with various programming languages and frameworks, such as ANT, Maven, Jenkins, Hudson, and more. |
Q.2) List some benefits of Selenium over tools like TestComplete and QTP. Also, what are the disadvantages?
Selenium does not require a license, unlike TestComplete and QTP, being easy on pockets. The online community offers massive support. The release cycles are smaller, and the feedback is prompt compared to TestComplete and QTP. Further, Selenium works on Mac, Linux, and Windows as well.
On the contrary, Selenium requires a developer to have high coding skills. Whereas QTP and TestComplete require low to moderate level of coding skills, respectively.
Refer to the below-mentioned table to understand the advantages and disadvantages of Selenium-
Advantages | Disadvantages |
Open- source software | No reliable technical support. |
Supports various programming languages | Only support web- based applications. |
Supporys multiple operating systems (Android, iOS, etc.) | Takes more time test cases. |
Supports various browsers (Chrome, Firefox, Safar, Internet Explorer, etc.) | Difficult to setup Test Environments |
Supports Parallel Test Execution | Limited Image Testing Support |
Test cases can be implemented while the browser window is minimised. | No built- in reporting facility |
Faster than other tools. | No test tool integration for executing test management. |
Check out upGrad’s Advanced Certification in Blockchain
Q.3) What changes have occurred in the various Selenium version upgrades?
In the first version of Selenium, Selenium v1, it only comprised three suites of tools, which are Selenium IDE, RC, and Grid. The Webdriver was missing. It was only in the second version of Selenium, Selenium v2 that the Webdriver was introduced. Once this was done, Selenium RC was no longer in use.
You can find them in the market, but the support isn’t available. The next version of Selenium is Selenium v3. It consists of Webdriver, IDE, and the Grid. It is currently in use. A newer version, Selenium v4, is also now available.
Selenium IDE is mainly for recording and playing back. The Webdriver is for testing the dynamic web applications using a programming interface. The Grid is used for employing tests in remote host machines.
You must use the IDE for recording and playback of tests. A WebDriver is used for testing active web applications using a programming interface, and the Grid is employed for deploying tests in isolated host machines.
Refer to the below-mentioned table to understand the difference in various Selenium upgrades-
Selenium Version | Description |
Selenium 1 |
|
Selenium 2 |
|
Selenium 3 |
|
Check out upGrad: Full Stack Development Bootcamp (JS/MERN)
Explore our Popular Software Engineering Courses
Q.4) What are the various exceptions in Selenium WebDriver?
Just like any other programming language, you can find exceptions in Selenium as well. You can find the following exceptions in Selenium WebDriver:
TimeoutException: You get this exception when a command does not perform an action in the specified time.
NoSuchElementException: You get this exception when it cannot find an element with the given attributes on a web page.
ElementNotVisibleException: You get this exception when an element is available in the document object model, but it is not seen on the web page.
StaleElementException: You get this exception when an element is not attached to the document object model or is deleted.
NoAlertPresentException: It is a type of popup, which provides important for users.
NoSuchWindowException: It is a popup that occurs when the driver in the Selenium Program code is unable to find the pop-up window on the web page in order to switch.
SessionNotFoundException: When the driver is trying to perform operations on the web application after the browser is closed.
InvalidSelectorException: It is a sub class of NoSuchElementException class and occurs when a selector is incorrect or syntactically invalid.
ElementNotSelectableException: It indicates the presence of the web element but not its selectabiity.
Q.5) Explain Selenium exception test
The exception you expect to be thrown inside a test class is an exception test. If you write a test case intending it to throw an exception, you must use the @test annotation and also mention it in the parameters that which exception would be thrown. For instance,
@Test(expectedException = NoSuchElementException.class)
Q.6) Is there a need for an excel sheet in a project? Is yes, how?
Excel sheets are used as a data source during testing. Further, it also stores the data set while executing data-driven testing. When excel sheets are used as a data source, it can store:
Application URL: Developers can mention the environment URL under which the testing is executed. For example, testing environment, development environment, QA environment, production environment, or staging environment.
User name and password information: Excel sheets can keep safe the access credentials like the username of a password of various environments. Developers can encrypt and store these details for security reasons.
Test cases: Developers can make a table wherein one column write the test case name and the other which says to be executed or not.
If you are going to use excel sheets for DataDriven Test, you can easily store the information for various duplications to be executed during the tests. For instance, all the data that needs to be written in a text box for testing on a web page can be stored in the excel sheets.
It can be defined as the problem that occurs during the test execution. On the occurrence of the exception, the program stops and so does the codes. The codes will not get executed in this scenario.
There exists three types of execution in Selenium-
- Checked Exception- Handled during compile time. They cause compile problem if not handled at the right time.
- Unchecked Exception- A compiler does not mandate to handle.
- Error- Occurs when the scenario becomes fatal and unable to be recover.
upGrad’s Exclusive Software and Tech Webinar for you –
SAAS Business – What is So Different?
Q.7) What is POM? List its advantages?
POM stands for Page Object Model. It is a design pattern for creating an Object Repository for web UI elements. Every single web page in the application must have its own corresponding page class, which is in charge of searching the WebElements in that page and then execute operations on them.
POM in selenium acts as a design pattern that used in test automation creating a object repository for web UI elements. It assists in reducing the code duplication and improving test maintainence.
There should be a corresponding Page Class for each web page in the application. The Page Class faciliates in identifying the Web Elements of that particular web page. It also contains the Page methods that performs operations on the WebElements. This is how to explain how to explain pom in interview.
The advantages of using the Page object model are:
- It makes the code readable by letting developers separate operations and UI flows from verification.
- Several tests can use the same Object Repository because it is independent of Test Cases.
- The code becomes reusable.
This is how you can tackle pom in selenium interview questions. Now while answering, page object model in selenium interview questions you could also choose to mention the elements of POM. Some of the elements are listed below-
- Dependencies
- Resources
- Plugin tests
- Plugin configuration
- Developers and contributors
- Plugin executions with matching IDs
This is also how to explain page object model framework in interview. You can read the room, and add or deduct from your answers.
Q.8) What is a Page Factory?
Page Factory offers an enhanced method to execute the Page Object Model by efficiently using the memory, and the execution is done using object-oriented design.
POM Implementation | |
With Page Factory | Without Page Factory |
Uses By() | Uses @FindBy() |
No imports are required | Imports Page factory |
No cache storage | Cache lookup is faster |
Page Factory initializes the elements of the Page Object or instantiates the Page Objects itself. Annotations for elements can also be produced. It is, in fact, a better way as the describing properties may not be expressive enough to differentiate one object from another.
If POM is used without a page factory, instead of having to use ‘FindElements,’ @FindBy is used to look for WebElement, and initElements is used to initialize web elements from the Page Factory class.
@FindBy can accept attributes like tagName, name, partialLinkText , linkText, id, className , css, and xpath.
The Page Factory is a class provided by the Selenium Web Driver to implement the POM. The Page Object Repository is separated from the test methods with the help of Page Factory Concept.
Some of the other Page Factory annotations-
- @FindBys
- @Findall
- @CacheLookUp
In page object model interview questions, you can definitely expect a question of Page Factory. You may choose to make a slight mention of the Page Factory while responding to what is pom in selenium. Or during pom selenium interview questions, if the interviewer ask a separate question on Page Factory, you may get into depth of it to answer. As mentioned above. Moreover, during the POM interview questions, the interviewer could also twist their way of asking, instead of descriptive questions, they could also throw some MCQs your way, such as the design pattern called page object model mcq.
Q.9) How do you achieve synchronization in WebDriver? Or, tell us about the different types of wait statements Selenium Web Driver?
Synchronization in WebDriver should be achieved using WebDriver Wait. In case a specific element the programmer is working on takes time, then they should use WebDriver Wait.
You can find two wait statements in Selenium web driver, namely, Implicit Wait and Explicit Wait.
Implicit wait commands the WebDriver to wait for a little by polling the DOM. It is present for the complete life of the web driver instance, once the implicit wait is declared. The pre-set value is zero. If you set it more than zero, then the behavior will poll the DOM on a regular basis based on the driver implementation.
Explicit wait commands the execution to wait for a little till a condition is attained like:
- elementToBeClickable
- presenceOfElementLocated
- elementToBeSelected
Read: Spring Interview Questions & Answers
10) What is the use of JavaScriptExecutor?
You can execute JavaScript through Selenium Websriver using JavaScriptExecutor. It is an interface that offers this mechanism. It gives methods like “executescript” and “executeAsyncScript” to run JavaScript in the condition of the currently chosen frame or window. An example of that is:
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript(Script,Arguments);
It works as an interface which is used to execute JavaScript through Webdriver. The JavaScript Editor provides two methods, namely-
ExecuteScript
These methods are executed in the selected window or frame. This chosen script runs as an anonymous function. The script can return values, the returned data types are-
- Web Element
- List
- String
- Long
- Boolean
ExecuteAsyncScript
It is used to execute the asynchronous JavaScript in the current window or frame. It is executed as a single thread while the rest of page is continuously parsing.
Explore Our Software Development Free Courses
Q.11) Which function lets you scroll down a page using JavaScript in Selenium?
The function window.scrollBy() h
elps you scroll down the page using JavaScript in Selenium. For instance:
((JavascriptExecutor) driver).executeScript("window.scrollBy(0,500”)
Q.12) How do you handle mouse and keyboard actions using Selenium?
Special mouse and keyboard actions are handled using Advanced User Interactions API. It comprises of the Actions and the Action Classes that are required for performing these events. The most used mouse and keyboard events are given by Action class are:
dragAndDrop(): This event performs click-and-hold at the position of the source element, moves.
source, target(): Moves to the position of the target element and releases the mouse.
clickAndHold(): It clicks the current location of the mouse.
Q.13) What are various types of Selenium frameworks?
The various types of Selenium frameworks are:
- Keyword Driven Framework: In this framework, the operations and instructions are written in a separate file like Excel. It is based on keywords that forms the basis of functionality. It might need repetitive writing to perform some actions in case when the code has to cover a lot of functionality. That is why the operators or methods that are required to be performed are written separately from the script in form of keywords.
- Data-Driven Framework: In this framework, full test data is taken from some external source files like an XML, Excel, CSV, or some other database table. It is based on different datasets that ar ecraeted on externa files such as excel and are imported into the automation testing tool. These datasets are engineered to be kept separate from the original script, thus increasing the accuracy.
- Hybrid Framework: This framework is a blend of both the Keyword Driven framework and the Data-Driven framework. The framework uses different keywords and datasets.
Q.14) Name a few files that serve as a data source for various Selenium frameworks.
They can be an XML, Excel, CSV, or even a Text file.
Q.15) What is Selenese?
Selenese is the group of selenium commands to test a web application. Developers can use Assertions, Actions, and Accessors. Assertions are used as checkpoints. Actions are for running operations, and Accessors are used to store the value of a variable.
These Selenese commands are used to test web-applications. It can easily verify the presence of an element. There are three types of commands that Selenese uses, such as-
- Actions- These commands can change the condition of an application. For example, clicking of a checkbox, form submission, dropdown selection and so on. In case of non-performance, the test fails.
- Accessors- These commands verify the state of application. They also keep a track of application.
- Assertions- These commands are used to check the state of applications against the expected conditions.
Q.16) What is the major difference between a Page Factory and Page Object Model (POM)?
A common selenium interview question. A page factory is a method to initialize web elements within the page object on the creation of the instance. On the other hand, the page object model is a class that states the web page and holds its functionalities.
Q.17) Does Selenium support handling window pop-ups?
No. Selenium does not support handling pop-ups. An alert, which is a pop-up window, displays a warning message on the screen. You can achieve this by using a few methods like:
Void dismiss(): When the cancel button is clicked in the alert box, this method is called.
Void accept(): When the ‘OK’ button of the alert is clicked, this method is called.
String getText(): If you want to capture the alert message, you must call this method.
Void sendKeys(String stringToSed): If you want to send some information to the alert box, you must call this method.
Read: React Interview Questions & Answers
Q.18) Explain Robot class
A Robot class gives control over the keyboard and mouse devices.
The methods comprise:
- KeyPress(): Called on the event where you want to press a key.
- KeyRelease(): Called in the event to release the pressed key.
- MouseMove(): Called in the event when you have to move the mouse pointer in the X and Y coordinates.
- MousePress(): Called in the event when you press the left button of the mouse.
- MouseMove(): Called in the event of releasing the pressed button of the mouse.
The Robot Class is used to activate the automated testing for implementation of Java platform. The robot class is easy to implement and can be integrated with an automated framework.
Benefits of Robot Class-
- It can simulate the Keyboard and Mouse Event.
- Help in upload/ download of files using the Selenium web driver.
- Can easily be integrated with the current automation.
Q.19) How to handle many windows in Selenium?
The window handle is a special identifier that has the address of all the windows. It serves as a pointer to a window returning the value in the string.
- get.windowhandle(): It gets the current window handle.
- get.windowhandles(): Gets the handles of all the windows opened.
- switch to: Helps in switching across the windows.
- set: Sets the window handles, which is in the form of a string.
- action: helps to execute certain actions on the windows.
Q.20) What are Listeners?
The interface that changes the behavior of the system is called listeners in Selenium. They enable customizations of logs and reports. They are of two kinds: TestNG listeners and Webdriver listeners.
They have the ability to listen to any event like data entering, page navigation and so on.These are defined with the help of interface. T modifies the behavior of technology and also indulges in providing reports customisation and logs.
Types of listeners in TestNG are mentioned below-
- Configurable
- Hookable
- Reporter
- Suite Listener
- Annotation Transformer
In-Demand Software Development Skills
Q.21) Explain Assert and Verify commands
Assert: An assertion is used to differentiate between the real result and the expected result.
Verify: The test executions aren’t paused no matter if the verify condition is true or false.
Q.22) How does one navigate back and forth on a webpage?
It is one of the most common selenium interview questions.
You can use the below methods to navigate back and forth.
driver.navigate.forward
driver.manage.navigate
driver.manage.back
driver.navigate.to(“url”)
Q.23) How to send ALT/SHIFT/CONTROL key in Selenium WebDriver?
Typically using the keys like ALT, Shift, or Control, we combine them with other keys to activate a function. We cannot just click them alone. We need to define two methods for the purpose of holding onto these keys while the following keys are
pressed: keyUp(modifier_key) and keyDown(modifier_key)
Parameters: Modifier_key (keys.ALT or Keys.SHIFT or Keys.CONTROL)
Objective: The purpose is it performs a modifier keypress without releasing the modifier key. Following interactions may assume it’s kept pressed.
Parameters: Modifier_key (keys.ALT or Keys.SHIFT or Keys.CONTROL)
Objective: The purpose is it performs a key release.
So, with a mix of these two methods, we can capture the special function of a particular key.
Q.24) How do we take screenshots in Selenium WebDriver?
The TakeScreenshot function helps to take a screenshot in Selenium Webdriver. Further, you can save the screenshot taking by using getScreenshotAs() method.
File scrFile = ((TakeScreenshot)driver).getScreenshotAs(outputType.FILE);
Q. 25) Can we set the size of the browser window using Selenium? If yes, how?
Yes. If you wish to maximize the size of browser window, you need to use the code
driver.manage().window().maximize();
If you wish to resize the current window to a specific dimension, you must use the setSize() method. For instance:
System.out.println(driver.manage().window().getSize());
Dimension d = new Dimension(420,600);
driver.manage().window().setSize(d);
If you wish to set the window to a particular size, you must use window.resizeTo() method.
For instance:
((JavascriptExecutor)driver).executeScript("window.resizeTo(1024, 768);");
Q.26) How to select a value from the dropdown? How to handle a dropdown?
You most likely will be asked about a question about dropdown and selection of values as it is a little tricky and technical as well.
The most crucial detail you must know is that to work with a dropdown in Selenium, it is important to use of the html tag: ‘select’. You cannot handle dropdowns without using the select tag. Have a look at the code below:
<select id="mySelect">
<option value="option1">Cakes</option>
<option value="option2">Chocolates</option>
<option value="option3"> Candies</option>
</select>
In the above code, an HTML ‘select’ tag is used to define a dropdown element. The ID of the select tag here is myselect. We have given three options in the dropdown: Cakes, Chocolates, and Candies. You can see that each of these choices has an attached value attribute. For instance, for Cake, the value is Option1, for Chocolates its Option2, and for Candies, it is Option3.
To choose a value, you need to:
Identify the ‘select’ html element by using the findelement()
Example:
WebElement mySelectElement = driver.findElement(By.id("mySelect"));
Select dropdown = new Select(mySelectElement);
In the above code, an HTML ‘select’ tag is used to define a dropdown element. The ID of the select tag here is myselect. We have given three options in the dropdown: Cakes, Chocolates, and Candies. You can see that each of these choices has an attached value attribute. For instance, for Cake, the value is Option1, for Chocolates its Option2, and for Candies, it is Option3.
To choose a value, you need to:
Identify the ‘select’ html element by using the findelement()
Example:
WebElement mySelectElement = driver.findElement(By.id("mySelect"));
Select dropdown = new Select(mySelectElement);
Pick up an option from that dropdown element.
To pick an option from that dropdown, there are three ways:
dropdown.selectByVisibleText(“Chocolates”); → Choosing an option by the text that is seen.
dropdown.selectByIndex(“1”); → Choosing an option using the Index number of that option.
dropdown.selectByValue(“option2”); → Choosing an option using the value of that option.
Note that in all the cases, the option “Chocolates” is selected from the dropdown. Points 1 and 3 are obvious and point two; we say “1” because the indexing starts from zero.
Read: Top Nagios Interview Questions & Answers
Q.27) How do you hop to a new tab which opens up after you click on a link?
On clicking a link on a web page, you need to use the switchTo() command to change the focus of the Webdriver. Example: driver.switchTo().window();
where ‘windowName’ is the name of the window, you want to switch your focus to.
If you do not have the name of the window, you can use the driver.getWindowHandle() command to fetch the name of all the windows that were initiated by the WebDriver. Remember, it will never give you the names of those windows which Webdriver did not initiate.
On getting the name, you need to run through a loop to get to that window. Here is an example:
String handle= driver.getWindowHandle();
for (String handle : driver.getWindowHandles())
{
driver.switchTo().window(handle);
}
Q.28) How can one upload a file in Selenium WebDriver?
The command element.send_keys(file path) is used to upload a file in Selenium Webdriver. But before you that, you must use the html tag: ‘input’ where the attribute type should be ‘file’. Here is an example to understand it better:
<input type="file" name="my_uploaded_file" size="50" class="pole_plik">
element = driver.find_element_by_id(”my_uploaded_file")
element.send_keys("C:myfile.txt")
Q.29) What is the importance of testng.xml?
If you are interviewing for Selenium, you surely know the importance of testing. Selenium does not support the generation of the report as well as test case management. We, therefore, use the TestNG framework with Selenium. It is way advanced compared to Junit, and it is easier to implement annotations making TestNG framework the choice with Selenium Webdriver.
You can define the test suites and grouping of test classes in TestNG, by taking commands from the testing.xml file. It is represented in an XML file and not in a test suite within the testing source code because the suite is a feature of execution. A test suite is a group or collection of test cases.
The testng.xml file should contain the name of all the methods and classes that you wish to execute as a portion of that execution flow.
Some of the advantages of using testng.xml file are:
- It lets the execution of multiple test cases from multiple classes
- It lets the execution of test cases in groups, where a single test can belong to multiple groups.
- It lets parallel execution.
Q. 30) Explain DataProviders in TestNG. Is it possible to call a single data provider method for multiple functions and classes?
One of the advanced selenium interview questions. DataProvider is a feature of TestNG, enabling developers to write DataDriven tests. It supports DataDriven testing, meaning that the same test method can run multiple times with different data-sets. DataProvider is just a method of passing parameters to the test method.
@DataProvider is a method for providing data for a test method. The annotated method must give back an Object[] where each Object[] can be allocated to the parameter list of the test method.
Yes. It possible to call a single data provider method for multiple functions and classes. The same DataProvider can be used in several functions and classes by declaring DataProvider in a separate class and then using it again in multiple classes.
Q. 31) What are the features of TestNG?
- Before and after annotations
- XML based test configuration
- Multithreaded execution
- Open API
- Better reporting
- Data-Driven testing
- Dependent Groups.
- Dependent methods
Learn Online Software Development Courses online from the World’s top Universities. Earn Executive PG Programs, Advanced Certificate Programs or Masters Programs to fast-track your career.
Read our Popular Articles related to Software
Selenium Test Automation for E-commerce Websites
Objective: Create a Selenium topics test suite to automatically test the key features of an e-commerce website, such as user registration, login, product search, shopping cart, and checkout.
Description: The complexity of e-commerce websites and the possible influence on user experience necessitate thorough testing. Beginners can comprehend the difficulties of testing dynamic web pages, managing numerous user interactions, and validating e-commerce operations by developing a Selenium topics test automation suite.
Selenium Data-Driven Testing
Objective: Use Selenium topics to implement data-driven testing, which involves testing a web application using a variety of test data sets that are kept in databases, CSV files, or other external data sources.
Description: By running test cases with various data inputs, data-driven testing increases the effectiveness of test cases. This project proposal encourages reusability and maintainability by enabling beginners to explore multiple data sources, read and interpret data, and run tests dynamically.
Continuous Integration (CI) Tools and Selenium Integration
Objective: Integrate CircleCI, Travis CI, and Jenkins with Selenium topics test automation to provide automated testing for every code commit.
Description: Contemporary software development methodologies require continuous integration. This project gives novices practical experience using CI tools to automate the test execution process, resulting in quicker feedback and better software quality.
Selenium-based cross-browser testing
Objective: Selenium WebDriver enables the automation of test cases on browsers such as Internet Explorer, Firefox, Chrome, and Safari.
Description: Although they adhere to Open Web Standards, browser companies have their own interpretations of those standards. Thoroughly debugging a website’s source code does not guarantee that the site will appear and function as intended on various browsers (or various versions of a single browser), as they all render HTML, CSS, and JavaScript in different ways. With the aid of this project idea, beginners may manage browser-specific behaviors and effectively address compatibility issues.
Automated Selenium Testing for Mobile Apps
Objective: Create Selenium topics test scripts to automate the testing of mobile applications using either emulation or actual hardware.
Description: This project introduces newcomers to the problems of mobile test automation as the world relies more and more on mobile applications. It entails creating mobile testing environments, dealing with mobile gestures, and examining app functioning across several platforms.
Conclusion
Coming to the end of the Selenium interview questions and answers guide, we hope this helps you get your job. Selenium interview questions for experienced are more technical, but with fierce competition over jobs, it is always great to be prepared well for an interview.
If you are interested in learning Selenium, DevOps and everything about Full Stack development, check out IIIT-B & upGrad’s Executive PG Program in Full Stack Software Development Program.
Frequently Asked Questions (FAQs)
1. Which programming language is best for Selenium?
Selenium is one of the most popular portable open-source frameworks designed for the quality assurance of web-based applications. Generally, Selenese is the language used with Selenium, specific to this testing domain. But Selenium also supports the use of other languages for writing test automation scripts. Out of all others, Java and Python are the most preferred languages used with Selenium. Due to its ease-of-use and simple syntax, Python reduces program execution time with Selenium. Plus, with Python API, connecting to a browser becomes very easy. Java is extremely versatile and popular too, and with Selenium, it offers shorter execution times and efficient error handling.
2. Is Selenium tough to learn?
Selenium is not exactly difficult to learn, but it will take a shorter time to learn it with a properly planned study strategy and discipline. It can be an uphill task when you are learning Selenium entirely by yourself. But when you have the right study roadmap, you can learn the basics of Selenium within a month or so. But before learning Selenium, you need to have an excellent working knowledge of Java or Python and HTML concepts. Selenium with Java or Python is one of the hottest skill sets in demand today. You can find ample resources to learn these technologies and build a lucrative career.
3. What is the difference between QTP and Selenium?
Both Selenium and QTP are popular tools used for automation testing purposes. While QTP is used for automated functional testing of software applications, Selenium is used for the automated testing of web-based applications. QTP is a licensed tool and expensive, too; it comes with its own built-in repository of objects. QTP offers a higher rate of automation compared to Selenium. However, Selenium is an open-source platform and needs no licenses; users do not incur expenses for this tool. And this offers more flexibility in testing than QTP – it supports different programming languages. Selenium testing scripts can execute across different IDEs, unlike QTP.
4. What is the highest salary for Selenium Tester?
The highest salary for a Selenium Tester is 15.0 lakhs per annum.
5. What are the four components of Selenium?
The four components of Selenium are- Selenium IDE Selenium RC Selenium WebDriver Selenium Grid
6. What are the three major components of Selenium?
The three major components of Selenium include- Selenium WebDriver Selenium Testing Selenium Java
7. Which language is best for Selenium?
Java and Python are best for Selenium.
Did you find this article helpful?
Our Trending Courses 3
Master of Science in Computer Science Master of Design in User Experience DBA Doctorate in Technology (Computer Science)Our Trending Skill 16
Javascript Courses Node.js Courses Blockchain Courses SQL Courses Core Java Courses Full Stack Development Courses Big Data Courses DevOps Courses Data Structures Courses NFT Courses Cyber Security Courses React JS Courses Cloud Computing Courses Database Design Courses Python Courses Cryptocurrency CoursesGet Free Counsultation
By clicking "Submit" you Agree toupGrad's Terms & Conditions