Pages

Wednesday, 23 September 2015

Selenium Interview Question and Answers Part 1

Selenium Interview Question and Answers Part 1


Q 1) What is Automation Testing?
  • Software testing automation is the process of software verification in which the basic function and test steps, such as running, initialization, execution, analysis and delivery of results are performed automatically by tools for automated testing.
  • Automation testing or Test Automation is a process of automating the manual process to test the application/system under test.
  • Automation testing involves use of a separate testing tool which lets you create test scripts which can be executed repeatedly and doesn’t require any manual intervention.
Q 2) What are the benefits of Automation Testing?

Benefits of Automation testing are:
  • Supports execution of repeated test cases
  • Aids in testing a large test matrix
  • Enables parallel execution
  • Encourages unattended execution
  • Improves accuracy thereby reducing human generated errors
  • Saves time and money
Q 3) Why should Selenium be selected as a test tool?

Selenium
  • is a free and open source
  • have a large user base and helping communities
  • have cross Browser compatibility (Firefox, chrome, Internet Explorer, Safari etc.)
  • have great platform compatibility (Windows, Mac OS, Linux etc.)
  • supports multiple programming languages (Java, C#, Ruby, Python, Pearl etc.)
  • has fresh and regular repository developments
  • supports distributed testing
Q 4) What is Selenium?

Selenium is one of the most popular automated testing suites. Selenium is designed in a way to support and encourage automation testing of functional aspects of web based applications and a wide range of browsers and platforms. Due to its existence in the open source community, it has become one of the most accepted tools amongst the testing professionals.
Q 5) What are the different Selenium components?

Selenium is not just a single tool or a utility, rather a package of several testing tools and for the same reason it is referred to as a Suite. Each of these tools is designed to cater different testing and test environment requirements.
The suite package constitutes of the following sets of tools:
  • Selenium Integrated Development Environment (IDE)– Selenium IDE is a record and playback tool. It is distributed as a Firefox Plugin.
  • Selenium Remote Control (RC)– Selenium RC is a server that allows user to create test scripts in a desired programming language. It also allows executing test scripts within the large spectrum of browsers.
  • Selenium WebDriver– WebDriver is a different tool altogether that has various advantages over Selenium RC. WebDriver directly communicates with the web browser and uses its native compatibility to automate.
  • Selenium Grid– Selenium Grid is used to distribute your test execution on multiple platforms and environments concurrently.
Q 6) What are the testing types that can be supported by Selenium?

For web based application testing selenium can be used
The test types can be supported are
a)Functional
b)Regression
For post release validation with continuous integration automation tool could be used
a)Jenkins
b)Hudson
c)Quick Build
d)CruiseCont
Q 7) What are the limitations of Selenium?

Some limitations of Selenium Automation tool are as follows:
  • It does not support and non web-based applications, it only supports web based applications.
  • Mobile applications cannot be tested using Selenium
  • Captcha and Bar code readers cannot be tested using Selenium
  • Reports can only be generated using third party tools like TestNG or Junit.
  • Its and open source tool so in case of any technical issues you need to rely on the selenium community forums to get your issue resolved.
  • You need to know at least one of the supported language very well in order to automate your application successfully.
  • No inbuilt reporting capability so you need plugins like JUnit and TestNG for test reports.
  • Lot of challenges with IE browser.
Q 8)What is the difference between Selenium IDE, Selenium RC and WebDriver?

Difference between Selenium IDE, Selenium RC, Selenium Webdriver

Selenium IDE Selenium RC Selenium Web-driver
Only works on Mozilla Firefox Works on almost all browsers. Does not work on latest version of Firefox/IE Works on latest versions of almost all browsers - Firefox, IE(6,7,8), Opera, Chrome
Record and play/run tool No Record and run No Record and run
No server required to start Server is required to start No server required to start
Core engine is JavaScript based Core engine is JavaScript based Interacts natively with browser application
Very simple to use. If using User extensions, you require knowledge on java script which makes the work a little bit tough. Its a simple and small API Complex and a bit large API as compared to RC
Not at all object oriented Less Object oriented API Purely Object oriented API
Cannot move mouse with it Cannot move mouse with it Can move mouse cursor
Full xpaths have to be appended with 'xapth=\\' syntax Full xpaths have to be appended with 'xapth=\\' syntax No need to append 'xpath=\\'
No Listeners No Listeners Implementation of Listeners is provided
Cannot test iPhone/Android applications Cannot test iPhone/Android applications Can test iPhone/Android applications
Cannot test iPhone/Android applications Cannot test iPhone/Android applications Can test iPhone/Android applications



Q 9) What is Selenese?
  • Selenese is the language which is used to write test scripts in Selenium IDE.
  • Selenese is the set of selenium commands which are used to test your web application.
  • Tester can test the broken links, existence of some object on the UI, Ajax functionality, Alerts, window, list options and lot more using selenese.
Q 10) How Selenium commands can be categorized?

Selenium commands are classified into 3 basic categories:-
1.Actions Commands which change the state of the application are classified as actions, like click on some link, select some options on the page, select a value from drop down etc. When action is performed on page the test will fail if the action is not successful. Most common action commands of selenium are:
    a. ClickAndWait
    b. Click
  1. Accessors These commands check the state of the application and stores the application state in some variable. Some examples of accessors are as follows .
    a storeTitle
    b. storeTextAccessors are also used to evaluate whether the desired result is present on the page and store the result in the variable.
    Examples:
    a. storeTextPresent: If text is found on the page then it stores the boolean value as true else store false.
    b. storeElementPresent: If UI element is present on the page then it stores boolean value as true else stores false.
  2. Assertions Assertions are used like the checkpoints or verification points in automation. Assertion verifies the state of the application conforms to the expected state .Example:
    a. verifyText
    b. verifyTitle
    c. assertText



Q 11) What are the different types of locators in Selenium?

Locator can be termed as an address that identifies a web element uniquely within the webpage. Thus, to identify web elements accurately and precisely we have different types of locators in Selenium:
  • ID
  • ClassName
  • Name
  • TagName
  • LinkText
  • PartialLinkText
  • Xpath
  • CSS Selector
  • DOM
Q 12)What is difference between assert and verify commands?

Assert:Assert command checks whether the given condition is true or false. Let’s say we assert whether the given element is present on the web page or not. If the condition is true then the program control will execute the next test step but if the condition is false, the execution would stop and no further test would be executed.
Verify:Verify command also checks whether the given condition is true or false. Irrespective of the condition being true or false, the program execution doesn’t halts i.e. any failure during verification would not stop the execution and all the test steps would be executed.
Q 13) What is an Xpath?

Xpath is used to locate a web element based on its XML path. XML stands for Extensible Markup Language and is used to store, organize and transport arbitrary data. It stores data in a key-value pair which is very much similar to HTML tags. Both being markup languages and since they fall under the same umbrella, Xpath can be used to locate HTML elements.
The fundamental behind locating elements using Xpath is the traversing between various elements across the entire page and thus enabling a user to find an element with the reference of another element.

Q 14) What is the difference between “/” and “//” in Xpath?

Single Slash “/” –Single slash is used to create Xpath with absolute path i.e. the xpath would be created to start selection from the document node/start node.
Double Slash “//” –Double slash is used to create Xpath with relative path i.e. the xpath would be created to start selection from anywhere within the document.
Q 15) What is Same origin policy and how it can be handled?

The problem of same origin policy disallows to access the DOM of a document from an origin that is different from the origin we are trying to access the document.
Origin is a sequential combination of scheme, host and port of the URL. For example, for a URL http:// http://www.softwaretestinghelp.com/resources/, the origin is a combination of http, softwaretestinghelp.com, 80 correspondingly.
Thus the Selenium Core (JavaScript Program) cannot access the elements from an origin that is different from where it was launched. For Example, if I have launched the JavaScript Program from “http://www.softwaretestinghelp.com”, then I would be able to access the pages within the same domain such as “http://www.softwaretestinghelp.com/resources” or “http://www.softwaretestinghelp.com/istqb-free-updates/”. The other domains like google.com, seleniumhq.org would no more be accessible.
So, In order to handle same origin policy, Selenium Remote Control was introduced.

No comments:

Post a Comment