Top 50 Selenium Webdriver Interview Questions And Answers Pdf

1. What is Automation Testing?
Answer: Automation testing or Test Automation is a process of automating the manual process to test the application/system under test. Automation testing involves use to 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 main advantages of Automation Testing?
Answer: Regression testing coverage, test engineer productivity, consistency in testing, test cases reusability, reduced software maintenance cost, increased test effectiveness, reduction of the test interval, reducing human-generated error.

3. How can you find if an element is displayed on the screen?
Answer: There are different methods, which help the user to check the visibility of the web elements: is displayed(), isEnabled(), isSelected(). These web elements can be buttons, drop boxes, checkboxes, radio buttons, labels, etc.

4. So, what is Selenium?
Answer: Selenium is a robust test automation suite 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.

5. Why should Selenium be selected as a test tool?
Answer:

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

6. What are the main advantages of Selenium?
Answer:

  • Selenium is a free and open source. You don’t need to spend any licensing cost to use it.
  • Cross Browser compatibility (Firefox, Chrome, Internet Explorer, Safari, etc.)
  • Multiple programming languages (Java, C#, Ruby, Python, Pearl, etc.) support
  • Compatibility with the main platform (Windows, Mac OS, Linux, etc.)

7. What are the limitations of Selenium?
Answer:
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 though the user can find numerous helping communities.

The user is expected to possess prior programming language knowledge.

8. How many types of Webdriver APIs are available in Selenium?
Answer:

  • The list of driver classes could be used for browser
  • automation.
  • AndroidDriver,
  • ChromeDriver,
  • EventFiringWebDriver,
  • FirefoxDriver,
  • HtmlUnitDriver,

9. Explain how you can find broken images in a page using Selenium Webdriver?
Answer:
You have to follow the next steps to find broken images in a page using Selenium Webdriver:

  • get XPath and get the all links on the page using the tag name
  • click on every link on the page
  • look for 404/500 in the target page title.

10. When should I use Selenium IDE?
Answer: Selenium IDE is the simplest and easiest of all the tools within the Selenium Package. Its record and playback feature make it exceptionally easy to learn with minimal acquaintances to any programming language. Selenium IDE is an ideal tool for a naïve user.

11. What is Selenium IDE?
Answer: Selenium IDE is a plug-in used to record and replay tests in Firefox browser. Scripts may be automatically recorded and edited manually providing autocompletion support and the ability to move commands around quickly.

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

13. What automation tools could be used for post-release validation with continuous integration?
Answer: Automation tools could be used for post release validation with continuous integration: CruiseCont, Hudson, Jenkins, Quick Build.

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

15. What is the difference between “/” and “//” in Xpath?
Answer:

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.

16. Explain the meaning of assertion in Selenium and what are the types of assertion?
Answer:
The assertion is used as a verification point. It verifies that the application state conforms to the expectation. The types of assertion are “assert”, “verify” and “waifFor”.

17. How to select a value in a dropdown?
Answer:

Value in the drop-down can be selected using Web Driver’s Select class.
Syntax:
selectByValue:

Select selectByValue = new Select(driver.findElement(By.id(“SelectID_One”)));
selectByValue.selectByValue(“greenvalue”);

selectByVisibleText:

Select selectByVisibleText = new Select (driver.findElement(By.id(“SelectID_Two”)));
selectByVisibleText.selectByVisibleText(“Lime”);

selectByIndex:

Select selectByIndex = new Select(driver.findElement(By.id(“SelectID_Three”)));
selectByIndex.selectByIndex(2);

18. What is the purpose of creating a reference variable- ‘driver’ of type
WebDriver instead of directly creating a FireFoxDriver object or any other driver’s reference in the statement Webdriver driver = new FirefoxDriver();?
Answer:
We can use the same variable to work with multiple browsers like ChromeDriver, IEDriver by creating a reference variable of type WebDriver.

19. What is Same origin policy and how it can be handled?
Answer:

  • 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 /resources/, the origin is a combination of  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 then I would be able to access the pages within the same domain such as resources” or  The other domains like google.com, selenium HQ. org would no more be accessible.

So, In order to handle the same-origin policy, Selenium Remote Control was introduced. 

20. What is the framework?
Answer: Framework is a constructive blend of various guidelines, coding standards, concepts, processes, practices, project hierarchies, modularity, reporting mechanism, test data injections, etc. to pillar automation testing.

21. How can we handle windows based pop up?
Answer: Selenium is an automation testing tool which supports only web application testing, that means, it doesn’t support testing of windows based applications. However Selenium alone can’t help the situation but along with some third party intervention, this problem can be overcome. There are several third-party tools available for handling window-based pop-ups along with the selenium like AutoIT, Robo.

22. What is the difference between getWindowHandles() and get window handle()?
Answer: You can get the browser address using these commands. But if you use get Window Handle(), you’ll get the address of the current browser where the control is and return type is a string. So, if you use get Window Handle s(), you will get the address of all the open browser and its return type is an iterator.
t class etc.

23. When should I use Selenium Grid?
Answer: 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.

24. What is an Absolute XPath?
Answer: Absolute XPath is the direct way to find the element. It has a disadvantage. XPath gets failed if there are any changes made in the path of the element. input – Absolute XPath example.

25. What kinds of test types are supported by Selenium?
Answer:

  • Functional Testing
  • Regression Testing
  • Sanity Testing
  • Smoke Testing
  • Responsive Testing
  • Cross Browser Testing
  • UI testing (black box)
  • Integration Testing
    are supported by Selenium. 

26. Which is the latest Selenium tool?
Answer:
WebDriver

27. What is a Relative XPath?
Answer: Relative XPath means that the user can start from the middle of the HTML DOM structure and no need to write long XPath. Example of Relative XPath – //input.

28. What is the difference between single slash (/) and a double slash ( //) in XPath?
Answer: A single slash (/) is used for creating XPaths with absolute paths beginning from the root node.
Double slash (//) is used for creating relative XPath to start selection from anywhere within the root node.

29. What are the different types of frameworks?
Answer: A single slash (/) is used for creating XPaths with absolute paths beginning from the root node.

  • Double slash (//) is used for Below are the different types of frameworks: Module Based Testing Framework: The framework divides the entire “Application Under Test” into a number of logical and isolated modules. For each module, we create a separate and independent test script. Thus, when these test scripts took together builds a larger test script representing more than one module.
  • Library Architecture Testing Framework: The basic fundamental behind the framework is to determine the common steps and group them into functions under a library and call those functions in the test scripts whenever required.
  • Data-Driven Testing Framework: Data-Driven Testing Framework helps the user segregate the test script logic and the test data from each other. It lets the user store the test data into an external database. The data is conventionally stored in “Key-Value” pairs. Thus, the key can be used to access and populate the data within the test scripts.
  • Keyword Driven Testing Framework: The Keyword-driven testing framework is an extension to Data-driven Testing Framework in a sense that it not only segregates the test data from the scripts, it also keeps the certain set of code belonging to the test script into an external data file.
  • Hybrid Testing Framework: Hybrid Testing Framework is a combination of more than one above mentioned frameworks. The best thing about such a setup is that it leverages the benefits of all kinds of associated frameworks.
  • Behavior Driven Development Framework: Behavior Driven Development framework allows the automation of functional validations in an easily readable and understandable format to Business Analysts, Developers, Testers, etc.
    creating relative XPath to start selection from anywhere within the root node.

30. What is TestNG and how is it better than Junit?
Answer: Testing is an advance framework designed in a way to leverage the benefits by both the developers and testers. With the commencement of the frameworks, JUnit gained enormous popularity across the Java applications, Java developers and Java testers with remarkably increasing the code quality. Despite being easy to use and straightforward, JUnit has its own limitations which give rise to the need of bringing TestNG into the picture. TestNG is an open source framework which is distributed under the Apache Software License and is readily available for download.

TestNG with WebDriver provides an efficient and effective test result format that can, in turn, be shared with the stakeholders to have a glimpse on the product’s/application’s health thereby eliminating the drawback of WebDriver’s incapability to generate test reports. TestNG has an inbuilt exception handling mechanism which lets the program to run without terminating unexpectedly.

There are various advantages that make TestNG superior to JUnit. Some of them are:

  • Added advance and easy annotations
  • Execution patterns can set.

31. What are the different types of locators in Selenium?
Answer: The 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:

  • IDClassName
  • Name
  • TagName
  • link text
  • PartialLinkText
  • Xpath
  • CSS Selector
  • DOM

32. What are the different types of Drivers available in WebDriver?
Answer:
The different drivers available in WebDriver are:

  • FirefoxDriver
  • InternetExplorerDriver
  • ChromeDriver
  • SafariDriver
  • OperaDriver
  • AndroidDriver
  • IPhoneDriver
  • HtmlUnitDriver

33. Give an example of the languages supported by WebDriver?
Answer: Java, C#, Python, and Ruby, are all supported directly by the development team. There are also PHP and Perl WebDriver implementations.

34. How to type in a textbox using Selenium?
Answer: User can use sendKeys(“String to be entered”) to enter the string in the textbox.
Syntax:
WebElement username = drv.findElement(By.id(“Email”));
// entering username
username.sendKeys(“sth”);

35. What are the advantages of Automation framework ?
Answer:
Advantage of Test Automation framework

  • Reusability of code
  • Maximum coverage
  • Recovery scenario
  • Low-cost maintenance
  • Minimal manual intervention
  • Easy Reporting

36. What kind of mouse actions can be performed in Selenium?
Answer: Selenium supports different mouse actions, such as:

  • click(WebElement element)
  • Context Click(WebElement element)
  • doubleClick(WebElement element)
  • mouseUp(WebElement element)
  • mouseDown(WebElement element)
  • mouseMove(WebElement element)
  • mouseMove(WebElement element, long xOffset, long yOffset).

37. What is Junit ?
Answer:
Junit is a unit testing framework introduced by Apache. Junit is based on Java.

38. What is the difference between assert and verify commands?
Answer:

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 halt i.e. any failure during verification would not stop the execution and all the test steps would be executed.

39. How can we get a text of a web element?
Answer: Get command is used to retrieve the inner text of the specified web element. The command doesn’t require any parameter but returns a string value. It is also one of the extensively used commands for verification of messages, labels, errors etc displayed on the web pages.

40. What are the different types of waits available in WebDriver?
Answer: There are two types of waits available in WebDriver:

Implicit Wait: Implicit waits are used to provide a default waiting time (say 30 seconds) between each consecutive test step/command across the entire test script. Thus, the subsequent test step would only execute when the 30 seconds have elapsed after executing the previous test step/command.

Explicit Wait: Explicit waits are used to halt the execution till the time a particular condition is met or the maximum time has elapsed. Unlike Implicit waits, explicit waits are applied for a particular instance only.

41. What is the difference between Selenium and QTP?
Answer:

  • Feature
  • Selenium
  • Quick Test Professional (QTP)
  • Browser Compatibility Selenium supports almost all popular browsers like Firefox, Chrome, Safari, Internet Explorer, Opera, etc.
  • QTP supports Internet Explorer, Firefox and Chrome. QTP only supports Windows Operating System Distribution
  • Selenium is distributed as an open source tool and is freely available
  • QTP is distributed as a licensed tool and is commercialized
  • Application under Test
  • Selenium supports testing of only web-based applications
  • QTP supports testing of both the web-based application and windows based application
  • Object Repository
  • Object Repository needs to be created as a separate entity
  • QTP automatically creates and maintains Object Repository
  • Language Support
  • Selenium supports multiple programming languages like Java, C#, Ruby, Python, Perl, etc
  • QTP supports only VB Script
  • Vendor Support
  • As Selenium is a free tool, the user would not get the vendor’s support in troubleshooting issues
  • Users can easily get the vendor’s support in case of any issue

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

driver.findElement(By.linkText(“Google”)).click();

The command finds the element using link text and then click on that element and thus the user would be redirected to the corresponding page.

The above-mentioned link can also be accessed by using the following command.

driver.findElement(By.partialLinkText(“Goo”)).click();

The above command finds the element based on the substring of the link provided in the parenthesis and thus partialLinkText() finds the web element with the specified substring and then clicks on it.

43. What is the difference between “type” and “type And Wait for” command?
Answer: If you need to type keyboard key values into a text field of the web application, “type” command will be used. Another reason for its usage is selecting values of the combo box. “type and wait” command is used when your typing is completed and software web page start reloading.

44. What is Selenium? What are the different Selenium components?
Answer: 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 to 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 a user to create test scripts in the desired programming language. It

45. What is the difference between setSpeed() and sleep() methods?
Answer: Both of these methods delay the speed of execution. The main difference between them is setSpeed sets a speed while will apply delay time before every Selenium operation takes place. thread.sleep() will set up wait only for once.

For Example:

  • sleep(5000)- It will wait for 5 seconds. It is executed only once, where the command is written.
  • setSpeed(“5000”)- It also will wait for 5 seconds. It runs each command after setSpeed delay by the number of milliseconds mentioned in set Speed.

46. How to mouse hover on a web element using WebDriver?
Answer: BWebDriver offers a wide range of interaction utilities that the user can exploit to automate mouse and keyboard events. Action Interface is one such utility which simulates the single user interactions.
Thus, In the following scenario, we have used Action Interface to mouse hover on a drop-down which then opens a list of options.

47. What are Junit annotations?
Answer: Following are the Junit Annotations:

  • Test: Annotation lets the system know that the method annotated as Test is a test method. There can be multiple test methods in a single test script.
  • Before: Method annotated as Before lets the system know that this method shall be executed every time before each of the test methods.
  • After: Method annotated as @After lets the system know that this method shall be executed every time after each of the test method.
  • BeforeClass: Method annotated as @BeforeClass lets the system know that this method shall be executed once before any of the test methods.
  • AfterClass: Method annotated as @AfterClass lets the system know that this method shall be executed once after any of the test methods.
  • Ignore: Method annotated as @Ignore lets the system know that this method shall not be executed.
  • Concurrent execution of test scripts
  • Test case dependencies can be set

48. What is the hybrid framework?
Answer: The combination of data-driven and keyword-driven framework is called the hybrid. Here the operations/instructions/keywords in a separate repository (.csv/.xls/.json/DB) and data is in separate (.csv/.xls/.json/DB from data provider) and the tests/driver would read both and perform the actual tests automatically. In this design, we get the best of both methodologies, and it is kind of practice in most of the automation cases.

49. What could be the cause of the Selenium WebDriver test to fail?
Answer: There are some causes of Selenium WebDriver test to fail:

  • Selenium WebDriver element waiting to access did not appear on the web page and the operation timed out
  • Selenium WebDriver is trying to access not created element
  • Selenium WebDriver cannot locate the element, because the locator has 70)

50. How can you find if an element is displayed on the screen?
Answer:
WebDriver facilitates the user with the following methods to check the visibility of the web elements. These web elements can be buttons, drop boxes, checkboxes, radio buttons, labels etc.

isDisplayed()
isSelected()
isEnabled()
Syntax:
isDisplayed():
boolean buttonPresence = driver.findElement(By.id(“gbqfba”)).isDisplayed();
isSelected():
boolean buttonSelected = driver.findElement(By.id(“gbqfba”)).isDisplayed();
isEnabled();

Note: Browse latest  Selenium interview questions and Selenium tutorial. Here you can check  Selenium Training details and Selenium Videos for self learning. Contact +91 988 502 2027 for more information.

Leave a Comment

FLAT 30% OFF

Coupon Code - GET30
SHOP NOW
* Terms & Conditions Apply
close-link