### Reuse WebDriver in Setup Methods (Deprecated) Source: https://docs.testerra.io/testerra/stable/index Illustrates the deprecated behavior where WebDriver instances created in setup methods (`@Before...` or `@After...`) are not automatically closed, even if `tt.wdm.closewindows.aftertestmethods` is true. This behavior will be removed in future versions. ```java @BeforeMethod public void setupWebDriver() { // This WebDriver will not be closed, because it's a setup method WebDriver driver = WEB_DRIVER_MANAGER.getWebDriver(); } @Test public void test1() { // You get the already opened session WebDriver driver = WEB_DRIVER_MANAGER.getWebDriver(); } ``` -------------------------------- ### Install Selenium and ChromeDriver via Package Managers Source: https://docs.testerra.io/testerra/stable/index Provides commands for installing Selenium and its corresponding ChromeDriver using common package managers on different operating systems. This is an optional step for setting up a local Selenium driver if a remote one is not available. ```shell choco install selenium selenium-chrome-driver ``` ```shell apt-get install chromium-chromedriver ``` ```shell brew install selenium-server-standalone chromedriver ``` -------------------------------- ### Handle UI Element Lists (Java) Source: https://docs.testerra.io/testerra/stable/index Demonstrates how to handle lists of UI elements using the new standard way with `UiElementList` and the deprecated `GuiElement` list approach. Includes examples of assertions and iteration. ```java UiElement anchors = find(By.tagName("a")); anchors.expect().foundElements().is(3); UiElementList list = anchors.list(); list.first().expect().value(Attribute.TITLE).is("StartPage"); list.get(1).expect().value(Attribute.TITLE).is("About Us"); list.last().expect().value(Attribute.TITLE).is("Contact"); list.forEach(anchor -> anchor.expect().value(Attribute.HREF).startsWith("https")); ``` ```java GuiElement anchors = new GuiElement(driver, By.tagName("a")); Assert.assertEquals(anchors.getNumberOfFoundElements(), 3); List list = anchor.getList(); list.get(0).asserts().assertAttributeValue("title", "StartPage"); list.get(1).asserts().assertAttributeValue("title", "About Us"); list.get(list.size()-1).asserts().assertAttributeValue("title", "Contact"); list.forEach(anchor -> Assert.assertTrue(anchor.getAttribute("href").startsWith("https"))); ``` -------------------------------- ### Implement Components Pattern in Java Source: https://docs.testerra.io/testerra/stable/index Details the new standard approach for implementing sub-pages or components using the `AbstractComponent` class. The example shows how to define a `MyForm` component and how to instantiate it within a page. ```java public class MyForm extends AbstractComponent { public MyForm(UiElement rootElement) { super(rootElement); } } ``` ```java class MyPage extends Page { private MyForm form = createComponent(MyForm.class, find(By.tagName("form"))); } ``` -------------------------------- ### Load Custom Properties at Test Startup in Java Source: https://docs.testerra.io/testerra/stable/index Demonstrates a Java setup method (`@BeforeSuite`) for dynamically loading custom property files at test startup. It reads an environment property (`env`) and loads a corresponding properties file (e.g., `test_qa.properties`) to override default settings. ```java @BeforeSuite public void setup() { String env = PROPERTY_MANAGER.getProperty("env", ""); if (!"".equals(env)) { PROPERTY_MANAGER.loadProperties("test_" + env + ".properties"); } } ``` -------------------------------- ### Create WebDriver Instances in Test/Setup Methods (Java) Source: https://docs.testerra.io/testerra/stable/index Demonstrates the correct practice of initializing WebDriver instances within test or setup methods to ensure proper session linking with test reports. Avoids creating WebDriver instances at the class level, which can lead to missing session information. ```java @BeforeMethod public void before() { // Context of a setup method WebDriver driver = WebDriverManager.getWebDriver(); } @Test public void myDemoTest() { // Context of a test method WebDriver driver = WEB_DRIVER_MANAGER.getWebDriver(); ... } ``` ```java public class MyTest extends TesterraTest implements WebDriverManagerProvider, PageFactoryProvider { // This may cause side effects! // The session information are missing in the report because // your new session cannot link to the method context WebDriver driver = WEB_DRIVER_MANAGER.getWebDriver(); @Test public void myDemoTest() { StartPage startPage = PAGE_FACTORY.createPage(StartPage.class, driver); ... } ``` -------------------------------- ### Java PageFactory Instantiation Source: https://docs.testerra.io/testerra/stable/index These Java code snippets show how to instantiate Page Objects using Testerra's `PageFactory`. The first example demonstrates the default creation using the provided `PAGE_FACTORY` instance. The second example shows how to explicitly pass a `WebDriver` object during instantiation, useful for managing multiple browser sessions. ```java HomePage homePage = PAGE_FACTORY.createPage(HomePage.class); // Or use an explicit WebDriver HomePage homePage = PAGE_FACTORY.createPage(HomePage.class, WebDriver otherWebDriver); ``` -------------------------------- ### Implementing Page Loaded Callback (Java) Source: https://docs.testerra.io/testerra/stable/index Provides an example of how to add custom actions to be executed after a page has been successfully loaded. This is achieved by overriding the `pageLoaded` method in a custom Page class. ```java public class MyPage extends Page { ... @Override protected void pageLoaded() { super.pageLoaded(); // Add here your custom action } } ``` -------------------------------- ### Listen to TestNG Events with Testerra Source: https://docs.testerra.io/testerra/stable/index This Java code demonstrates how to listen to TestNG events by implementing ISuiteListener and integrating with Testerra's event system. It logs when a test suite starts. Requires TestNG and Guava EventBus. ```java import eu.tsystems.mms.tic.testframework.logging.Loggable; import com.google.common.eventbus.Subscribe; import org.testng.ISuite; import org.testng.ISuiteListener; class MySuiteListener implements ISuiteListener, Loggable { @Subscribe @Override public void onStart(ISuite suite) { log().info("Suite started"); } } ``` -------------------------------- ### TestNG Suite Configuration (suite.xml) Source: https://docs.testerra.io/testerra/stable/index An example of a TestNG suite XML file used to customize test execution. It defines suite-level properties like name, thread count, and parallel execution mode, and specifies which classes to include in the test run. ```xml ``` -------------------------------- ### Configure Proxy for Chrome WebDriver Session Source: https://docs.testerra.io/testerra/stable/index Sets up a custom HTTP proxy for Chrome WebDriver sessions using `WebDriverProxyUtils` and `WebDriverManager`. This example configures a proxy with authentication details from a URL. ```java import org.testng.annotations.BeforeSuite; import eu.tsystems.mms.tic.testframework.webdrivermanager.WebDriverManagerUtils; import eu.tsystems.mms.tic.testframework.webdrivermanager.WebDriverProxyUtils; import org.openqa.selenium.Proxy; public abstract class AbstractTest extends TesterraTest { @BeforeSuite public void proxySetup() { WebDriverProxyUtils utils = new WebDriverProxyUtils(); Proxy otherProxy = utils.createHttpProxyFromUrl( new URL("http://proxyUser:secretPassword@my-proxy:3128") ); WEB_DRIVER_MANAGER.setUserAgentConfig(Browsers.chrome, (ChromeConfig) options -> { options.setProxy(otherProxy); }); } } ``` -------------------------------- ### Run Gradle Tests with Environment Properties Source: https://docs.testerra.io/testerra/stable/index Shows the command-line execution of Gradle tests, passing an environment-specific property using the `-D` flag. This property (`env=qa`) can be used within the test setup to load the appropriate configuration file, enabling tests to run against different environments. ```bash gradle test -Denv=qa ``` -------------------------------- ### Deprecated PageFactory Usage in Java Source: https://docs.testerra.io/testerra/stable/index Highlights deprecated methods for page instantiation using the static `PageFactory`. The code examples show the old way of creating pages with a WebDriver instance, which is no longer recommended. ```java MyPage page = PageFactory.create(MyPage.class, WebDriverManager.getWebDriver()); ``` -------------------------------- ### Access Properties using PropertyManager Source: https://docs.testerra.io/testerra/stable/index Shows how to retrieve various types of properties (String, Long, Double, Boolean) using the PROPERTY_MANAGER instance. It includes examples of providing default values if properties are not found. ```java String property = PROPERTY_MANAGER.getProperty("my.property", "default"); Long longProperty = PROPERTY_MANAGER.getLongProperty("my.long", 200L); Double doubleProperty = PROPERTY_MANAGER.getDoubleProperty("my.double", 200.0); Boolean booleanProperty = PROPERTY_MANAGER.getBooleanProperty("my.boolean", false); ``` -------------------------------- ### Combine Retry and Timeout Control Features (Java) Source: https://docs.testerra.io/testerra/stable/index Shows an example of nesting `CONTROL.withTimeout` within `CONTROL.retryFor` to create a complex control flow. This allows for retrying actions within a specific timeout period, with nested timeouts for individual actions. ```java CONTROL.retryFor(int seconds, () -> { CONTROL.withTimeout(int seconds, () -> { button.click(); uiElement.scrollIntoView(); uiElement.expect().visiblePartial(boolean); } ); } ``` -------------------------------- ### Building XPath by Attribute Value Source: https://docs.testerra.io/testerra/stable/index Demonstrates selecting elements based on their attributes using `.attribute()`. This example shows how to filter elements whose `src` attribute ends with a specific string, like `.png`. ```java XPath.from("*").attribute("src").endsWith(".png"); ``` -------------------------------- ### Set Device Emulation with Chrome DevTools Source: https://docs.testerra.io/testerra/stable/index This code example shows how to emulate mobile devices using Chrome DevTools within Testerra. It configures screen resolution, scale factor, and device type. The `setDevice` method simplifies common mobile emulation settings. For more advanced control, the `Emulation.setDeviceMetricsOverride` method can be used, referencing the Chrome DevTools Protocol documentation. ```java import org.openqa.selenium.Dimension; import org.openqa.selenium.WebDriver; import org.openqa.selenium.devtools.DevTools; import org.openqa.selenium.devtools.v137.emulation.Emulation; public class ChromeDevToolsTests extends TesterraTest implements ChromeDevToolsProvider, WebDriverManagerProvider { @Test public void test_CDP_GeoLocation() { WebDriver webDriver = WEB_DRIVER_MANAGER.getWebDriver(); CHROME_DEV_TOOLS.setDevice( webDriver, new Dimension(400, 900), // resolution 100, // Scale factor true); // it's a mobile device webDriver.get("..."); } } ``` ```java WebDriver webDriver = WEB_DRIVER_MANAGER.getWebDriver(); DevTools devTools = CHROME_DEV_TOOLS.getRawDevTools(webDriver); devTools.send(Emulation.setDeviceMetricsOverride(...)); ``` -------------------------------- ### Get System Proxy URLs Source: https://docs.testerra.io/testerra/stable/index Retrieves the system's configured HTTP and HTTPS proxy URLs using `ProxyUtils`. This utility reads proxy settings defined in `system.properties` or via JVM parameters. ```java import java.net.URL; import eu.tsystems.mms.tic.testframework.utils.ProxyUtils; // Format e.g.: http://{http.proxyHost}:{http.proxyPort} URL httpProxyUrl = ProxyUtils.getSystemHttpProxyUrl(); URL httpsProxyUrl = ProxyUtils.getSystemHttpsProxyUrl(); ``` -------------------------------- ### Implement ModuleHook for Initialization and Termination Source: https://docs.testerra.io/testerra/stable/index Implement the ModuleHook interface to define setup (init) and teardown (terminate) logic for your module. The init() method is called early in Testerra's startup, and terminate() is called just before execution ends for cleanup. ```java package io.testerra.myproject.mymodule; import eu.tsystems.mms.tic.testframework.hooks.ModuleHook; public class ConfigureMyModule extends AbstractModule implements ModuleHook { @Override public void init() { // Initialization logic here } @Override public void terminate() { // Cleanup logic here } } ``` -------------------------------- ### Configure System Proxy via Command Line Source: https://docs.testerra.io/testerra/stable/index Demonstrates how to set system proxy configurations for the entire environment, including build tools (Maven, Gradle), JVM, and Selenium, by passing system properties as command-line arguments. This is the recommended approach for setting up proxies. ```shell gradle test -Dhttps.proxyHost=your-proxy-host.com -Dhttps.proxyPort=8080 ``` -------------------------------- ### Testerra Assertion Hierarchy Example Source: https://docs.testerra.io/testerra/stable/index Illustrates the hierarchical nature of Testerra assertions using the `uiElement.screenshot().file().extension().is("png")` example. This shows how different assertion types like `ScreenshotAssertion`, `FileAssertion`, and `StringAssertion` are chained together. ```plaintext 1. Take a screenshot and return a `ScreenshotAssertion` 2. Return a generic `FileAssertion` with the taken screenshot file 3. Return a generic `StringAssertion` with the given file name extension ``` -------------------------------- ### Get Message Count with MailConnector Source: https://docs.testerra.io/testerra/stable/index Provides methods to retrieve the number of messages in the inbox or a specified folder. This is a utility function for understanding the state of the mailbox. ```java connector.getMessageCount(); connector.getMessageCount("FolderName"); ``` -------------------------------- ### Instantiate Pages using PageFactoryProvider in Java Source: https://docs.testerra.io/testerra/stable/index Demonstrates how to obtain a `PAGE_FACTORY` instance by implementing the `PageFactoryProvider` interface and use it to create page objects. It also shows how to use a specific WebDriver instance for page creation. This is the recommended approach for managing page object instantiation. ```java import eu.tsystems.mms.tic.testframework.testing.PageFactoryProvider; import org.testng.annotations.Test; class MyTest extends TesterraTest implements PageFactoryProvider, WebDriverManagerProvider { @Test public void test_MyPageTest() { MyPage page = PAGE_FACTORY.createPage(MyPage.class); // Or using a different WebDriver MyPage page = PAGE_FACTORY.createPage(MyPage.class, WEB_DRIVER_MANAGER.getWebDriver()); } } ``` -------------------------------- ### Define Browser Type for WebDriver Session Source: https://docs.testerra.io/testerra/stable/index Configures the desired browser type for starting a WebDriver session. This can be set to a specific browser name or a browser name with a version number. ```properties # Only browser type tt.browser.setting=firefox # ... or with version tt.browser.setting=firefox:65 ``` -------------------------------- ### Module Migration: Using Google Guice Source: https://docs.testerra.io/testerra/stable/index Explains the migration to Google Guice for Dependency Injection. To enable v2 module hooks, the ModuleHook class must extend AbstractModule. ```java import com.google.inject.AbstractModule; import eu.tsystems.mms.tic.testframework.hooks.ModuleHook; public class MyModuleHook extends AbstractModule implements ModuleHook { } ``` -------------------------------- ### Instantiate UI Elements (Java) Source: https://docs.testerra.io/testerra/stable/index Demonstrates the new standard way to instantiate `UiElement` using `findById` and `find` methods. Also shows the deprecated approach of using the constructor of `GuiElement`. ```java class MyPage extends Page { private UiElement uiElement = findById(42); private UiElement uiElement = find(By.xpath("//div[1]")); } ``` ```java class MyPage extends Page { private GuiElement guiElement = new GuiElement(driver, By.xpath("//div[1]")); } ``` -------------------------------- ### Create Default UiElement using find() Source: https://docs.testerra.io/testerra/stable/index Demonstrates the creation of default UiElements using the `find` method with various Selenium By locators. Each UiElement represents the first element found by the specified locator. ```java UiElement myElement = find(By.id("elementId")); UiElement button1 = find(By.name("button")); UiElement textOutputField = find(By.xpath("//p[@id='99']")); ``` -------------------------------- ### Add Detailed Information to Assertions (Java) Source: https://docs.testerra.io/testerra/stable/index Extends the regular assertion example by adding a third parameter to `assertContains` to provide more context to the assertion message. This helps in understanding the failure reason more clearly. ```java ASSERT.assertContains("Hello world", "planet", "the greeting"); ``` -------------------------------- ### Run Tests with Gradle Source: https://docs.testerra.io/testerra/stable/index The command to execute tests using Gradle. This command will trigger the configured test tasks, including running the TestNG suite. ```shell gradle test ``` -------------------------------- ### Define Test Steps in Java Source: https://docs.testerra.io/testerra/stable/index Demonstrates how to define test steps within Java test code using the `TestStep.begin()` method. This practice enhances test transparency and makes it easier to understand the context of failures. It assumes the Testerra framework and its `TestStep` class are available. ```java @Test public void testT04_TableEntryNotPresent() { final UserModel userNonExisting = userModelFactory.createNonExisting(); TestStep.begin("Init driver and first page"); StartPage startPage = PAGE_FACTORY.createPage(StartPage.class); TestStep.begin("Navigate to tables"); TablePage tablePage = startPage.goToTablePage(); TestStep.begin("Assert user shown."); Assert.assertTrue(tablePage.isUserShown(userNonExisting)); } ``` -------------------------------- ### Fire Custom ContextUpdateEvent Programmatically Source: https://docs.testerra.io/testerra/stable/index Post custom events to Testerra's event bus to notify other modules or components about changes. This example shows how to fire a ContextUpdateEvent after modifying data in the method context. ```java // Update some data in data model... methodContext.name = "new_Test_Method_Name"; Testerra.getEventBus().post(new ContextUpdateEvent().setContext(methodContext)); ``` -------------------------------- ### Component Creation: Define and Instantiate Custom Components Source: https://docs.testerra.io/testerra/stable/index Components are reusable containers with functionality, acting as hybrids of UiElements and PageObjects. They can contain other UiElements and Components. Define components by extending `AbstractComponent` and implement `find` for its elements. Instantiate them using `createComponent()`, providing the component class and its root UiElement. ```java import eu.tsystems.mms.tic.testframework.pageobjects.AbstractComponent; import eu.tsystems.mms.tic.testframework.pageobjects.UiElement; import eu.tsystems.mms.tic.testframework.pageobjects.Page; import org.openqa.selenium.By; // Component definition public class MyComponent extends AbstractComponent { @Check UiElement input = find(By.id("mytext")); @Check UiElement button = find(By.id("button")); public MyComponent(UiElement rootElement) { super(rootElement); } } // Page using the component public class MyPage extends Page { MyComponent component = createComponent(MyComponent.class, find(By.id("container"))); } ``` -------------------------------- ### Wait for Element Visibility (Java) Source: https://docs.testerra.io/testerra/stable/index Illustrates how to wait for an element to become visible using the `waitFor()` prefix in the new standard approach. Also shows the deprecated `waits()` method. ```java if (uiElement.waitFor().displayed(true)) { // Optional element became visible } ``` ```java if (guiElement.waits().waitForIsDisplayed()) { } ``` -------------------------------- ### Delayed Window Switching with Retry Logic Source: https://docs.testerra.io/testerra/stable/index Demonstrates how to handle window switching with a delay and retry mechanism using `CONTROL.retryFor`. This is beneficial when a new window or tab might take a moment to appear or become ready. You can specify the duration for retries and use either title matching or a custom predicate for switching. ```java int secondsForRetry = 6; CONTROL.retryFor(secondsForRetry, () -> { WEB_DRIVER_MANAGER.switchToWindowTitle(webDriver, "MyWindowTitle"); }); // Using a predicate you have to check the result of switching CONTROL.retryFor(secondsForRetry, () -> { boolean result = WEB_DRIVER_MANAGER .switchToWindow(webDriver, driver -> driver.getTitle().contains("MyWindowTitle")); Assert.assertTrue(result); }); ``` -------------------------------- ### Testerra Test Properties Configuration Source: https://docs.testerra.io/testerra/stable/index This snippet demonstrates how to configure Testerra test properties in a `test.properties` file. It shows examples for setting the browser and the base URL for tests. These properties can be overridden by system parameters. ```properties # Setting the browser tt.browser.setting=chrome # ... or with version tt.browser.setting=chrome:120 # Setting the start page tt.baseurl=http://example.org ``` -------------------------------- ### Gradle Build Target Configuration for TestNG Source: https://docs.testerra.io/testerra/stable/index Shows how to configure the 'test' task in a Gradle build file (build.gradle) to use TestNG and specify the suite XML file. It also includes settings for test logging and forwarding JVM properties. ```gradle // build.gradle test { useTestNG() { suites file('src/test/resources/suite.xml') } testLogging { outputs.upToDateWhen { false } showStandardStreams = true } // Important: Forward all JVM properties like proxy settings to TestNG options { systemProperties(System.getProperties()) } // basically execution returns "GREEN" (framework exits with exit code > 0 if there were failures) ignoreFailures = true } ``` -------------------------------- ### Define Default and Environment-Specific Properties Source: https://docs.testerra.io/testerra/stable/index Illustrates how to define properties for test environments. A default `test.properties` file sets base configurations, while environment-specific files (e.g., `test_qa.properties`) can override these settings for particular environments like QA. This allows for flexible configuration management. ```properties tt.browser=chrome tt.baseurl=http://example.org ``` ```properties tt.browser=firefox tt.baseurl=http://qa.example.org ``` -------------------------------- ### Get UI Element Properties using getActual() Source: https://docs.testerra.io/testerra/stable/index Demonstrates retrieving various properties of a UiElement, such as text, attributes, tag name, classes, and CSS properties, using the getActual() method after a wait condition. ```java UiElement element = find(By.xpath("//a")); String text = element.waitFor().text().getActual(); // returns "My link" String href = element.waitFor().attribute("href").getActual(); // returns "newpage.html" String tag = element.waitFor().tagName().getActual(); // returns "a" String classes = element.waitFor().classes().getActual(); // returns "foolink" String css = element.waitFor().css("font-size").getActual(); // returns "20px" ``` -------------------------------- ### Prohibited Explicit Page Checks in Java Source: https://docs.testerra.io/testerra/stable/index Illustrates the prohibited methods for performing explicit page checks. The examples show that calling `checkPage()` as a protected or public member is disallowed, reinforcing the move towards implicit checks. ```java class MyPage extends Page { public MyPage(WebDriver webDriver) { super(webDriver); checkPage(); __**(1)** } } MyPage page = PAGE_FACTORY.create(MyPage.class); page.checkPage(); __**(2)** ``` -------------------------------- ### Execute Maven Tests with Specific Profile Source: https://docs.testerra.io/testerra/stable/index Shows the command-line syntax for running Maven tests with a specified profile. The `-P` flag activates the profile defined in the `pom.xml`, which in turn configures the Surefire plugin to use the appropriate TestNG suite XML file. ```bash mvn test -PmySuite ``` -------------------------------- ### Handle Custom Event in Listener Source: https://docs.testerra.io/testerra/stable/index Implement the custom event listener interface and use the @Subscribe annotation to define the method that will be called when your custom event is posted to the event bus. This example logs a message when a CustomEvent is received. ```java @Override @Subscribe public void onCustomEvent(CustomEvent event) { log().info("Custom Event started!"); } ``` -------------------------------- ### Component Lists: Create and Use Lists of Components Source: https://docs.testerra.io/testerra/stable/index Components can be treated as lists, similar to UiElements. This allows for iterating over multiple instances of a component, such as rows in a table. Create component lists using `createComponent` with the appropriate component class and a UiElement representing the list items. ```java import eu.tsystems.mms.tic.testframework.pageobjects.UiElement; import eu.tsystems.mms.tic.testframework.pageobjects.Page; import org.openqa.selenium.By; // Assuming TableRow and its methods like getNameColumn() are defined elsewhere // public class TableRow extends AbstractComponent { ... } public class MyPage extends Page { public void processTable() { UiElement table = find(By.tagName("table")); // Assuming TableRow is a component that represents a row // and has a method like 'list()' to get a collection of rows // and 'getNameColumn()' to access a specific column. // The actual implementation of TableRow and its finders would be necessary. // For demonstration, let's assume createComponent can create a list-like component // or that TableRow itself handles list creation internally. // The example below demonstrates the usage pattern. // This part is conceptual, as `createComponent` typically creates a single instance. // A list of components would likely be handled by a find-all mechanism or a dedicated list component. // Let's assume `table.find(By.tagName("tr"))` returns a UiElementList of rows, // and we can map `createComponent` over it if `createComponent` supported it directly // or if we had a helper method. // A more realistic approach might involve finding all row elements and then creating components for each: java.util.List rowElements = table.find(By.tagName("tr")).list(); for (UiElement rowElement : rowElements) { // Assuming TableRow can be instantiated with a single root element TableRow row = createComponent(TableRow.class, rowElement); row.getNameColumn().text().contains("Hello").is(true); } } } ``` -------------------------------- ### Configure Responsive PageFactory in Java Modules Source: https://docs.testerra.io/testerra/stable/index Shows how to configure your application's modules to use the `ResponsivePageFactory` by binding the `PageFactory.class` to `ResponsivePageFactory.class`. This is necessary if you need to utilize the responsive page factory features, as they are removed from the default implementation. ```java import eu.tsystems.mms.tic.testframework.pageobjects.internal.ResponsivePageFactory; import com.google.inject.AbstractModule; import com.google.inject.Scopes; public class MyModule extends AbstractModule { protected void configure() { bind(PageFactory.class).to(ResponsivePageFactory.class).in(Scopes.SINGLETON); } } ``` -------------------------------- ### Get WebDriver Session Source: https://docs.testerra.io/testerra/stable/index Retrieves a WebDriver instance. On the first call, it opens a new browser window. Subsequent calls within the same test context return the existing session, avoiding the need to pass the instance around. ```java WebDriver driver = WEB_DRIVER_MANAGER.getWebDriver(); ``` -------------------------------- ### Create UiElements with Prepared XPath Expressions Source: https://docs.testerra.io/testerra/stable/index Illustrates the use of `LOCATE.prepare()` to create reusable and readable XPath expressions. These prepared locators can then be used with placeholders for dynamic values. ```java PreparedLocator byText = LOCATE.prepare("//button[text()='%s']"); PreparedLocator byClass = LOCATE.prepare("//%s[contains(@class, '%s')][%d]"); UiElement loginButton = find(byText.with("Login")); UiElement logoutButton = find(byClass.with("button", "btn-logout", 1)); ``` -------------------------------- ### Run Tests with Maven Source: https://docs.testerra.io/testerra/stable/index The command to execute tests using Maven. This command will activate the appropriate profile and run the tests defined in the Surefire plugin configuration. ```shell mvn test ``` -------------------------------- ### Load Additional Property Files Source: https://docs.testerra.io/testerra/stable/index Demonstrates how to load additional custom property files into the PropertyManager. Properties loaded from these files will override any existing properties with the same keys. ```java PROPERTY_MANAGER.loadProperties("my.property.file"); ``` -------------------------------- ### Building XPath to Select Sub-Elements by Attributes and Text Source: https://docs.testerra.io/testerra/stable/index Combines multiple XPath builder methods to select a specific sub-element. This example finds a `