Top 10 Selenium Interview Questions with answers (2021).

Author: neptune | 02nd-Apr-2023
#Selenium #Interview

What is the major difference between “assert” and “verify” cmd's in Selenium?

Both “assert” and “verify” commands check whether the given condition is true or false :

  • Assert: It stops the execution of the testing if the given condition is false else continue with the further tests.

 Example: assertEquals (expectedMessage, actualMessage);

  • Verify: It doesn’t stop the flow of execution irrespective of the condition being true or false. 

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

  • driver.close() It closes the currently active window on which the user is working.

  • driver.quit() It closes all the windows opened by the driver.

Note: Both the commands don’t take any parameter and don’t return any value either.




How can we create right-click and mouse hover actions in Selenium?

This code can replicate right-click action:

 Actions action = new Actions(driver);

 WebElement element = driver.findElement( By.id("elementId")); 

 action.contextClick( element).perform(); 

This code can replicate mouse hover action:

 Actions action = new Actions(driver);

 WebElement element = driver.findElement ( By.id("elementId"));

 action.moveToElement( element).perform();

Different types of Locating strategies in Selenium ?

Locating by ID:

driver.findElement(By.id("q"));

Location by Name:

driver.findElement(By.name("q"));

Location by Xpath:

driver.findElement( By.xpath("//input[@id==’neptune’]));

Locating Hyperlinks by Link Text:

driver.FindElement(By.LinkText ("edit this page")).Click();

Locating by ClassName:

driver.findElement( By.className("Header"));

Locating by TagName:

driver.findElement( By.tagName("select') ).click();

Locating by LinkText:

driver.findElement( By.linkText("NeptuneWorld") ).click();

Locating by PartialLinkText:

driverlindElement( By.partialLinkText("Neptune") ).click();




What is the Syntax for defining explicit and Implicit wait for 10 seconds ?

Explicit Wait :

WebDriverWait wait = new WebDriverWait(driver, 10);

WebElement messageElement = wait.until(

ExpectedConditions .presenceofElementLocated(

By.id(”loginToNeptuneworld")));

Implicit wait :

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

What are the different types of navigation commands ?

  1. driver.navigate().refresh(); - This method refreshes the current page.

  2. driver.navigate().to( "https://neptuneworld.in/"); - Navigates to the provided URL.

  3. driver.navigate().forward(); - This method does the same operation as clicking on the Forward Button of any browser. It neither accepts nor returns anything.

  4. driver.navigate().back(); - This method does the same operation as clicking on the Back Button of any browser. It neither accepts nor returns anything.

How to scroll down a page using JavaScript?

First, create a JavaScript object.

   JavascriptExecutor js = (JavascriptExecutor) driver;

Now, Scroll down to the desired location.

   js.executeScript( "window.scrollBy(0,1000)"); 

The window is scrolled vertically by 1000 pixels

Is there a way to type in a textbox without using sendKeys()?

Yes! Text can be entered into a textbox using JavaScriptExecutor

JavascriptExecutor js = (JavascriptExecutor) driver;

js.executeScript( "document.getElementById( ‘email').value=

[email protected]”);




How to select a value from a dropdown in Selenium WebDriver?

WebElement dp = driver.findElement( By.id("testingDropdown"));

Select dropdown = new Select(dp);

dropdown.selectByIndex(5);

or

dropdown.selectByValue(“Neptune”);

or

dropdown.selectByVisibleText(“Neptune World”);

How to upload a file in Selenium WebDriver? 

Browse button located:

  WebElement browseBtn = driver.findElement( By.id("uploadfile"));

Pass the path of the file to be uploaded using sendKeys methods:

browseBtn.sendKeys("D:\\neptune.txt");

I Hope you got something from this article !!

If you have something in mind, Write in the comment section.

Thanks for Reading!! 




anonymous | Sept. 8, 2021, 11:42 a.m.

Add more questions 👍


anonymous | Aug. 18, 2021, 7:20 a.m.

Really good Questions.



Related Blogs
Automate Ticket Booking in SpiceJet from Delhi to Bengaluru using Selenium and Cucumber.
Author: neptune | 08th-Aug-2023
#Selenium
We are going to automate a ticket booking using Selenium WebDriver and Cucumber BDD...

Where you applied OOPs in Automation Testing?
Author: neptune | 28th-Aug-2023
#Interview #Java
You may face this question Where you have applied OOPs concept in Automation Framework? in almost all the Selenium Interviews. Let's learn OOP’s concept in Java before going further...

Selenium, Cucumber, JUnit, TestNG dependencies for Selenium project.
Author: neptune | 02nd-Apr-2023
#Selenium #Testing
We guide you how to update the pom.xml file for Selenium Maven project...

5 Selenium Project Ideas & for Beginners in Automation Testing
Author: neptune | 30th-Mar-2023
#Selenium #Testing #Projects
In this article, we will discuss 5 interesting Selenium project ideas for beginners in automation testing...

How to use wait commands in Selenium WebDriver in Java ?
Author: neptune | 22nd-Feb-2022
#Selenium #Testing #Java
We are going to explore different types of waits in Selenium WebDriver. Implicit wait, Explicit wait, and Fluent wait with examples...

Top 50+ Selenium Interviews Questions 2023 based on Years of Experience
Author: neptune | 02nd-Apr-2023
#Selenium #Testing #Interview
Every interview difficulty is based on how many years of experience you have in that field. For the Selenium Automation Tester I have divided the question on the number of years of experience...

Mostly asked Python Interview Questions - 2023.
Author: neptune | 30th-May-2023
#Python #Interview
Python interview questions for freshers. These questions asked in 2022 Python interviews...

Core Python Syllabus for Interviews
Author: neptune | 26th-Jul-2023
#Python #Interview
STRING MANIPULATION : Introduction to Python String, Accessing Individual Elements, String Operators, String Slices, String Functions and Methods...

How to create Selenium Cucumber Project in Eclipse.
Author: neptune | 25th-May-2022
#Selenium
First, divide the process into the various steps to understand working in brief of a project. Steps in brief: We’ll start with initializing the browser driver and then log in to the web page...

30+ SQL Interview Questions
Author: neptune | 05th-Jan-2023
#Interview #SQL
Data Definition Language (DDL) – It allows end-users to CREATE, ALTER, and DELETE database objects...

How to create a Selenium, Cucumber Automation project in Eclipse ?
Author: neptune | 02nd-Apr-2023
#Selenium #Testing
Problem Statement : Let’s consider this particular project where we will try automating the process of booking a flight ticket. Let’s get started and see how it’s done using Selenium...

Challenges faced in automating Web Applications using Selenium
Author: neptune | 02nd-Oct-2022
#Selenium #Testing
List of Challenges faced by testers using Selenium 1. Popup and Alert Handling, 2. Dynamic element Handling 3. Restricted to only Desktop Browsers Testing...

20 TestNG Interview Questions
Author: neptune | 17th-Dec-2022
#Selenium #Interview
There is always more than one test or method in the class. If we do not prioritize these tests or methods, then the methods are selected alphabetically and executed while execution...

Getting started with Selenium WebDriver.
Author: neptune | 02nd-Apr-2023
#Selenium #Testing
In this blog I will give you an overview of Selenium WebDriver and Also discuss about advantages and disadvantages of Selenium WebDriver...

Why we use Robot Class in Automation Testing?
Author: neptune | 23rd-Aug-2022
#Selenium
Robot class is used to generate native system input events for the purpose of automation testing. It is used to perform mouse and keyboard events on windows applications or popups...

Top 10 Selenium Interview Questions.
Author: neptune | 02nd-Apr-2023
#Selenium #Interview
Locator is a command that tells Selenium IDE which GUI elements (like Text Box, Buttons, Check Boxes etc) we are going to use or perform some automation task...

How to send POST request using Rest Assured framework in Java ?
Author: neptune | 26th-Mar-2023
#Selenium #API
Rest Assured is a popular Java-based framework that is used for testing RESTful web services. It provides a simple and intuitive API for sending HTTP requests and validating the responses...

Black Mirror Season 6: A Glimpse into the Future of Technology and Society
Author: neptune | 27th-Apr-2023
#Interview
Black Mirror Season 6, starring Salma Hayek and Aaron Paul, promises more violence and thought-provoking explorations of technology and society...

Top 20+ Appium Interview Questions and Answers (2023)
Author: neptune | 30th-May-2023
#Interview
This article provides a comprehensive list of 20 common interview questions on Appium mobile automation, covering various topics and providing solutions for each question...

The Key to QA Success: Understanding How Important Grooming Is?
Author: neptune | 19th-Sep-2023
#Testing #Interview
We will delve into the importance of grooming & ceremony for QA testers, key points to highlight their significance...

Skills Required for Full-Stack Developer at IBM Onsite, CA
Author: neptune | 25th-Feb-2024
#Interview #Jobs
The company's commitment to pushing the boundaries of what is possible necessitates a team of skilled professionals...

View More