Top 50 Selenium interview questions and answers 2018

Top 50 Selenium interview questions and answers 2018

1. What is Automation Testing?
Automation testing or Test Automation is a process of automating the manual process to test the application/system under test. Automation testing involves the use of a separate testing tool which lets you create test scripts which can be executed repeatedly and doesn’t require any manual intervention.

2. What are the benefits of Automation Testing?
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

3. Why should Selenium be selected as a test tool?
It 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

4.What is Selenium? What are the different Selenium components?
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.

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.

5. What are the testing types that can be supported by Selenium?
Selenium supports the following types of testing:
Functional Testing
Regression Testing

6. What are the limitations of Selenium?
Following are the limitations of Selenium:
Selenium supports testing of only web-based applications
Mobile applications cannot be tested using Selenium
Captcha and Barcode readers cannot be tested using Selenium
Reports can only be generated using third-party tools like TestNG or JUnit.
As Selenium is a free tool, thus there is no ready vendor support through the user can find numerous helping communities.
The user is expected to possess prior programming language knowledge.

7. 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

8. 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 “findElement” command may not work as expected.

9. 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

10. Explain how you can handle colors in 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

11. Using web driver how you can store a value which is text box?
You can use following command to store a value which is text box using web driver
driver.findElement(By.id(“your Textbox”)).sendKeys(“your keyword”);

12. 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 number or ID: Select a frame by its name or ID
Previously found WebElement: Using its previously located WebElement select a frame

13. 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

14. 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);

15. How will you use Selenium to upload a file ?
You can use “type”command to type in a file input box of upload file. Then, you have to use “Robot” class in JAVA to make file upload work.

16. Which web driver implementation is fastest?
HTMLUnit Driver implementation is fastest, HTMLUnitDriver does not execute tests on browser but plain http request, which is far quick than launching a browser and executing tests

17. Explain how you can handle frames using Selenium 2.0 ?
To bring control on HTML frame you can use “SwitchTo” frame method-
driver.switchTo().frame(“frameName”);
To specify a frame you can use index number
driver.switchTo().frame(“parentFrame.4.frameName”);
This would bring control on frame named- “frameName” of the 4th sub frame names “parentFrame”

18. When should I use Selenium Grid?
Selenium Grid can be used to execute same or different test scripts on multiple platforms and browsers concurrently so as to achieve distributed test execution, testing under different environments and saving execution time remarkably.

19. What do we mean by Selenium 1 and Selenium 2?
Selenium RC and WebDriver, in a combination, are popularly known as Selenium 2. Selenium RC alone is also referred as Selenium 1.

20. Which is the latest Selenium tool?
WebDriver

21. What is the command that is used in order to display the values of a variable into the output console or log?
In order to display a constant string, command can be used is echo <constant string>
If order to display the value of a variable you can use command like echo ${variable name>>
Above is using PHP. If you are using Java, replace echo with System.out.println

22. Explain how you can use recovery scenario with Selenium?
Recovery scenarios depends upon the programming language you use. If you are using Java then you can use exception handling to overcome same. By using “Try Catch Block” within your Selenium WebDriver Java tests

23. What is Selenium IDE?
Selenium IDE (Integrated Development Environment) is a Firefox plugin. It is the simplest framework in the Selenium Suite. It allows us to record and playback the scripts. Even though we can create scripts using Selenium IDE, we need to use Selenium RC or Selenium WebDriver to write more advanced and robust test cases.

24. What is Selenese?
Selenese is the language which is used to write test scripts in Selenium IDE.

25. When do you use Selenium Grid?
Selenium Grid can be used to execute same or different test scripts on multiple platforms and browsers concurrently so as to achieve distributed test execution

26. What are the advantages of Selenium Grid?
It allows running test cases in parallel thereby saving test execution time.
It allows multi-browser testing
It allows us to execute test cases on multi-platform

27. What is a hub in Selenium Grid?
A hub is a server or a central point that controls the test executions on different machines.

28. What is a node in Selenium Grid?
Node is the machine which is attached to the hub. There can be multiple nodes in Selenium Grid.

29. What is the command that is used in order to display the values of a variable into the output console or log?
In order to display a constant string, command can be used is echo <constant string>
If order to display the value of a variable you can use command like echo ${variable name>>
Above is using PHP. If you are using Java, replace echo with System.out.println

30. Explain how you can use recovery scenario with Selenium?
Recovery scenarios depends upon the programming language you use. If you are using Java then you can use exception handling to overcome same. By using “Try Catch Block” within your Selenium WebDriver Java tests

31. Explain how to iterate through options in test script?
To iterate through options in test script you can loop features of the programming language, for example to type different test data in a text box you can use “for” loop in Java
// test data collection in an array
String[ ] testData = { “test1” , “test2” , “test3” } ;
// iterate through each test data
For (string s: test data) { selenium.type ( “elementLocator”, testData) ; }

32. How can you prepare customized html report using TestNG in hybrid framework ?
There are three ways
Junit: With the help of ANT
TestNG: Using inbuilt default.html to get the HTML report. Also XST reports from ANT, Selenium, Testng combinations
Using our own customized reports using XSL jar for converting XML content to HTML

33. From your test script how you can create html test report?
To create html test report there are three ways
TestNG: Using inbuilt default.html to get the HTML report. Also XLST reports from ANT, Selenium, TestNG combination
JUnit: With the help of ANT
Using our own customized reports using XSL jar for converting XML content to HTML

34. Explain how you can insert a break point in Selenium IDE ?
In Selenium IDE to insert a break point
Select “Toggle break point” by right click on the command in Selenium IDE
Press “B” on the keyboard and select the command in Selenium IDE
Multiple break points can be set in Selenium IDE

35. Explain in Selenium IDE how can you debug the tests?
Insert a break point from the location from where you want to execute test step by step
Run the test case
At the given break point execution will be paused
To continue with the next statement click on the blue button
Click on the “Run” button to continue executing all the commands at a time

36. What is Selenese and what are the types of Selenese ?
Selenese is a selenium set of command which are used for running the test
There are three types of Selenese
Actions: It is used for performing the operations and interactions with the target elements
Assertions: It is used as a check points
Accessors: It is used for storing the values in a variable

37. Explain what are the limitations of Selenium IDE?
The limitations of Selenium IDE
Exceptional handling is not present
Selenium IDE uses only HTML languages
External databases reading is not possible with IDE
Reading from the external files like .txt, .xls is not possible
Conditional or branching statements execution like if,else, select statements is not possible

38. What are the two modes of views in Selenium IDE ?
Either Selenium IDE can be opened as a pop up window or in side bar

39. In selenium IDE what are the element locators that can be used to locate elements on web page?
In selenium there are mainly 4 locators that are used
X-path locators
Css locators
Html id
Html name

40. Explain how you can debug the tests in Selenium IDE ?
Insert a break point from the location where you want to execute step by step
Run the test case
At the given break point execution will be paused
To continues with the next step click on the Blue button
To run commands at a time click on run button

41. From Selenium IDE how you can execute a single line?
From Selenium IDE single line command can be executed in two ways
Select “Execute this command” by right clicking on the command in Selenium IDE
Press “X” key on the keyboard after selecting the command in Selenium IDE

42. Explain how you can insert a start point in Selenium IDE?
In two ways selenium IDE can be set
Press “S” key on the keyboard and select the command in Selenium IDE
In Seleniun IDE right click on the command and the select “Set / Clear Start Point”

43. What if you have written your own element locator and how would you test it?
To test the locator one can use “Find Button” of Selenium IDE, as you click on it, you would see on screen an element being highlighted provided your element locator is right or or else an error message will be displayed

44. What is regular expressions? How you can use regular expressions in Selenium?
A regular expression is a special text string used for describing a search pattern. In Selenium IDE regular expression can be used with the keyword- regexp: as a prefix to the value and patterns needs to be included for the expected values.

45.What are core extension ?
If you want to “extend” the defualt functionality provided by Selenium Function Library , you can create a Core Extension. They are also called “User Extension”. You can even download ready-made Core Extension created by other Selenium enthusiats.

46. How will you handle working with multiple windows in Selenium ?
We can use the command selectWindow to switch between windows. This command uses the title of Windows to identify which window to switch to.

47. How can we handle pop-ups in RC ?
To handle pop-ups in RC , using selectWindow method, pop-up window will be selected and windowFocus method will let the control from current window to pop-up windows and perform actions according to script

48. What are the technical limitations while using Selenium RC?
Apart from “same origin policy” restriction from js, Selenium is also restricted from exercising anything that is outside browser.

49. Can we use Selenium RC to drive tests on two different browsers on one operating system without Selenium Grid?
Yes, it is possible when you are not using JAVA testing framework. Instead of using Java testing framework if you are using java client driver of selenium then TestNG allows you to do this. By using “parallel=test” attribute you can set tests to be executed in parallel and can define two different tests, each using different browser.

50. Why to use TestNG with Selenium RC ?
If you want full automation against different server and client platforms, You need a way to invoke the tests from a command line process, reports that tells you what happened and flexibility in how you create your test suites. TestNG gives that flexibility.

top
ETLHIVE is a Trademark of Itelligence Infotech Pvt Ltd.   *PMP®, PMBOK, PMI, PgMP, CAPM, PMI-RMP, and PMI-ACP are registered trademarks of the Project Management Institute, Inc. *ITIL®, IT Infrastructure Library, Swirl Logo, Prince2 are registered trademarks of AXELOS Limited.
25th May 2019 – Demo Sessions – Pimple Saudagar – Saleforce : 12pm | Python : 3pm | Digital Marketing : 11am | Selenium : 4pm | AWS : 6pm | Devops : 11am | Informatica : 11am |Data Science : 4pm| Hadoop : 10am Nal Stop – AWS : 12pm | Python : 2pm | Data Science : 3pm | Kharadi – Data Science : 12pm | Hadoop : 10am | Vashi – Data Science : 6pm | Python : 6pm | Selenium : 5pm | AWS : 11am | Devops : 12.30pm | Hadoop : 4.30pm |