1. 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 plugin
•WebDriver and RC: It provides the APIs for a variety of languages like Java, .NET, PHP, etc. With most of the browsers Webdriver and RC works.
•Grid: With the help of Grid you can distribute tests on multiple machines so that tests can be run parallel which helps in cutting down the time required for running in browser test suites.
2. 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
•Linktext
•PartialLinkText
•Xpath etc.,
3. List out the test types that are supported by Selenium?
For web based application testing selenium can be used
The test types can be supported are:
•Functional
•Regression
For post release validation with continuous integration automation tool could be used
•Jenkins
•Hudson
•Quick Build
•CruiseCont.
4. Explain what is an 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 “waitFor”.
5. Mention what is the use of Xpath?
XPath is used to find the WebElement in web pages. It is also useful in identifying the dynamic elements.
6. Explain the difference between single and double slash in Xpath?
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
7. List out the technical challenges with Selenium?
Technical challenges with Selenium are:
•Selenium supports only web based applications
•It does not support the Bitmap comparison
•For any reporting related capabilities have to depend on third party tools
•No vendor support for tool compared to commercial tools like HP UFT
•As there is no object repository concept in Selenium, maintainability of objects becomes difficult.
8. What is the difference between type keys and type commands ?
TypeKeys() will trigger JavaScript events in most of the cases whereas .type() won’t. Type key populates the value attribute using JavaScript whereas .typekeys() emulates like actual user typing.
9. 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 terminate at the point where the 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 the tests fails.
10.What are 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 known as Annotations. Variables, parameters, packages, methods and classes are annotated some of the
Junit annotations which can be useful are:
•Test
•Before
•After
•Ignore
•BeforeClass
•AfterClass
•RunWith
11. While using the click command can you use screen coordinate?
To click on a specific part of an element, you would need to use the clickAT command. ClickAt command accepts element locator and x, y coordinates as arguments- clickAt (locator, cordString).
12. What are the advantages of Selenium?
•It supports C#, PHP, Java, Perl, Python
•It supports different OS like Windows, Linux and Mac OS
•It has got powerful methods to locate elements (Xpath, DOM , CSS)
•It has a highly developed community supported by Google.
13. Why should testers opt for Selenium and not QTP?
Selenium is more popular than QTP as
•Selenium is an open source whereas QTP is a commercial tool
•Selenium is used specially for testing web based applications while QTP can be used for testing client server application also
•Selenium supports Firefox, IE, Opera, Safari on operating systems like Windows, Mac, Linux etc. however QTP is limited to Internet Explorer on Windows.
•Selenium supports many programming languages like Ruby, Perl, Python whereas QTP supports only VB script.
14. What are the four parameters you have to pass in Selenium?
Four parameters that you have to pass in Selenium are:
•Host
•Port Number
•Browser
•URL
15. What is the same origin policy? How can you avoid the same origin policy?
The “Same Origin Policy” is introduced for security reasons, 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 website’s 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.
16.What are heightened privilege browsers?
The purpose of heightened privileges is similar to Proxy Injection, allowing websites to do something that are not commonly permitted. The key difference is that the browsers are launched in a special mode called heightened privileges. By using these browser modes, Selenium core can open the AUT directly and also read/write its content without passing the whole AUT through the Selenium RC server.
17. How can you “submit” a form using Selenium ?
You can use “submit” method on element to submit form-
element.submit () ;
Alternatively you can use the click method on the element which does form submission.
18. 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
19. 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 elements 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.
20. 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 a list of frames.
•You will need to switch to each and every frame and search for the locator which we want.
•Then break the loop.
21. Explain what is the difference between find elements () and find element () ?
•find element (): It finds the first element within the current page using the given “locating mechanism”. It returns a single WebElement
•findElements (): Using the given “locating mechanism” find all the elements within the current page. It returns a list of web elements.
22. Explain what 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.
23. Explain what is Data Driven framework and Keyword driven?
•Data Driven 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.
•Keyword Driven framework: The keyword driven framework requires the development of data tables and keywords, independent of the test automation. In a keyword driven test, the functionality of the application under test is documented in a table as well as step by step instructions for each test.
24. What is Object Repository ?
An object repository is an essential entity in any UI automations which allows a tester to store all objects that will be used in the scripts in one or more centralized locations rather than scattered all over the test scripts.
25. Explain how Selenium Grid works?
Selenium Grid sent the tests to the hub. These tests are redirected to Selenium Webdriver, which launches the browser and runs the test. With the entire test suite, it allows for running tests in parallel.
26.Can we use the Selenium grid for performance testing?
Yes. But not as effectively as a dedicated Performance Testing tool like Loadrunner.
27. List the advantages of Webdriver over Selenium Server?
•If you are using Selenium-WebDriver, you don’t need the Selenium Server as it is using totally different technology
•Selenium Server provides Selenium RC functionality which is used for Selenium 1.0 backwards compatibility
•Selenium Web driver makes direct calls to browser using each browser’s native support for automation, while Selenium RC requires selenium server to inject Javascript into the browser
28.Mention what are the capabilities of Selenium WebDriver or Selenium 2.0 ?
WebDriver should be used when requiring improvement support for
•Handling multiple frames, pop ups , multiple browser windows and alerts
•Page navigation and drag & drop
•Ajax based UI elements
•Multi browser testing including improved functionality for browser not well supported by Selenium 1.0
29. While injecting capabilities in webdriver to perform tests on a browser which is not supported by a webdriver what is the limitation that one can come across?
Major limitation of injecting capabilities is that the “findElement” command may not work as expected.
30.Explain how you can find broken images in a page using Selenium Web driver?
To find the broken images in a page using Selenium web driver is
•Get XPath and get all the links in the page using tag name
•In the page click on each and every link
•Look for 404/500 in the target page title.
31. Explain how you can handle colors in a web driver?
To handle colors in web driver you can use
Use getCssValue(arg0) function to get the colors by sending ‘color’ string as an argument
32.Using a web driver how can you store a value which is a text box?
You can use following command to store a value which is textbox using web driver
driver.findElement(By.id(“your Textbox”)).sendKeys(“your keyword”);
33.Explain how you can switch between frames?
To switch between frames webdrivers [ driver.switchTo().frame() ] method takes one of the three possible arguments
•A number: It selects the number by its (zero-based) index
•A name or ID: Select a frame by its name or ID
•Previously found WebElement: Using its previously located WebElement select a frame.
34. Mention 5 different exceptions you had in Selenium web driver?
The 5 different exceptions you had in Selenium web drivers are
•WebDriverException
•NoAlertPresentException
•NoSuchWindowException
•NoSuchElementException
•TimeoutException
35.Explain using Webdriver how you can perform double click ?
You can perform double click by using
•Syntax- Actions act = new Actions (driver);
•act.doubleClick(webelement);
36.How will you use Selenium to upload a file ?
You can use the “type”command to type in a file input box of the upload file. Then, you have to use the “Robot” class in JAVA to make file upload work.