{"id":23286364,"url":"https://github.com/inammar/Terms-and-definitions-Selenium-TestNG","last_synced_at":"2025-08-21T17:32:20.203Z","repository":{"id":266869920,"uuid":"899557931","full_name":"inammar/Terms-and-definitions","owner":"inammar","description":"Terms and definitions of Selenium Webdriver and TestNG","archived":false,"fork":false,"pushed_at":"2024-12-19T12:09:58.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-19T13:22:53.522Z","etag":null,"topics":["selenium-java","selenium-webdriver","testng-framework"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/inammar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-06T14:12:22.000Z","updated_at":"2024-12-19T12:10:01.000Z","dependencies_parsed_at":"2024-12-06T17:34:37.335Z","dependency_job_id":null,"html_url":"https://github.com/inammar/Terms-and-definitions","commit_stats":null,"previous_names":["inammar/terms-and-definitions"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inammar%2FTerms-and-definitions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inammar%2FTerms-and-definitions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inammar%2FTerms-and-definitions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inammar%2FTerms-and-definitions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inammar","download_url":"https://codeload.github.com/inammar/Terms-and-definitions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230523771,"owners_count":18239446,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["selenium-java","selenium-webdriver","testng-framework"],"created_at":"2024-12-20T02:11:35.848Z","updated_at":"2025-08-21T17:32:20.191Z","avatar_url":"https://github.com/inammar.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Terms-and-definitions\n\n![image](https://github.com/user-attachments/assets/47d86a3d-0c4e-4b25-8ad2-27a01d3d7173)\n\nI found a lot of definitions and terms about Selenium Webdriver and TestNG on the Internet, but not all of them were understandable to me as a beginner. It took a time to find ones that would be explained simply and clearly. Therefore, I created this repository to have all the definitions in one place so that I could check them if necessary. The definitions are not mine, they were all found on the Internet. \n\n________________________________________________________________________________________________________________________________________________________________________________________\n## Terms and definitions of Selenium Webdriver and TestNG\n\n### 1. Selenium Webdriver definition\n\nSelenium Webdriver is an open source web automation tool, that allows to automate web browser interactions. It allows testers to automate browser actions such as navigating through web pages, clicking buttons, entering text, and validating expected outcomes.\n\n### 2. Locators\n\nLocators are one of the essential components of Selenium infrastructure, which help Selenium scripts in uniquely identifying the web elements (such as text box, button, etc.) present of the web page. Shortly, a locator is a way to identify and interact with elements on a page.\n\nTo use these locators, Selenium provides the By class, which locates elements within the DOM (The Document Object Model (DOM) is a programming interface for XML and HTML documents. It states the logical structure of the document and the way it is accessed and manipulated).\nThere are different locators like className, cssSelector, id, linkText, name, partialLinkText, tagName, and XPath, etc., which can identify the unique or specific element based on various attributes. \n\n### 3. POM file\n\nIn Java, there are dependency management and build solution tools. Maven and Gradle are the most common for Selenium. \n\nThe Maven solution introduces a project object model file - POM file which is an XML structure file. Every time a change is made to the project code, it updates the build status and continuously maintains and monitors the framework components (various parts and libraries that your project depends on) and build (compilation of tests, dependancy management). It ensures everything is set up correctly for you to run your tests smoothly. Maven \"continuously maintains and monitors\" this setup to make sure your project builds successfully every time changes are made.\n\n### 4. How to start\n\npublic class Main { // Declares a class named 'Main'\n\n    public static void main(String[] args) { // Main method where program execution starts\n    \n        WebDriver driver = new ChromeDriver(); // Creates a new instance of the ChromeDriver, a WebDriver implementation for Chrome\n        \n        driver.manage().window().maximize(); // Maximizes the browser window\n        \n        driver.get(\"https://www.example.com\"); // Navigates to the specified URL (\"https://www.example.com\")\n        \n        driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5)); // Sets an implicit wait of 5 seconds, allowing WebDriver to wait for elements to appear before throwing an exception (error)\n        \n        driver.findElement(By.id(\"CookieOptinAllowAll\")).click(); // Locates an element with the ID \"CookieOptinAllowAll\" and simulates a click action on it\n\nThis simple example is attached to this repository using \"Magento\" shop website.\n\n### 5. Common methods\n\n#### 5.1. Browser Control\n\n       manage() - interacts with the browser's settings and capabilities. It provides access to manage things like window size, cookies, timeouts, and other browser-level operations.\n\n       findElement() - finds the first element using the given selector.\n\n       findElements() - finds all elements within the current page using the given locator.\n\n       getTitle() - gets the title of the current page.\n\n       close() - closes the current window and if it is the last window, closes the browser.\n\n       quit() - terminates the driver closing all associated window.\n\n#### 5.2. Basic interactions that can be done on a web element\n\n       sendKeys(string) - enters the string or characters that is specified in the element.\n\n       click() - clicks on the element.\n\n       getText() - retrieves the text present in the element (visible content, that user can see on the screen).\n\n       getAttribute() - retrieves the text present in the element (for attribute values like placeholder, value, href, src, etc. For example, to access the text in a password field, which is stored in the \n                        value attribute).\n\n       clear() - clears the text present in the element.\n\n#### 5.3. Waits\n\nImplicit Wait is a global wait, applied to all elements in a script, causing Selenium WebDriver to wait for a certain amount of time before throwing a NoSuchElementException.\n\n           Example: driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));\n\nExplicit Wait is a conditional wait, applied to specific elements, making the WebDriver wait until a certain condition is met.\n\n           Example: \n\n           WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5)); \n\n           wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(\"example Id\")));\n\nDifference: Implicit Wait is set once and applies throughout the script, whereas Explicit Wait is specified for individual elements.\n\n#### 5.4. XPath\n\nWhat is XPath? XPath is a language used to locate elements on a web page.\n\nThere are two main types of XPath: Absolute XPath and Relative XPath.\n\n        Absolute XPath: Starts from the root node and follows a specific path to the element, which we want to identify. It's less flexible because any change in the path will break \n        the XPath.\n        The key characteristic of XPath is that it begins with the single forward slash (/).\n\n        Relative XPath: Starts from any node and allows for more flexible paths. A relative XPath starts with the // symbol. It is mainly used for automation since even if an element is\n        removed or added in the DOM, the relative XPath is not impacted.\n\nAn absolute XPath is long and difficult to maintain (html/body/tagname/…). While a relative XPath is short (//*[@attribute='value']).\n\nExample of html: \n\n\n![image](https://github.com/user-attachments/assets/0c05abb0-4c6a-4523-9d8b-3add17d4b8d4)\n\nExample of XPaths:\n\n•\tAbsolute XPath to the paragraph:\n\n    /html/body/div[1]/div/p\n    \n•\tRelative XPath to the paragraph:\n\n    //div[@id='container']//p\n    \n•\tXPath using text for the link:\n\n    //a[contains(text(),'Click here')]\n    \n    WebElement link = driver.findElement(By.xpath(\"//a[contains(text(),'Click here')]\"));\n                          \n•\tXPath using attribute for the div with class \"content\":\n\n    //div[@class='content']\n                        \n    WebElement contentDiv = driver.findElement(By.xpath(\"//div[@class='content']\"));\n\n### 6. TestNG definition\n\nTestNG is a testing framework for the Java programming language. The design goal of TestNG is to cover a wider range of test categories: unit, functional, end-to-end, integration, etc., with powerful and easy-to-use functionalities.\n\nA TestNG xml file is a configuration file used in the TestNG framework to organize and run your test cases. It allows you to define:\n\n          - test suites, \n\n          - test classes,\n\n          - test methods, \n\nand making it easier to manage and execute your tests.\n\n### 7. TestNG installation\n\nWhen you install TestNG in your project, the TestNG configuration XML file does not automatically appear. You need to create the TestNG XML file manually. It allows you to customize and organize your tests according to your specific requirements. You can name it whatever you like, typically something like testng.xml, and place it in your project directory. Then, you can configure it as needed using the \u003c suite \u003e, \u003c test \u003e, and \u003c class \u003e tags.\n\n       •\tSuite: Represents a collection of tests and is defined by the \u003csuite\u003e tag.\n\n       •\tTest: Represents a group of test classes and is defined by the \u003ctest\u003e tag.\n\n       •\tClass: Represents a Java class containing test methods and is defined by the \u003cclass\u003e tag.\n\n       •\tTest Method: Represents individual test methods annotated with @Test in your Java class.\n\nExample of a simple TestNG XML file:\n\n     \u003c!DOCTYPE suite SYSTEM \"https://testng.org/testng-1.0.dtd\"\u003e\n        \u003csuite name=\"MySuite\"\u003e\n          \u003ctest name=\"MyTest\"\u003e\n            \u003cclasses\u003e\n               \u003cclass name=\"com.example.MyTestClass\"/\u003e\n            \u003c/classes\u003e\n          \u003c/test\u003e\n       \u003c/suite\u003e\n          \nThis file defines a suite named \"MySuite\" with a single test named \"MyTest,\" which includes one test class \"com.example.MyTestClass.\"\n\n### 8. TestNG features\n\nTestNG offers a wide range of properties and features that make it a powerful framework. Here are some:\n\n     Parallel Execution: TestNG supports parallel execution of tests by configuring the parallel attribute in the XML file. You can run tests in parallel at the suite, test, class, or \n     method level.\n\n     Reports: TestNG generates detailed HTML and XML reports by default, which provide insights into the test execution and results.\n\n     Assertions: TestNG provides a rich set of assertions that help validate test results.\n\n     Annotations: TestNG provides a variety of annotations such as @Test, @BeforeClass, @AfterClass, @BeforeMethod, @AfterMethod, etc., to control the test flow.\n\n#### 8.1. Main Annotations\n\n@Test: Marks a method as a test method. This method will run as a test case.\n\n@BeforeClass: Runs once before any test methods in the class. Used for one-time setup, like initializing resources.\n\n@AfterClass: Runs once after all test methods in the class. Used for one-time cleanup, like releasing resources.\n\n@BeforeMethod: Runs before each test method. Used for setting up preconditions for tests.\n\n@AfterMethod: Runs after each test method. Used for cleanup after tests.\n\n### 9. Typical Project Structure of Selenium and TestNG\n\n- Project\n  - src\n    - main\n      - java\n        - my_package_name\n    - test\n      - java\n        - my_package_name\n          - TestClass1.java  \u003c-- Test script here!\n          - TestClass2.java  \u003c-- And here!\n  - resources\n  - lib\n  - logs\n  - screenshots\n  - pom.xml\n  - testng.xml\n\n\n\n\n\n(I will keep adding information...).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finammar%2FTerms-and-definitions-Selenium-TestNG","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finammar%2FTerms-and-definitions-Selenium-TestNG","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finammar%2FTerms-and-definitions-Selenium-TestNG/lists"}