Tuesday, June 28, 2022

Selenium Interview Questions and Answers - PART 1

1. What is Selenium?

  •  Selenium is an automation testing tool that is used for automating web-based applications.
  •  It supports multiple browsers, programming languages, and platforms.

2. What are the different forms of selenium?

  •  Selenium WebDriver - It is used to automate web applications using browser methods.
  •  Selenium IDE - It is a plugin that works on record and playback principles.
  •  Selenium RC - Selenium Remote Control(RC) is officially deprecated by Selenium and it used to work on javascript to automate web applications.
  •  Selenium Grid - Allows selenium tests to run in parallel across multiple machines.

3. Advantages of selenium?

  •  Selenium is open source and free to use without any licensing cost.
  •  It supports multiple languages like java, ruby, python, etc.
  •  It supports multi-browser testing.
  •  Using the selenium ide component, non-programmers can also write automation scripts.

4. Limitations of selenium?

  •  We cannot test the desktop applications using selenium.
  •  We cannot test web services using selenium.

5. Which browsers/drivers are supported by the selenium web driver?

 Google chrome - ChromeDriver

 Firefox - FireFoxDriver

 Internet Explorer - InternetExplorerDriver

 Safari - SafariDriver

6. What are the testing types supported by the selenium web driver?

  •  Selenium web driver can be used for performing automated functional and regression testing.

7.Different locators in selenium?

 id,xpath,cssSelector,className,tagName,name,linkText,partialLinkText

8.What is an XPath?

  •  Xpath or XML path is a query language for selecting nodes from XML documents.
  •  XPath is one of the locators supported by the selenium web driver.

 Types of XPath:

 absolute XPath

 relative XPath

9. How can we launch different browsers in the selenium web driver?

  •  By creating an instance of the driver of a particular browser

 WebDriver driver = new ChromeDriver();

10.What is the use of driver.get("url") and driver.navigate().to("url")command?

  •  Both driver. get("url") and driver.navigate().to("URL") commands are used to navigate to a URL passed as a parameter.

11. How can we type text in a textbox element using selenium?

  •  using the sendKeys() method we can type text in a textbox.

 WebElement text = driver.findElement(By.id("search"));

 text.sendKeys("suriya");

12. How we can clear a text written in a textbox?

  •  Using the clear() method we can delete the text written in a textbox.

 driver.findElement(By.id("elementLocator")).clear();

13. How to check a checkbox in selenium?

  •  the click() method used for clicking buttons or radio buttons can be used for checking checkboxes.

14. Difference between close and quit commands?

 driver.close() - used to close the current browser having focus.

 driver.quit() - used to close all the browser instances

15. Maximize browser window - driver.manage().window().maximiza();

16. Find the value - driver.findElement(By.id("locator")).getAttribute("value");

17. How to delete cookies in selenium?

 driver.manage().deleteAllCookies();

18. Double-click an element in selenium?

 Actions action = new Actions(driver);

 WebElement element = driver.findElement(By.id("elementid"));

 action.doubleClick(element).perform();

19. Right-click an element in selenium?

 Actions action = new Actions(driver);

 WebElement element = driver.findElement(By.id("elementid"));

 action.contextClick(element).perform();

20. How to fetch the current page URL in selenium?

 driver.getCurrentUrl();

21. How can we fetch the title of the page in selenium?

 driver.getTitle();

22. fetch the page source in selenium?

 driver.getPageSource();

No comments:

Post a Comment