Showing posts with label Automation Experience. Show all posts
Showing posts with label Automation Experience. Show all posts

Tuesday, December 12, 2017

Selenium Interview Questions & Answers


1. What is Automation Testing?

Automation testing is a process of simulating the manual process of the application which is under test.

2. What are the benefits of Automation Testing?

Benefits of Automation testing are:
  • Supports execution of repeated test cases.
  • It enables parallel execution.
  • Improves accuracy thereby reducing human-generated errors.
  • Saves time and money.
3. What is Selenium 2.0?

Web Testing tools Selenium RC and WebDriver are consolidated in a single tool in Selenium 2.0.

4. Mention what is Selenium 3.0?

Selenium 3.0 is the latest version of Selenium. It has released 2 beta versions of selenium 3.0.

5. Why Selenium?

It is becoming increasingly popular and it is the first choice of automation testers as well as organizations for automating the testing of Web-based applications for both the GUI as well as the functionality.

6. What are the testing types that can be supported by Selenium?

Selenium supports the following types of testing:
  • Functional Testing.
  • Regression Testing.
7. What are the different types of locators in Selenium?

In Selenium every object or control in a web page is referred as element, there are different ways to find an element on a web page they are
  • ID
  • Name
  • TagName
  • CSS Selector
  • Link text
  • PartialLink Text
  • Xpath etc
8. Mention what is the use of X-path?

XPath means XML Path. X-Path is used to find the WebElement in web pages. It is also useful in identifying the dynamic 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.

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

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

Single slash '/':
  1. Single slash (/) start selection from the document node.
  2. It allows you to create 'absolute' path expressions.
Double Slash '//':
  1. Double slash (//) start selection matching anywhere in the document.
  2. It enables to create 'relative' path expressions.
11. What is same origin policy? How you can avoid same origin policy?

The "Same Origin Policy" is introduced for security reason, and it ensures that content of our application will never be accessible by a script from another application. 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 and then masks the application under test under a fictional URL.

12. 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 and if the element is not found then it throws a NoSuchElementException.

Explicit Wait: It is a one-timer, used for a particular search.


13. Explain what is the difference between findElement() and findElements()?

findElement(): It finds the single element within the current page using the given “locating mechanism”.It returns a single WebElement
Example: driver.findElement(By.xpath(“//div[@id=’example’]//ul//li”));

findElements(): Using the given “locating mechanism” find all the elements on the current page.It returns a list of web elements.
Example: List <WebElement> elementList = driver.findElements(By.xpath(“//div[@id=’example’]//ul//li”));

14. How to select a value in a drop-down?

A value in the drop-down can be selected using WebDriver’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);

15. What is the difference between driver.close() and driver.quit command?

close(): Close() method closes the web browser window that the user is currently working.

quit(): Quit() method closes down all the windows that the program has opened. 

16. What is the difference between getWindowhandles() and getwindowhandle()?

getwindowhandles(): It is used to get the address of all the open browser and its return type is Set<String>

getwindowhandle(): It is used to get the address of the current browser where the control is and return type is a string

17. Explain how you can switch back from a frame?

To switch back from a frame use method defaultContent()
Example: driver.switchTo().defaultContent();

18. What is the difference between driver.get() and driver.navigate()?

driver.get(): It's used to go to the particular website, But it doesn't maintain the browser History and cookies so, we can't use forward and backward button, if we click on that, page will not get schedule

driver.navigate(): it's used to go to the particular website, but it maintains the browser history and cookies. So we can use the forward and backward button to navigate between the pages during the coding of test cases

19. What is Gecko driver?

Gecko Driver is the link between your tests in Selenium and the Firefox browser. Gecko Driver is a proxy for using W3C Web Driver-compatible clients to interact with Gecko-based browsers i.e. Mozilla Firefox in this case. As Selenium 3 will not have any native implementation of FF, we have to direct all the driver commands through Gecko Driver.

20. What are the differences between XPath and CSS?

With XPath, we can search elements either backward or forward in the DOM hierarchy while CSS works only in a forward direction. This means that with XPath we can locate a parent element using a child element.