+91 90691 39140 | +1 253 214 3115 | info@hub4tech.com | hub4tech

Selenium Interview Questions

These Selenium Interview Questions and answers have been designed for beginner and professional. Here you can find the answers of various interview questions related to Selenium.

What is Selenium and what is composed of?

Selenium is a suite of tools for automated web testing. It is composed of

  • Selenium IDE (Integrated Development Environment) : It is a tool for recording and playing back. It is a firefox plug-in
  • Web Driver and RC: It provide the APIs for a variety of languages like Java, .NET, PHP, etc. With most of the browsers Web driver and RC works.
  • Grid: With the help of Grid you can distribute tests on multiple machines so that test can be run parallel which helps in cutting down the time required for running in browser test suites
What are the Components of Selenium ?
  • Selenium IDE
  • Selenium Remote Control
  • Selenium Grid
Why and When To Automate?
  • Frequent regression testing
  • Repeated test case Execution is required
  • User Acceptance Tests
  • Faster Feedback to the developers
  • Reduce the Human Effort
  • Test same application on multiple environments
How will you find an element using Selenium?

In Selenium every object or control in a web page is referred as an elements, there are different ways to find an element in a web page they are

  • ID
  • Name
  • Tag
  • Attribute
  • CSS
  • Link text
  • PartialLink Text
  • Xpath etc
What are the Features of Selenium IDE ?
  • Record and playback
  • Intelligent field selection will use IDs, names, or XPath as needed
  • Auto complete for all common Selenium commands
  • Walk through test cases and test suites.
  • Debug and set breakpoints
  • Save tests as HTML, Ruby scripts, or other formats
  • Support for Selenium user-extensions.js file
  • Option to automatically assert the title of every page
  • Rollup common commands
Explain what is assertion in Selenium and what are the types of assertion?

Assertion is used as a verification point. It verifies that the state of the application conforms to what is expected. The types of assertion are “assert” , “verify” and “waif For”.

Selenium Interview Questions

Mention what is the use of X-path?

X-Path is used to find the WebElement in web pages. It is also useful in identifying the dynamic elements.

Explain the difference between single and double slash in X-path?

Single slash ‘/ ’

  • Single slash ( / ) start selection from the document node
  • It allows you to create ‘absolute’ path expressions

Double Slash ‘// ’

  • Double slash ( // ) start selection matching anywhere in the document
  • It enables to create ‘relative’ path expressions
What are the Selenese Commands in Selenium ?
  • clicking a link - click or clickAndWait commands
  • entering values - type command
  • selecting options from a drop-down listbox - select command
  • clicking checkboxes or radio buttons - click command
What is Test Runner ?

Test Runner allows you to run the test case in a browser loaded with the Selenium-Core Test Runner. Test runner is invoked by clicking the below Shown button in the IDE.

What is the difference between verify and assert commands?

Assert: Assert allows to check whether an element is on the page or not. The test will stop on the step failed, if the asserted element is not available. In other words, the test will terminated at the point where check fails.
Verify: Verify command will check whether the element is on the page, if it is not then the test will carry on executing. In verification, all the commands are going to run guaranteed even if any of test fails.

What is JUnit Annotations and what are different types of annotations which are useful ?

In JAVA a special form of syntactic meta-data can be added to Java source code, this is know as Annotations. Variables, parameters, packages, methods and classes are annotated some of the JUnit annotations which can be useful are

  • Test
  • Before
  • After
  • Ignore
  • Before Class
  • After Class
  • Run With
What is JUnit Annotations and what are different types of annotations which are useful ?

In JAVA a special form of syntactic meta-data can be added to Java source code, this is know as Annotations. Variables, parameters, packages, methods and classes are annotated some of the JUnit annotations which can be useful are

  • Test
  • Before
  • After
  • Ignore
  • Before Class
  • After Class
  • Run With
What are the four parameter you have to pass in Selenium?

Four parameters that you have to pass in Selenium are

  • Host
  • Port Number
  • Browser
  • URL
What is the difference between setSpeed() and sleep() methods?

Both will delay the speed of execution.
Thread. Sleep () : It will stop the current (java) thread for the specified period of time. It’s done only once

  • It takes a single argument in integer format
    Ex: thread.sleep(2000)- 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.

Explain Selenium WaitFor Commands ?
  • waitForPageToLoad : This command will make the script to wait till the page loads.Syntax is waitForPageToLoad(timeout); Time out is the maximum time the script will wait for the page to load.
  • waitForAlert : This command will wait for the alert message to appear
  • waitForTable: This command will wait for the Web table to completely load in the page
  • waitForTitle: This command will for the page Title to appear on the browser.
  • Other waitFor commands : Selenium has several other wait command like waitForText,waitForPopup and so on. These commands are generically called Synchronization commands
How you can use “submit” a form using Selenium ?

You can use “submit” method on element to submit form-
element.submit () ;
Alternatively you can use click method on the element which does form submission

What are the features of TestNG and list some of the functionality in TestNG which makes it more effective?

TestNG is a testing framework based on JUnit and NUnit to simplify a broad range of testing needs, from unit testing to integration testing. And the functionality which makes it efficient testing framework are

  • Support for annotations
  • Support for data-driven testing
  • Flexible test configuration
  • Ability to re-execute failed test cases
Explain what are the JUnits annotation linked with Selenium?

The JUnits annotation linked with Selenium are

  • @Before public void method() –It will perform the method () before each test, this method can prepare the test
  • @Test public void method() – Annotations @Test identifies that this method is a test method environment
  • @After public void method()- To execute a method before this annotation is used, test method must start with test@Before
Explain what is Datadriven framework and Keyword driven?

Datadriven framework: In this framework, the test data is separated and kept outside the Test Scripts, while test case logic resides in Test Scripts. Test data is read from the external files ( Excel Files) and are loaded into the variables inside the Test Script. Variables are used for both for input values and for verification values.

Which attribute you should consider throughout the script in frame for “if no frame Id as well as no frame name”?

You can use…..driver.findElements(By.xpath(“//iframe”))….
This will return list of frames.
You will ned to switch to each and every frame and search for locator which we want.
Then break the loop

Mention what is the difference between Implicit wait and Explicit wait?

Implicit Wait: Sets a timeout for all successive Web Element searches. For the specified amount of time it will try looking for element again and again before throwing a NoSuchElementException. It waits for elements to show up.
Explicit Wait : It is a one-timer, used for a particular search.

What tests can selenium do?

Selenium could do functional, regression, and load of web based applications.

What is the selenium’s recording language?

Selenium’s recording language is “HTML”.

What is WebDriver?

WebDriver is a tool for writing automated tests of websites. It aims to mimic the behaviour of a real user, and as such interacts with the HTML of the application.

Can Selenium test a application on iPhone’s Mobile Safari browser?

Selenium can handle Mobile Safari browser. There is experimental Selenium IPhone Driver for running tests on Mobile with Safari on the iPhone and iPad and iPod Touch.

Copyright ©2015 Hub4Tech.com, All Rights Reserved. Hub4Tech™ is registered trademark of Hub4tech Portal Services Pvt. Ltd.
All trademarks and logos appearing on this website are the property of their respective owners.