Important terms of Selenium WebDriver

Important terms of Selenium WebDriver

 In Selenium testing, there are several important terms and concepts that you need to understand to effectively write and manage your test scripts. Here are some key terms:

1. WebDriver:

  • WebDriver is the interface that allows interaction with web browsers. It is the core component of Selenium and can be used to simulate user interactions like clicking, typing, and navigating pages.
  • WebDriver supports multiple browsers like Chrome, Firefox, Edge, Safari, etc.

2. Locator:

  • A locator is used to identify elements on a web page. Selenium provides several ways to locate elements:
    • ID (By.id())
    • Name (By.name())
    • Class Name (By.className())
    • Tag Name (By.tagName())
    • Link Text (By.linkText())
    • Partial Link Text (By.partialLinkText())
    • CSS Selector (By.cssSelector())
    • XPath (By.xpath())

3. Assertions:

  • Assertions are used to verify that the application behaves as expected. They validate whether a certain condition holds true during the execution of a test.
    • Common assertions in Selenium include:
      • assertEquals()
      • assertTrue()
      • assertFalse()
      • assertNotNull()
      • assertNull()

4. Waits:

  • Implicit Wait: A global wait that applies to all elements and tells the WebDriver to wait a specified amount of time before throwing an exception if an element is not found.
  • Explicit Wait: A more specific wait that applies to a particular element and waits for a specific condition (like visibility or clickability).
  • Fluent Wait: A more advanced wait that allows for periodic checks for a condition within a given time frame.

5. Actions:

  • The Actions class is used for simulating advanced user interactions such as hover, drag-and-drop, keyboard actions, etc.
    • Example:
      • Actions actions = new Actions(driver);
      • actions.moveToElement(element).click().build().perform();

6. TestNG:

  • TestNG is a testing framework often used with Selenium for organizing test cases, defining groups, parallel execution, and reporting.
  • It provides annotations like @Test, @BeforeClass, @AfterMethod, etc.

7. Page Object Model (POM):

  • POM is a design pattern that encourages the use of separate classes for representing different pages of the web application.
  • It helps in making the test code more maintainable and reusable by abstracting the interaction with the elements of a page.

8. Selenium Grid:

  • Selenium Grid allows you to run tests on multiple machines (or environments) simultaneously. It helps distribute the test load, which is useful for parallel testing.

9. Headless Browser:

  • A headless browser is a browser that does not have a graphical user interface (GUI). These are often used for automated testing to speed up test execution, as rendering the UI is not required.
  • Examples: Chrome Headless, Firefox Headless.

10. WebElement:

  • A WebElement is an interface that represents an HTML element. Through this interface, you can perform actions on web elements, like clicking, sending text, or extracting information.

11. FindElement and FindElements:

  • findElement() is used to locate a single element on the web page.
  • findElements() is used to locate multiple elements on the web page that match a certain locator.

12. CSS Selectors:

  • CSS Selectors are patterns used to select elements based on attributes like ID, class, type, etc. They are used in conjunction with By.cssSelector() to find elements.
    • Example: driver.findElement(By.cssSelector("input[type='text']"));

13. JavaScript Executor:

  • JavaScriptExecutor allows you to execute JavaScript code within the browser, which can be useful for triggering actions that are not easily achievable using the regular Selenium commands.
    • Example: JavascriptExecutor js = (JavascriptExecutor) driver;
    • js.executeScript("window.scrollBy(0, 500)");

14. DesiredCapabilities:

  • DesiredCapabilities is a class that allows setting various options or configurations for a browser (e.g., enabling/disabling browser features, setting proxies, etc.).

15. Screenshots:

  • Selenium allows taking screenshots of the browser window for test reporting and debugging.
    • Example:
      java
      File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE)

16. Cookie Management:

  • Selenium provides methods for handling cookies, including adding, deleting, and retrieving cookies.
    • Example: driver.manage().addCookie(new Cookie("name", "value"));

17. Driver Commands:

  • These are commands used to control the browser, such as:
    • get(): Opens a URL.
    • quit(): Closes all windows and ends the session.
    • navigate(): Navigates to a new page or back to the previous page.
    • getTitle(): Retrieves the page title.
    • getCurrentUrl(): Retrieves the current URL.

18. BrowerOptions:

  • BrowserOptions allows you to configure browser-specific options like running in headless mode, enabling/disabling extensions, setting timeouts, etc.

Understanding these terms and concepts will help you build more efficient and effective Selenium test scripts. They are fundamental when working with Selenium to automate web application testing.

https://otieu.com/4/9433883
https://otieu.com/4/9433883