Monday, January 30, 2023

Selenium Webdriver Automation Interview Questions

Don't Miss

Have You Created Any Framework

Selenium Interview Questions & Answers – Latest (2020) – Part -1

If you are a beginner:You can say No, I didnt get a chance to create a framework from the scratch. I have used the framework which is already available. My contribution is mostly in creating test cases by using the existing framework.

If you are a beginner but have good knowledge of creating framework: You can say Yes, I have involved in developing framework along with other automation testers in my company.

If you are an experienced tester:You can say I have contributed to developing framework. or You can say Yes, I have created a framework from the scratch. There was no automation process in my previous company. I designed the framework from the scratch.

Ques64 How To Handle The Https Website In Selenium Or How To Accept The Ssl Untrusted Connection

Ans. Using profiles, we can handle accept the SSL untrusted connection certificate. Profiles are basically a set of user preferences stored in a file.

FirefoxProfile profile = new FirefoxProfile profile.setAcceptUntrustedCertificates  profile.setAssumeUntrustedCertificateIssuer WebDriver driver = new FirefoxDriver  

Why Selenium Rc Is Used

Selenium IDE does not directly support many functions like condition statements, Iteration, logging and reporting of test results, unexpected error handling and so on as IDE supports only HTML language. To handle such issues Selenium RC is used it supports the language like Perl, Ruby, Python, PHP using these languages we can write the program to achieve the IDE issues.

Don’t Miss: How To Record An Interview For A Podcast

Can Captcha Be Automated

No, Selenium cannot automate Captcha. Well, the whole concept of Captcha is to ensure that bots and automated programs dont access sensitive information – which is why, Selenium cannot automate it. The automation test engineer has to manually type the captcha while other fields can be filled automatically.

Explain Seleniums Components In Detail

Selenium Webdriver Interview Questions for Test Engineers

Although labeled as an automation testing tool, Selenium isnt a standalone tool. Instead, it is a package of several tools, and thus a testing suite. The Selenium suite has the following components:

  • Selenium IDE: Distributed as a Firefox plugin, Selenium IDE serves as a record and playback tool
  • Selenium Grid: Allows distributing test execution across multiple platforms and environments concurrently
  • Selenium RC: A server that allows users to create test scripts in a desirable programming language. Selenium RC also permits executing test scripts across a diverse range of web browsers.
  • Selenium WebDriver: Communicated directly with the web browser in addition to using its native compatibility to automate

Don’t Miss: How To Get More Interviews

How Many Parameters Can Selenium Commands Have At Minimum

There are four parameters that you have to pass in Selenium are

Host: It is the parameter which we use to bind Selenium to a specific IP. Usually, we run selenium tests on our local machine so the value will be localhost. You can sepcify IP address instead of localhost.

java -jar < selenium server standalone jar name> -host < Your IP Address>

Port Number: TCP/IP port which is used to connect selenium tests to the selenium grid hub. Default port hub is 4444.java -jar < selenium server standalone jar name> -role hub -port 4444

Make sure no other application in your system is using this port. You may face an exception like Exception in thread main java.net.BindException: Selenium is already running on port 4444. Or some other service is.

If this occurs you can either shutdown the other process that is using port 4444, or you can tell Selenium-Grid to use a different port for its hub. Use the -port option for changing the port used by the hub.

java -jar < selenium server standalone jar name> -role hub -port 4441

Browser: To pass the browser which has to execute our selenium scripts

URL: To pass the application URL

What Types Of Wait Are Available In Selenium Webdriver

A: There are two types of wait in Selenium WebDriver:

1.Implicit Wait: Provides a specific user defined time span during which the test execution is stopped before an element is found in each test conducted throughout the entire program.

2.Explicit wait: Causes execution to be stopped till a custom defined condition is met for a specific instance only.

You May Like: What Are Some Interview Questions For Medical Assistants

What Are The Different Kinds Of Frameworks

  • Data-driven framework:

The test data of this kind is generated from external files like excel, CSV, XML, etc. The data relating to the test cases rely outside on the input and verification values maintained using the variables.

  • Keyword-driven framework:

The data tables and the keywords are developed independently of the automation test cases. In this framework, the functionality of the test scenarios is documented in the table step by step.

  • Module-based testing framework:

Isolated and Logical modules are made out of the application that is under test. Independent test scripts are written for each module. These scripts are then clubbed together as a whole.

  • Behaviour driven testing framework:

The test scripts are written in such a way that the automation is done on the functionality or features to ensure the readability, understanding, and reliability to either the business experts or developers, or other testers.

  • Hybrid testing framework:

The combination of more than one of the above-mentioned frameworks by leveraging the benefits of each is called a Hybrid testing framework.

What Is Selenium Ide

Selenium Interview Questions and Answers

Selenium IDE is implemented as Firefox extension which provides record and playback functionality on test scripts. It allows testers to export recorded scripts in many languages like HTML, Java, Ruby, RSpec, Python, C#, JUnit and TestNG.

Selenium IDE has limited scope, and the generated test scripts are not very robust, and portable.

Also Check: How Should I Answer Interview Questions

Uplevel Your Next Tech Interview Prep

If you’re looking for guidance on how to prepare for a software engineer interview, then .

Interview Kickstart offers interview preparation courses taught by FAANG tech leads and seasoned hiring managers. We have trained thousands of software engineers to crack the toughest interviews at Google, Facebook, Amazon, Apple, Netflix, and other top tech companies.

What Are The Various Types Of Drivers And Waits Available In Webdriver

WebDriver provides support for the following drivers:

There are two types of waits available in WebDriver:

  • Implicit Wait: Used for providing a default waiting time between each successive test step or command across the entire test script. Hence, the next test step or command will only execute when the set default waiting time, say 30 seconds, have passed since the execution completion of the previous test step or command. It can be applied to a particular instance or several instances.
  • Explicit Wait: Used for halting the execution until the occurrence of a particular condition or till the elapsing of the maximum time. Applied for a particular instance only.

Also Check: Interview Questions For Accounting Assistant

Ques13 How Can We Locate An Element By Only Partially Matching The Value Of Its Attributes In Xpath

Ans. Using contains method we can locate an element by partially matching its attributes value. This is particularly helpful in scenarios where the attributes have dynamic values with a certain constant part.

xPath expression = //*

Basically, the above statement will match all the values of the name attribute containing the word user in them.

What Are The Different Ways Of Locating A Web Element In Selenium

Selenium WebDriver question &  Answer

In Selenium, web elements are identified and located with the help of Locators. Locators specify a target location which uniquely defines the web element in the context of a web application. Thus, to identify web elements accurately and precisely we have different types of locators in Selenium:

  • iPhoneSimulatorDriver
  • RemoteWebDriver

Recommended Reading: What Do You Need For Tsa Precheck Interview

What Is The Difference Between Setspeed And Sleep Methods

Both will delay the speed of execution.

Thread.sleep  :

It will stop the current thread for the specified period of time. Its done only once

  • It takes a single argument in integer format

Ex: thread.sleep- It will wait for 2 seconds

  • It waits only once at the command given at sleep
SetSpeed  :

For specific amount of time it will stop the execution for every selenium command.

  • It takes a single argument in integer format

Ex: selenium.setSpeed- It will wait for 2 seconds

  • Runs each command after setSpeed delay by the number of milliseconds mentioned in set Speed

This command is useful for demonstration purpose or if you are using a slow web application

What Is The Use Of @listener Annotation In Testng

Ans. TestNG listeners are used to configure reports and logging. One of the most widely used listeners in TestNG is ITestListener interface. It has methods like onTestStart, onTestSuccess, onTestFailure, onTestSkipped etc. We should implement this interface creating a listener class of our own. Next, we should add the listeners annotation in the Class which was created.

Also Check: How To Interview At Amazon

Why Should Selenium Be Selected As A Testing Tool For Web Applications Or Systems

Selenium provides the following advantages, which make it an excellent automated testing framework:

  • It is free and open-source software with a large user base and supports providing community.
  • It has cross-browser compatibility and supports multiple browsers like Google Chrome, Mozilla Firefox, Internet Explorer, Edge, Opera, Safari, etc.
  • It supports multiple operating systems such as Windows, Linux, macOS, etc.
  • It facilitates the usage of multiple programming languages including Scala, Ruby, Python, PHP, Perl, Java, Groovy, C#, etc.
  • It provides support for distributed testing as well.

Mention Why To Choose Python Over Java In Selenium

Part1-Selenium with Java Tutorial | Practical Interview Questions and Answers | Selenium WebDriver

Few points that favor Python over Java to use with Selenium is,

  • Java programs tend to run slower compared to Python programs.
  • Java uses traditional braces to start and ends blocks, while Python uses indentation.
  • Java employs static typing, while Python is dynamically typed.
  • Python is simpler and more compact compared to Java.

Recommended Reading: What To Email After An Interview

What Is The Major Difference Between / And // In Xpath

  • Single Slash/: It is used to create Xpath with an absolute path that is Xpath would be created to start selection from document node/start node.
/html/body/div/div/div/a
  • Double Slash “//”: It is used to create Xpath with a relative path that is Xpath would be created to create start selection from anywhere within the document
//div/a

Ques61 How Can We Handle Window Ui Elements And Window Pop Ups Using Selenium

Ans. Selenium is used for automating web-based applications only. If we want to handle window GUI elements then we can use tools like AutoIT. AutoIT is a freeware used for automating window GUI. The AutoIt scripts follow simple BASIC language like syntax. Also, it can be easily integrated with Selenium tests.

Recommended Reading: How To Prepare For Zoom Interview

Why And How Will You Use An Excel Sheet In Your Project

The reason we use Excel sheets is because it can be used as data source for tests. An excel sheet can also be used to store the data set while performing DataDriven Testing. These are the two main reasons for using Excel sheets.

When you use the excel sheet as data source, you can store the following:

  • Application URL for all environments: You can specify the URL of the environment in which you want to do the testing like: development environment or testing environment or QA environment or staging environment or production/ pre-production environment.

  • User name and password credentials of different environments: You can store the access credentials of the different applications/ environments in the excel sheet. You can store them in encoded format and whenever you want to use them, you can decode them instead of leaving it plain and unprotected.

  • Test cases to be executed: You can list down the entire set of test cases in a column and in the next column, you can specify either Yes or No which indicates if you want that particular test case to be executed or ignored.

When you use the excel sheet for DataDriven Test, you can store the data for different iterations to be performed in the tests. For example while testing a web page, the different sets of input data that needs to be passed to the test box can be stored in the excel sheet.

What Is Object Repository How Can We Create Object Repository In Selenium

Writing test case in Selenium WebDriver with simple example
  • Object Repository is a term used to refer to the collection of web elements belonging to Application under Test along with their locator values.
  • Thus, whenever the element is required within the script, the locator value can be populated from the Object Repository.
  • Object Repository is used to store locators in a centralized location instead of hard coding them within the scripts.
  • In Selenium, objects can be stored in an excel sheet which can be populated inside the script whenever required.

Recommended Reading: What Type Of Leader Are You Interview Question

What Are Testng Annotations Frequently Used With Selenium

TestNG annotations prioritize the calling of a test method over others. Here are the ones to use with Selenium:

  • @BeforeSuite to run before all tests
  • @AfterSuite to run only once after all tests
  • @BeforeClass to run only once before the first test method
  • @AfterClass to run only once after all the test methods of the current class finish execution
  • @BeforeTest to run before any test method inside the Test tag
  • @AfterTest to run after any test method inside the Test tag

What Is Same Origin Policy How You Can Avoid Same Origin Policy

The Same Origin Policy is introduced for security reason, and it ensures that content of your site will never be accessible by a script from another site. As per the policy, any code loaded within the browser can only operate within that websites domain.

To avoid Same Origin Policy proxy injection method is used, in proxy injection mode the Selenium Server acts as a client configured HTTP proxy , which sits between the browser and application under test and then masks the AUT under a fictional URL

Also Check: How To Do Podcast Interviews Remotely

What Are The Challenges And Limitations Of Selenium Webdriver

As we all know Selenium WebDriver is a tool that automates the browser to mimic real user actions on the web. Selenium is a free open source testing tool. Some of the challenges with Selenium WebDriver are as follows

  • We cannot test the windows application
  • We cannot test mobile apps
  • Limited reporting
  • Read the detailed explanation on the challenges and limitations of Selenium WebDriver

    Write A Code To Wait For A Particular Element To Be Visible On A Page Write A Code To Wait For An Alert To Appear

    Selenium Interview Questions and Answers | Selenium Interview Preparation | Edureka

    We can write a code such that we specify the XPath of the web element that needs to be visible on the page and then ask the WebDriver to wait for a specified time. Look at the sample piece of code below:

    WebDriverWait wait=new WebDriverWait Element = wait.until)) 

    Similarly, we can write another piece of code asking the WebDriver to wait until an error appears like this:

    WebDriverWait wait=new WebDriverWait Element = wait.until) 

    Don’t Miss: Spring Boot Interview Questions For 10 Years Experience

    Basic Java Interview Questions For Selenium

    The following Java coding interview questions for automation developers will help you stand out in the coding interview rounds.

  • Given an array, write a program in Java to find out the first two max values from an array?
  • Find the longest substring from a given string that doesn’t contain any duplicate characters.
  • What code would you use to filter duplicate elements from an array and print them as a list?
  • Write code in Java to sort the list of strings using Java collection?
  • Write a function in Java to reverse a given number.
  • Write a method in Java to check a prime number.
  • Write a code in Java to remove multiple spaces from a string.
  • Write a program in Java to identify a number as Palindrome.
  • What Are The Different Types Of Wait Statements In Selenium Webdriver Or The Question Can Be Framed Like This: How Do You Achieve Synchronization In Webdriver

    There are basically two types of wait statements: Implicit Wait and Explicit Wait.

    Implicit wait instructs the WebDriver to wait for some time by polling the DOM. Once you have declared implicit wait, it will be available for the entire life of the WebDriver instance. By default, the value will be 0. If you set a longer default, then the behavior will poll the DOM on a periodic basis depending on the browser/ driver implementation.

    Explicit wait instructs the execution to wait for some time until some condition is achieved. Some of those conditions to be attained are:

    • elementToBeClickable
    • elementToBeSelected
    • presenceOfElementLocated

    Recommended Reading: How To Ace Data Science Interview

    What Are The Different Types Of Waits Available In Webdriver

    There are two types of waits available in WebDriver:

    • Implicit Wait: Implicit waits are used to provide a default waiting time between each consecutive test step/command across the entire test script. Thus, subsequent test step would only execute when the 30 seconds have elapsed after executing the previous test step/command.
    • Explicit Wait: Explicit waits are used to halt the execution till the time a particular condition is met or the maximum time has elapsed. Unlike Implicit waits, explicit waits are applied for a particular instance only.
    • User can use sendKeys to enter the string in the textbox.

    Syntax:

    How Can You Redirect Browsing From A Browser Through Some Proxy

    Selenium Webdriver Interview Questions in Folsom ...

    Selenium provides a PROXY class to redirect browsing from a proxy. Look at the example below:

    String PROXY = & ldquo 199.201.125.147:8080& rdquo org.openqa.selenium.Proxy proxy = new.org.openqa.selenium.Proxy proxy.setHTTPProxy .setFtpProxy .setSslProxyDesiredCapabilities cap = new DesiredCapabilities cap.setCapability WebDriver driver = new FirefoxDriver 

    Don’t Miss: How To Have A Perfect Interview

    What Is Staleelementreferenceexception And How Do You Handle It

    Stale means old and no longer new. A stale element means an old element. Any element present on the webpage is considered as a web element in Web Driver. If the document object model changes, then the web element goes stale. If we try to connect with any element that is staled, then StaleElementReferenceException is thrown.

    The reasons for StaleElementReferenceException thrown are, one is a web element deleted entirely and the next id element no longer attached to DOM.

    To handle StaleElementReferenceException, follow the below-mentioned ways:

    • Solution 1: Refresh the page and try again for the same element

    Sample code to overcome the issue:

    driver.navigate.refresh driver.findElement).click 
    • Solution 2: Use try-catch block within for loop, if the element is not found in DOM.
    // Using for loop, it tries for 4 times.// If the element is located for the first time then it breaks from the for loop nad comeout of the loopfor  catch}
    • Solution 3: Wait for element till it gets available

    wait.until)) 

    Use ExpectedConditions.refreshed to avoid StaleElementReferenceException and retrieve the element again. This element updates the element by redrawing it accessing the referenced element.

    wait.until)) 
    • Solution 4: Handle StaleElementElement Exception by POM.

    More articles

    Popular Articles