• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

SoftwareTestingo - Jira Selenium Protractor Testing SDLC Agile Methodology

Java Selenium Tutorial & Testing Interview Questions

  • Home
  • Interview Questions
  • Java
  • Java Programs
  • Test Cases
  • Selenium
  • Manual Testing
  • Difference
  • Search
SoftwareTestingo » Interview Questions » Selenium Real Time Interview Questions

Selenium Real Time Interview Questions

Last Updated on: February 24, 2021 By Softwaretestingo Editorial Board

What We Are Learn On This Post

  • ☒ Automation ☒
  • Manual:
  • Selenium Real Time Interview Questions
  • 130 Selenium Interview Question & Answer Updated
  • Generic Selenium Questions
  • Selenium IDE Questions
  • 130 Selenium Interview Question

Technical and Non Technical Questions I have faced in the Interviews(Capgemini, CTS, L&T, Tech Mahindra, Hyundai, IDP Education, ADP, HCL, Standard Chartered, and Fidelity):

  • Write code for Action class
  • Write code for positive and negative scenarios for Alerts
  • Write code for handling multiple windows
  • Find odd number
  • Disadvantages of Selenium
  • Difference between get() and navigate().to()
  • Write code to click on the Check box which is inside the Dynamic Table
  • Write code for taking Screenshot
  • Explains Maps in Java
  • Explain framework (Questions based on your framework explanation)
  • What is Pom.xml
  • Which is the correct Xpath for this code (Lot of questions on Xpath)
  • Xpath methods Ex: Starts-with & Contains
  • The syntax for the CSS selector
  • How to identify dynamic images
  • From a given string, separate characters, integers, and special characters and store in a separate variable and print them
  • Remove duplicates from ArrayList
  • Print all the frame names
  • How to read from XML or CSV file and store in hashmap
  • Get the value of a cell in the Dynamic table
  • What is the Burndown chart (Agile)
  • Print these characters from a given string and change them to uppercase
  • Explain Access specifiers
  • Difference between Priority and Severity
  • Example for High Priority and Low Severity and vice versa
  • Difference between Test Strategy and Test Scenario
  • What Software Metrics you have used in your project
  • How to handle Dynamic Elements, since the webpage is designed in Angular Js
  • Implicit and Explicit Waits
  • Write code for Cross Browser Testing
  • Explain Method Overloading and Method Overriding with Example
  • What is Static Keyword
  • Dependencies in Pom.xml
  • Write code for fetching data from Excel
  • Select this value in the dropdown and hover to this element and click
  • Assert and Verify
  • Check if a given string is Palindrome or not
  • Remove duplicate characters from a string and print
  • Which Code Repository you are using (Ex: GitHub)
  • How will you estimate the time to automate a scenario?
  • How to perform Right Click
  • In a Dynamic Table, if I give 1 cell value, it should give me the values of other cells in that row
  • Have you Developed any Tool, If yes explain
  • Write code for handling Frames
  • Read from a text file and store it in HashMap
  • Print the occurrence of each character if it is present more than once in a given string
  • Write code for nested drop-down, You have to check all the values in the dropdown, All permutation, and combination
  • Advantages of Selenium
  • How to check if a checkbox is displayed
  • If the element is not present, how will you print the Element that is not present in the message?
  • What all exceptions you have faced
  • What all difficulties you have faced in Selenium
  • What all TestNG Annotations you have used in the project
  • Where will you maintain the code?
  • What all Collections, you have used in your project
  • How to run multiple test cases
  • What are Primitive and Non-primitive Data Types?
  • What are JDK, JRE, and JVM
  • Settings.xml in Maven
  • Eliminate first and last string from array and print
  • What is Encapsulation
  • What is the use of build() and perform() in Actions
  • How you will check the actual vs expected result
  • Xpath Axes, Ex: Following
  • Automate Menu and Sub Menu and click on a link in Sub Menu and navigate to the page and click on an element
  • Syntax for Alerts
  • How will you generate Reports?
  • What is the execution time of your test cases?
  • Print a Reverse Pyramid
  • Go to frame and click on the upload button and select the file which is in this directory
  • Difference between PUTS and POST in API
  • Read data from Excel and given that data as input for login and password and click on submit and validate the popup which says Login is successful
  • Read data from two text files and compare if they are the same or not
  • Read data from an Excel file and compare the data to the web table and check whether it is the same or not
  • Select multiple options from the dropdown
  • Explain Defect Lifecycle
  • How many people are working on your project, what all teams are there
  • What is your role in your project?
  • How often Daily Triage Call will happen and what will be discussed
  • What all packages you have used in your project
  • How will you check Broken Links?
  • Read from a text file and change that content
  • Write test scenario for Credit Cards
  • How to read Properties file
  • Which is the latest Java version and which one you have used and what are the features of that version
  • Check if the given two strings are an anagram
  • What is the difference between Interface and Abstract Methods?
  • Difference between BeforeSuite and BeforeMethod
  • Difference between Default and Protected
  • Write a program to divide without using division or modulus symbol
  • String = ‘AaBbCcDD’ ,In that change a lowercase ‘a’ to uppercase
  • Hierarchy of TestNg Annotations
  • How many Sprints you have worked on, how often you will get Sprints
  • How Agile Methodology works
  • Do Exceptions have priority?
  • Can a try block have more than 1 catch block?
  • Can a class be Public, Private, Protected, and Default
  • How will you compare the data from the database to the data on the webpage?
  • Blackbox vs Whitebox Testing
  • Explain Waterfall Methodology
  • What is Traceability Matrix
  • Explain STLC
  • Explain SDLC
  • What is a class
  • What is an object
  • What is a variable
  • How to clone one list and store it in a new list
  • How to run a group of test cases in TestNg
  • How to include or exclude test case in TestNg
  • How to run the parallel test case in TestNg
  • What is Selenium Grid
  • Can a Map have a Null value?
  • What all different test annotations you have used in TestNg
  • How to switch frame in Selenium
  • Difference between this and super
  • Difference between Constructor and Method
  • Difference between String Buffer and String Builder
  • Difference between List and Set
  • How to run a test suite in different browsers
  • What is static and final
  • Difference between String and String Builder
  • How to run failed test cases in TestNg
  • Difference between Iterator and ListIterator
  • How to set the proxy in Jenkins
  • Explain Maven Life Cycle
  • Explain POM
  • What will be there in POM.xml
  • Without using Select statement, how to select dropdown
  • Difference between Sanity and Smoke Testing
  • Can the Main Method be overridden?
  • What is Retrospective Meeting?
  • What all methods String has?

☒ Automation ☒

  • What are XPath and its types?
  • What are cross-browser testing and parallel testing?
  • Challenges faced during selenium testing?
  • What is the Actions class?
  • How to handle drop-down in selenium?
  • How to handle multiple browser pop up?
  • How to handle multiple browser tabs in selenium?
  • How to perform upload files using selenium?
  • How to perform download files using selenium?
  • How to get all values of dropdown in selenium?
  • How to perform (control + a) through selenium?
  • How to shift between tabs of the same browser using selenium?
  • What is a Robot class?
  • What is AutoIT?
  • What is the difference between get() and navigate()?
  • What are the difference between findElement() and findElements()?
  • What is difference between quit() and close()?
  • What are different locators used?
  • Difference between XPath and CSS selector?
  • Different approaches to click the submit button?
  • What is javascriptExecutor and when it is used?
  • Handling WebTable(static and dynamic) in selenium
  • What is POM? Advantage and its disadvantage?
  • What is a maven? list its phases or life cycle? Command to run our project through the maven?
  • Explain ur project folder structure? Or Explain ur framework?
  • What is TestNG?
  • How to create and delete cookies?
  • What does getwindowhandles() and getwindowhandle() return? Or its differences?
  • Is it possible to use only perform() without build()? 30.What is perform() and build()?
  • How to scroll the browser window?
  • Preceding sibling and following sibling of custom XPath?
  • What is the test management tool used in ur project?
  • What is the build automation tool used in ur project?
  • How u will handle the SSL certification?
  • What are DesiredCapabilities?
  • How to verify ‘Bangalore’ present in the dropdown box or not?
  • How to verify ‘Bangalore’ present in 4×4 webtable? And print the column and row number of it is present?
  • How to fetch the data from a particular row and column of excel?
  • List all maven plugins like surefire plugin etc
  • What is Jenkins? And explain its use?
  • Explain the tags present in the testng.xml file
  • What is TDD?
  • What is BDD? Explain the cucumber framework? What are gherkins?
  • What is Listener?
  • What is DataProvider?
  • What is parameterization?
  • What is PageFactory?
  • What is Apache POI API? Or how to read data from excel?
  • What are explicit and implicit waits?
  • What are the challenges faced in automation testing?
  • Write code for handling multiple browsers and switch to new windows?
  • What is webdriver? And why webdriver is used?
  • List some selenium exceptions
  • What is StaleElementReferenceException?When this occurs? And how to overcome such exceptions?
  • How do you group the test cases? And why?
  • How to include or exclude test cases?
  • What is NullPointerException?When it occurs?
  • What is a selenium grid?
  • Should have knowledge of all TestNG annotations.
  • How do you control the execution of your test cases/test classes?
  • Git and its commands
  • Maven commands to execute, debug, compile
  • What is the current version of maven used?
  • How to identify broken links? How have done you in your project? Write code or tell approach.
  • Write a code to fetch the value ‘Test’ from the excel sheet which might be present in any cell in excel. Or check whether the value ‘Test’ is present in excel or not.
  • How to pass values to textbox other than using sendKeys()?
  • How to click the login button other than using click(), submit(), and JavascriptExecutor?
  • What is subversion?

Manual:

  • What are test design techniques? Explain BVA and ECP with some examples?
  • Explain STLC
  • Explain Bug Life Cycle
  • What is the difference between bug and defect?
  • What are severity and priority?
  • Explain SDLC
  • What are the differences between smoke and sanity testing?

Selenium Real Time Interview Questions

What are the Selenium Tools, and Testing framework that you are using in your Current Project?
Ans: We are using,

  • Selenium WebDriver for Creating Test Cases.
  • Java Programming for Enhancing Test cases.
  • TestNG Testing Framework for Grouping Test cases, executing Test batches, and generating Test reports. Also used,
  • Firebug and Firepath for inspecting elements.
  • IE Browser driver, Chrome browser driver for Cross Browser testing.

What is your Project Operating environment?
Ans: Microsoft Windows 8.1

What is your project domain and Application Environment?
Ans: Our project is Banking Application, Our AUT (Application Under Test) developed using Java Technology and the Database is Oracle.

What are the major challenges in Functional Test Automation?
Ans:

  • Object Identification.
  • Debugging Issues. etc…

What are the difficulties that you faced in Object identification?
Ans: Some Elements (Objects) not recognized properly using Selenium WebDriver Element locators.

How you conducted Data-driven Testing in your project?
Ans: We conducted Data-driven Testing using an external Excel file as Resource, we added some third-party excel jar files to Java Project in Eclipse.

Read Also: QA Interview Questions

How you conducted Batch Testing in your project?
Ans: We conducted Batch Testing using TestNG Testing Framework.

How you conducted Cross-browser testing in your project?
Ans: Using Mozilla Firefox, IE, and Google Chrome browsers(Downloaded IE and Google Chrome Browser drivers). we executed Test cases.

How you handled duplicate Elements in your project?
Ans: Using the index property of Elements we handled duplicate objects.

How many Test cases you wrote for your Project/Module?
Ans: I prepared around 120 Test cases in my Module.

How many defects you detected and give one example?
Ans: I detected nearly 20 Defects in which 5 defects are Severe defects.

How you selected Test cases for Regression Testing?
Ans: We selected Test cases for Regression Testing based on Defect affected Test cases and from defect dependent Test cases.

How you organized your Test Automation resources?

Did you use any build management tool in your project?
Ans: We used the Maven build management tool in our project.

How you handled errors in your Test scripts?
Ans: We handled errors in our Test Scripts using Java Error handling features.

Did you create any reusable components?
Ans: Yes, We created some reusable components in our project for Login Functionality, Registration Functionality, etc.

Check Also: Social Interview Questions

Did you find any Test Scenarios that not to be automated in your project using Selenium?
Ans: Yes, We find some Some Test Scenarios in our Current project, Functionalities that require more user interaction, Functionalities that require Dynamic test data submission.

How to execute multiple Java programs at a time?
Ans: We execute multiple Java programs using an XML file in the TestNG framework.

How to conduct parallel Test execution?
Ans: Usually We conduct Parallel Test Execution using Selenium Grid, but no parallel test execution in my Current project.

What Defect management / Test management tool you used in your project?
Ans: We are using the Jira Test Management tool in our project with Selenium.

How you communicated with the development team to resolve the issues.
Ans: We communicate Development team via Our Test Manager.

Did you involve in the Selenium Test environment Setup?
Ans: Yes, I involved in Selenium Environment Setup in my Current Project. As per my project, we selected Java, Selenium WebDriver and TestNG Framework, and Maven.

  • We Downloaded Eclipse IDE and Extracted it.
  • Downloaded Java Software and Installed.
  • Environment Variable path setup.
  • Downloaded Selenium WebDriver Java language bindings(jar files) and added them to Java Project in Eclipse.
  • Downloaded and Installed TestNG Framework from Eclipse IDE.
  • Installed Maven build management tool.

130 Selenium Interview Question & Answer Updated

Well, As Software QA Testers Are Searching Online To Get the Latest Interview Question and Answer Which Are Commonly Ask In The Interviews. So I Am Sure, this doc is not going to help you crack that interview, but I know there are many interviewers out there who want to know the answer to one-liner Selenium interview questions. You could use this questionnaire as a resource to tests your Selenium skills once you have gained enough knowledge in the Selenium suite of tools. Most of the questions are derived from the SeleniumHQ Doc and the Google wiki of the Selenium project.

Generic Selenium Questions

What is Selenium?
Answer: Selenium is a browser automation tool that lets you automate operations like – Type, Click, and Selection from a drop-down of a web page.

How is Selenium different from commercial browser automation tools?
Answer: Selenium is a library that is available in Various languages, i.e. Java, C#, Python, Ruby, PHP, etc. while most commercial tools are limited in their capabilities of being able to use just one language. Moreover, many of those tools have their language, which is of little use outside the domain of those tools. Most commercial tools focus on record and replay while Selenium emphasis using Selenium IDE (Selenium record and replay) tool ONLY to get acquainted with Selenium working and then move on to other Selenium libraries like Remote control [RC] (Selenium 1.0) and Web Driver (Selenium 2.0). Though most commercial tools have built-in capabilities of test reporting, error recovery mechanisms and Selenium does not provide any such features by default. But given the rich set of languages available with Selenium, it very easy to emulate such features.

What is the set of tools available with Selenium?
Answer: Selenium has mainly four sets of tools – Selenium IDE, Selenium 1.0 (Selenium RC), Selenium 2.0 (WebDriver), and Selenium Grid.

Which Selenium Tool should I use?
Answer: It entirely boils down to where you stand today in terms of using Selenium. If you are altogether new to Selenium, then you should begin with Selenium IDE to learn Selenium location strategies and then move to Selenium 2 as it is the most stable Selenium library and future of Selenium. Use Selenium Grid when you want to distribute
your test across multiple devices. If you are already using Selenium 1.0 then you should begin to migrate your
test scripts to Selenium 2.0

Check Also: Common 50 Selenium Interview Questions

What is Selenium IDE?
Answer: Selenium IDE is a Firefox plugin which is used to record and replay test in firefox browser. Selenium IDE can be used only with the Firefox browser.

Which language is used in Selenium IDE?
Answer: Selenium IDE uses an HTML sort of language called Selenese. Though other languages (java, c#, PHP, etc.) cannot be used with Selenium IDE, Selenium IDE lets you convert test in these languages so that they could be used
with Selenium 1.0 or Selenium 2.0

What is Selenium 1.0?
Answer: Selenium 1.0 or Selenium Remote Control (popularly known as Selenium RC) is a library available in a wide variety of languages. The primary reason for the advent of Selenium RC was the incapability of Selenium IDE to execute tests
in a browser other than Selenium IDE and the programmatical limitations of language Selenese used in Selenium
IDE.

What is Selenium 2.0?
Answer: Selenium 2.0, also known as WebDriver, is the latest offering of Selenium. It provides

  • Better API than Selenium 1.0
  • Does not suffer from javascript security restriction which Selenium 1.0 does
  • Supports more UI complicated UI operations like drag and drop

What are the element locators available with Selenium, which could be used to locate elements on a web page?
Answer: There are mainly 4 locators used with Selenium

  • Html ID
  • Html Name
  • Html Tagname
  • Html Class Name
  • XPath locator
  • CSS locators
  • Link Text
  • Partial Link Text

What is Selenium Grid?
Answer: Selenium grid lets you distribute your tests on multiple machines and all of them at the same time. Hence you can execute tests on IE on Windows and Safari on Mac machine using the same test script (well, almost always).
This greatly helps in reducing the time of test execution and provides quick feedback to stack holders.

Selenium IDE Questions

What are the two modes of views in Selenium IDE?
Answer:  Selenium IDE can be opened either in sidebar (View > Sidebar > Selenium IDE) or as a pop up window (Tools > Selenium IDE). While using Selenium IDE in the browser sidebar, it cannot record user operations in a pop-up
the window opened by an application.

Can I control the speed and pause test execution in Selenium IDE?
Answer: Selenium IDE provides a slider with Slow and Fast pointers to control the speed of execution.

Where do I see the results of Test Execution in Selenium IDE?
Answer: The result of test execution can be viewed in a log window in Selenium IDE

Where do I see the description of commands used in Selenium IDE?
Answer: Commands of description can be seen in the Reference section

Can I build a test suite using Selenium IDE?
Answer: Yes, you can first record individual test cases and then group all of them in a test suite. Following this entire test suite could be executed instead of executing individual tests.

What verification points are available with Selenium?
Answer: There are largely three types of verification points available with Selenium

  • Check for the page title
  • Check for certain text
  • Check for the certain element (text box, drop-down, table, etc.)

I see two types of the check with Selenium – verification, an assertion, what’s the difference between the two?
Answer: A verification check lets test execution continue even in the wake of failure with a check, while assertion stops the test execution. Consider an example of checking the text on a page, and you may like to use the verification point and let test execution continue even if a text is not present. But for a login page, you would like to add an assertion for the presence of text box login as it does not make sense to continue with test execution if the login text box is not present.

Read Also: Einfochips Selenium Automation Interview Questions

I don’t see checkpoints added to my tests while using Selenium IDE, how do I get them added to my tests?
Answer: You need to use the context menu to add checkpoints to your Selenium IDE tests.

How do I edit tests in Selenium IDE?
Answer:  There are two ways to edit tests in Selenium IDE; one is the table view while others are looking into the source code of recorded commands.

What is the syntax of the command used in Selenium?
Answer: There are three entities associated with a command

  • Name of Command
  • Element Locator (also known as Target)
  • Value (required when using echo, wait, etc.)

There are tons of Selenium Command, am I going to use all of them?
Answer: This entirely boils down to operations you are carrying out with Selenium. Though you would be using the following Selenium Commands more often

  • Open: opens a web page.
  • Click/clickAndWait: click on an element and waits for a new page to load.
  • Select: Selects a value from a drop-down value.
  • VerifyTitle/assertTitle: verifies/asserts page title.
  • Verify/assert ElementPresent: verifies/asserts presence of element, in the page.
  • Verify/assert TextPresent:  verifies/asserts expected text is somewhere on the page.

How do I use HTML id and name while using Selenium IDE?
Answer: Html id and name can be used as it is in selenium IDE. For example, the Google search box has a name – “q” and id  “listb,” and they can be used as a target in Selenium IDE

What is XPath? When would I have to use XPath in Selenium IDE?
Answer: XPath is a way to navigate in an XML document, and this can be used to identify elements in a web page. You may have to use XPath when there is no name/is associated with the element on the page, or only a partial part of name/ide is
constant.

  • The direct child is denoted with /
  • The relative child is denoted with //
  • Id, class, names can also be used with XPath –
    · //input[@name=’q’]
    · //input[@id=’lstib’]
    · //input[@class=’ lst’]
  • If only part of id/name/class is constant then “contains” can be used as –
    · //input[contains(@id,’lstib’)]

What is the CSS location strategy in Selenium?
Answer:  CSS location strategy can be used with Selenium to locate elements, it works using cascade style sheet location methods in which Direct child is denoted with – (space) Relative child is denoted with > Id, class, names can also be used with XPath –
· css=input[name=’q’]
· css=input[id=’lstib’]
or input#lstib
· css=input[class=’ lst’] or input.lst
If only part of id/name/class is constant then “contains” can be used as –
· css=input[id*=’ lstib
‘)]
Element location strategy using inner text
· CSS = a:contains(‘log out’)

There is an id, name, XPath, CSS locator, which one should I use?
Answer: If there are constant names/IDs available, then they should be used instead of XPath and CSS locators. If not, then CSS locators should be given preference as their evaluation is faster than XPath in most modern browsers.

I want to generate random numbers, dates as my test data, how do I do this in Selenium IDE?
Answer: This can be achieved by executing javascript in Selenium. Javascript can be executed using the following syntax –
type
css=input#s
javascript{Math.random()}
And for a date –
type
css=input#s
javascript{new Date()}

Can I store the result of an evaluation and use it later in my test?
Answer: You can use the “store” command to achieve this. You can save the result of an evaluation in a variable and use it later in your Selenium IDE script. For example, we can store a value from a text box as following and later use it to
type it in another text box –
storeText
css=input#s
var1
type
css=input#d
${var1}

I have stored the result of an evaluation; can I print it in IDE to check its value?
Answer: You can use the echo command as following to check the stored value in Selenium IDE –
storeText
css=input#s
var1
echo
${var1}

Can I handle a javascript alert using Selenium?
Answer: You could use verify/assertAlert to check the presence of an alert on the page. Since selenium cannot click on the “Ok” button on the js alert window, the alert itself does not appear on the page when this check is carried out.

Selenium has recorded my test using XPath, how do I change them to CSS locator?
Answer: You can use the drop-down available next to Find in Selenium to change the element locator used by Selenium

I have written my element locator, how do I test it?
Answer: You can use the Find button of Selenium IDE to test your locator. Once you click on it, you would see element being highlighted on the screen provided your element locator is right Else one error message would be displayed in the log
window.

I have written one js extension; can I plug it in Selenium and use it?
Answer: You could specify a js extension in the “Options” window of Selenium IDE –

How do I convert my Selenium IDE tests from Selenese to another language?
Answer: You could use the Format option of Selenium IDE to convert tests in another programming language –

I have converted my Selenium IDE tests to java, but I am not able to execute them, execution options, as well as the Table tab of Selenium IDE, is disabled
Answer: This is because Selenium IDE does not support the execution of the test in any other language than Selenese
(the language of Selenium IDE). You can convert Selenium IDE in a language of your choice and then use
Selenium 1.0 to execute these tests in that language.

I want to use only Selenese as my test script language but still want to execute tests in other browsers, how do I do that?
Answer: You can execute your Selenese test in another browser by specifying the “htmlSuite” followed by the path of your
Selenese suite while starting the Selenium Server. Selenium Server would be covered in detail in question
about Selenium RC.

I have added one command in the middle of the list of commands, how do I test only this new command?
Answer: You can double click on the newly added command, and Selenium IDE would execute only that command in
browser.

Can I make Selenium IDE tests begin test execution from a certain command and not from the very first command?
Answer: You could set a command as a “start” command from the context menu. When a command is set as a start command, then a small green symbol appears before the command. The same context menu can be used to toggle this option

Are there other tools available outside Selenium IDE to help me tests my element locators
Answer:  You could XPath checker https://addons.mozilla.org/enUS/firefox/addon/xpathchecker/ to test your XPath
locators and Firefinder (a Firebug add-on) to test you, CSS locators. Firefinder can also be used to test XPath locators.

What is an upcoming advancement in Selenium IDE?
Answer: The latest advancement in Selenium IDE would be to have capabilities of converting Selenium IDE tests in
Webdriver (Selenium 2.0) options. This would help to generate quick and dirty tests for Selenium 2.0

How can I use the looping option (flow control) is Selenium IDE
Answer: Selenese does not provide support for looping, but there is an extension that could be used to achieve the same.

Can I use a screen coordinate while using the click command? I want to click on a specific part of my element.
Answer: You would need to use the clickAT command to achieve. the clickAt command accepts element locator and x, y
coordinates as arguments – clickAt(locator, coordString)

How do I verify the presence of drop-down options using Selenium?
Answer: Use assertSelectOptions as following to check options in a drop-down list.

Can I get data from a specific HTML table cell using Selenium IDE?
Answer: Use the storeTable command to get data from a specific cell in an HTML table, following example store text from cell 0,4 from an HTML table
storeTable
css=#tableId.0.4
textFromCell

I want to make a Selenium IDE record and display CSS locator followed by other locators, is it possible to give high priority to CSS locator in Selenium IDE?
Answer: You can change the default behavior of Selenium IDE > element locator preference by creating a js file with the following– LocatorBuilders.order = [‘css: name’, ‘CSS: id’, ‘id’, ‘link’, ‘name’, ‘XPath: attributes’]; And add this file under “Selenium IDE Extension” under Selenium Options.

My application has dynamic alerts which don’t always appear, how do I handle them?
Answer: If you want to simulate clicking “ok “ on alert than use – chooseOkOnNextConfirmation and if you want to simulate clicking “cancel” on the alert then use Selenium RC (Selenium 1.0) Questions

Can I right-click on a locator?
Answer: You can use command contextMenu ( locator) to simulate a right-click on an element on a web page.

How do I capture a screenshot of a page using Selenium IDE?
Answer: Use the command – captureEntirePageScreenshot to take the screenshot of the page.

I want to pause my test execution after a certain command.
Answer: Use pause command which takes time in milliseconds and would pause test execution for a specified time –
pause ( waitTime )

I used the open command to launch my page, but I encountered a timeout error?
Answer: This happens because open commands wait for only 30 seconds for the page to load. If your application takes
more than 30 sec, then you can use “setTimeout ( timeout )” to make selenium IDE wait for a specified time before proceeding with test execution.

What’s the difference between type and typeKeys commands?
Answer: type command simulates enter operations at one go while typeKeys simulates keystroke key by key.
typeKeys could use when typing data in the text box, which brings options (like Google suggestion list) because
such an operation is not usually simulated using type command.

130 Selenium Interview Question

Difference Between Assertion and Verification?
Answer:
Verify command will not stop the execution of the test case if verification fails. It will log an error and proceed with the execution of the rest of the test case. We use verify commands in Selenium IDE when we still want to proceed with the execution of the test case even if the expected output is not matched for a test step.

Assert command will stop the execution of the test case if verification fails. It will log an error and will not proceed with the execution of the rest of the test case. We use assertions in scenarios where there is no point proceeding further if the expected output is not matched.

It’s pretty simple. Use assertions when you want to stop the execution of a test case if the expected output is not matched and use verification when you still want to proceed execution of a test case if the expected output is not matched.

The difference between Set, List, and Map?
Set (Interface)

  • Set is an unordered collection that doesn’t allow duplicate (no duplicate) elements
  • We can iterate the values by calling the iterator() method
    Set s = new HashSet();
    Iterator iter = s.iterator();

List (Interface)

  • The list is an ordered collection that allows duplicate elements
  • We can iterate the values by calling the iterator() method
    List li = new ArrayList();
    Iterator iter = li.iterator();

Map (Interface)

  • In Map, we used to store the data in key and value pairs, we may have duplicate values but no duplicate keys
  • In Map we don’t have iterator() method, but we can get the keys by calling the method keySet()
    Map m; // insert values
    Set s = m.keySet();
    // Get Map keys into the Set and then iterate this Set object normally
    // m.keySet() returns Set object with Map keys
    Iterator iter = s.iterator();

How to Create a Parameterized Test in JUnit Testing Framework?
Answer:
In this example, we are going to see how to create a parameterized test in the JUnit testing framework.

Create the Java class to be tested
Answer:
Create a folder named JUnitParameterized. This is the folder where your classes will be located. Using a text editor, create a Java class named Addition.java. To make sure your file name is Addition.java, (not Addition.java.txt), first choose “Save as > Save as type > All files,” then type in the file name Addition.java.

Addition.java

public class Addition 
{ 
public int addNumbers(int a, int b)
{
 int sum = a + b; 
 return sum; 
 }
}

2. Create a JUnit test case
In the same directory (JUnitParameterized), use a text editor and create a java class named JunitAdditionTest.java with the following code.

What are the types of Assertions in JUnit?
Answer:
Assertions:

JUnit provides overloaded assertion methods for all primitive types and Objects and arrays (of primitives or Objects). The parameter order is the expected value, followed by an actual value. Optionally the first parameter can be a String message that is output on failure. There is a slightly different assertion, assertThat that has parameters of the optional failure message, the actual value, and a Matcher object. Note that expected and actual are reversed compared to the other assert methods.

Examples: A representative of each assert method is shown below.

import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.junit.Assert.assertThat;
import static org.junit.matchers.JUnitMatchers.both;
import static org.junit.matchers.JUnitMatchers.containsString;
import static org.junit.matchers.JUnitMatchers.everyItem;
import static org.junit.matchers.JUnitMatchers.hasItems;
import java.util.Arrays;
import org.hamcrest.core.CombinableMatcher;
import org.junit.Test;

What is New in TestNG? and Difference Between TestNG and JUNIT?
Answer:
TestNG is a testing framework inspired by JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use, such as:

  • Annotations.
  • Flexible test configuration.
  • Support for data-driven testing (with @DataProvider).
  • Support for parameters.
  • Allows distribution of tests on slave machines.
  • Powerful execution model (no more TestSuite).
  • It is supported by a variety of tools and plug-ins (Eclipse, IDEA, Maven, etc…).
  • Dependent methods for application server testing.

If you want to learn TestNG, you can download it and see its documentation at “http://testng.org/doc/index.html.” TestNG is extensively used in Selenium Automation and Code testing instead of Junit due to its advantages over it. Using TestNG Selenium automation becomes simplified, and also the Parallel execution using Selenium Grid becomes easy.

    Filed Under: Interview Questions

    Reader Interactions

    Comments

    1. kiran says

      July 19, 2019 at 11:29 AM

      hi this is kiran ,
      interview questions of very helpful for interview
      but answers are in short, please can you elaborate to 4 to 5 lines
      then we could get clarity on answers

      Reply
    2. Dileep says

      October 11, 2019 at 1:20 PM

      how you integrate grid in your project?
      how to do parallel test cases?
      asked about framework?
      about sorting 0’s oneside and 1’s one side write a programme for this?
      webdriver driver = new firefoxdriver() explain it?
      why the above one not firefoxdriver driver = newfirefoxdriver() this ?
      tell me about oops concept?
      about over loading and how to overload?
      overriding?
      about encapsulation?
      write a code for dropdown without using select keyword?
      login page code using JS?
      Difference b/n String And StringBuffer?
      About abstraction?
      given an array and told to write a palindrome?
      reverse a string?
      What are the exceptions you faced?
      how you know whether element is present or not , excluding isdisplayed(), is enabled()?
      without index and value how to select dropdown value?
      About waits?
      Wht is meant by fluent wait and where you used?
      what is meant by collections?

      these questions asked in Paytm , amadeous, Cgi for 3+ candidates, hope these will help you

      Reply
      • Ishan says

        May 20, 2020 at 9:58 AM

        Thank you it helped a lot….

        Reply
    3. Navya says

      March 7, 2020 at 8:56 PM

      Thanks for Sharing!!!. Its helpful.
      Navya Rao

      Reply

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    Primary Sidebar

    Join SoftwareTestingo Telegram Group

    Tutorials Important Links

    • Software Testing Jobs
    • Manual Testing Tutorial
    • Selenium Tutorial
    • Core Java Tutorial
    • TestNG Tutorial
    • Java Programs
    • Selenium Programs
    • Manual Test Cases
    • Interview Tips
    • Contact US
    • www.softwaretestingo.com

    Important Links

    • Software Testing Interview Questions
    • Agile Interview Questions
    • Manual Testing Interview Questions
    • Testing Interview Questions
    • Selenium Interview Questions
    • Selenium Real Time Interview Questions
    • Selenium WebDriver Interview Questions
    • Automation Framework Interview Questions
    • Appium Interview Questions
    • TestNG Interview Questions
    • Java Interview Questions
    • Core Java Interview Questions

    Categories

    Copyright © 2021 SoftwareTestingo.com ~ Contact Us ~ Sitemap ~ Privacy Policy