MCPcopy Index your code
hub / github.com/aquality-automation/aquality-selenium-java

github.com/aquality-automation/aquality-selenium-java @v4.22.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v4.22.0 ↗ · + Follow
1,176 symbols 4,848 edges 198 files 338 documented · 29%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Build Status Quality Gate Sonatype Central

Overview

This package is a library designed to simplify your work with Selenium WebDriver.

You've got to use this set of methods, related to most common actions performed with web elements.

Most of performed methods are logged using LOG4J, so you can easily see a history of performed actions in your log.

We use interfaces where is possible, so you can implement your own version of target interface with no need to rewrite other classes.

Breaking news!

Starting from v4.4.0 onwards, this package requires Java 11 or higher, as Selenium has stopped support of Java 8. The last version available for Java 8 is v4.3.3

Quick start

To start the project using aquality.selenium framework, you can download our template BDD project by this link.

Alternatively, you can follow the steps below:

  1. Add the dependency to your pom.xml:
<dependency>
    <groupId>com.github.aquality-automation</groupId>
    <artifactId>aquality-selenium</artifactId>
    <version>4.x.x</version>
</dependency>
  1. Create instance of Browser in your test method:
Browser browser = AqualityServices.getBrowser();
  1. Use Browser's methods directly for general actions, such as navigation, window resize, scrolling and alerts handling:
browser.maximize();
browser.goTo("https://wikipedia.org");
browser.waitForPageToLoad();
  1. Use ElementFactory class's methods to get an instance of each element.
ITextBox txbSearch = AqualityServices.getElementFactory().getTextBox(By.id("searchInput"), "Search");
  1. Call element's methods to perform action with element:
txbSearch.type("Selenium WebDriver");
txbSearch.submit();
browser.waitForPageToLoad();
  1. Use BiDi functionality to handle basic authentication:
browser.network().addBasicAuthentication("domain.com", "username", "password");

or intercept network requests/responses:

browser.network().startNetworkInterceptor((HttpHandler) request -> new HttpResponse()
        .setStatus(HttpStatus.SC_OK)
        .addHeader("Content-Type", MediaType.HTML_UTF_8.toString())
        .setContent(utf8String("Some phrase")));
  1. Emulate GeoLocation, Device, Touch, Media, UserAgent overrides, Disable script execution, log HTTP exchange, track Performance metrics, add initialization scripts, and more using browser.devTools() interfaces:
final double latitude = 53.90772672521578;
final double longitude = 27.458060411865375;
final double accuracy = 0.97;
browser.devTools().emulation().setGeolocationOverride(latitude, longitude, accuracy);

See more DevTools use cases here

It is also possible to set mobile emulation capabilities (for chromium-based browsers) in resources/settings.json file, as well as to configure other arguments and options there:

{
  "browserName": "chrome",
  "isRemote": false,
  "remoteConnectionUrl": "http://qa-auto-nexus:4444/wd/hub",
  "isElementHighlightEnabled": true,

  "driverSettings": {
    "chrome": {
      "capabilities": {
        "selenoid:options": 
        { 
            "enableVNC": true 
        },
        "mobileEmulation": {
          "userAgent": "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19",
          "deviceMetrics": {
            "width": 660,
            "height": 1040,
            "pixelRatio": 3.0
          },
          "clientHints": {
            "platform": "Android",
            "mobile": true
          }
        },
        "unhandledPromptBehavior": "ignore"
      },
      "options": {
        "download.prompt_for_download": "false",
        "download.default_directory": "./downloads"
      },
      "loggingPreferences": {
          "Performance": "All"
      },
      "excludedArguments": [ "enable-automation" ],
      "startArguments": [ "--disable-search-engine-choice-screen" ],
      "pageLoadStrategy": "normal"
    },
    "safari": {
      "options": {
        "safari.options.dataDir": "/Users/username/Downloads"
      }
    }
  },
  "timeouts": {
    "timeoutImplicit": 0,
    "timeoutCondition": 30,
    "timeoutScript": 10,
    "timeoutPageLoad": 60,
    "timeoutPollingInterval": 300,
    "timeoutCommand": 60
  },
  "retry": {
    "number": 2,
    "pollingInterval": 300
  },
  "logger": {
    "language": "en",
    "logPageSource": true
  },
  "elementCache": {
    "isEnabled": false
  },
  "visualization": {
    "imageExtension": "png",
    "maxFullFileNameLength": 255,
    "defaultThreshold": 0.012,
    "comparisonWidth": 16,
    "comparisonHeight": 16,
    "pathToDumps": "./src/test/resources/visualDumps/"
  }
}
  1. Quit browser at the end
browser.quit();

See quick start example here

Documentation

To get more details please look at documentation: - In English - In Russian

License

Library's source code is made available under the Apache 2.0 license.

Extension points exported contracts — how you extend this code

IBrowserFactory (Interface)
Factory that creates instance of desired Browser based on aquality.selenium.configuration.IBrowserProfile [6 implementers]
src/main/java/aquality/selenium/browser/IBrowserFactory.java
IBrowserProfile (Interface)
Describes browser settings. [2 implementers]
src/main/java/aquality/selenium/configuration/IBrowserProfile.java
ITimeoutConfiguration (Interface)
Describes timeouts configuration. [2 implementers]
src/main/java/aquality/selenium/configuration/ITimeoutConfiguration.java
IConfiguration (Interface)
Describes tool configuration. [2 implementers]
src/main/java/aquality/selenium/configuration/IConfiguration.java
IBrowserWindowNavigation (Interface)
Provides functionality to work with browser tab/window navigation. [1 implementers]
src/main/java/aquality/selenium/browser/IBrowserWindowNavigation.java

Core symbols most depended-on inside this repo

getBrowser
called by 165
src/main/java/aquality/selenium/browser/IBrowserFactory.java
getBrowser
called by 79
src/main/java/aquality/selenium/browser/AqualityServices.java
getElementFactory
called by 76
src/main/java/aquality/selenium/forms/Form.java
get
called by 74
src/main/java/aquality/selenium/elements/interfaces/IElementFactory.java
getDriver
called by 68
src/main/java/aquality/selenium/browser/Browser.java
logElementAction
called by 65
src/main/java/aquality/selenium/elements/actions/JsActions.java
goTo
called by 58
src/main/java/aquality/selenium/browser/Browser.java
getElement
called by 58
src/main/java/aquality/selenium/elements/Element.java

Shape

Method 1,004
Class 132
Interface 23
Enum 14
Function 3

Languages

Java100%
TypeScript1%

Modules by API surface

src/main/java/aquality/selenium/browser/Browser.java36 symbols
src/main/java/aquality/selenium/elements/Element.java26 symbols
src/main/java/aquality/selenium/browser/devtools/NetworkHandling.java26 symbols
src/main/java/aquality/selenium/browser/devtools/JavaScriptHandling.java26 symbols
src/test/java/tests/integration/BrowserTests.java22 symbols
src/test/java/aquality/selenium/waitings/ConditionalWaitTests.java22 symbols
src/main/java/aquality/selenium/elements/actions/JsActions.java22 symbols
src/test/java/tests/integration/BrowserTabsTests.java20 symbols
src/main/java/aquality/selenium/configuration/driversettings/DriverSettings.java20 symbols
src/main/java/aquality/selenium/browser/devtools/DevToolsHandling.java19 symbols
src/main/java/aquality/selenium/browser/AqualityServices.java19 symbols
src/test/java/w3schools/forms/SelectMultipleForm.java18 symbols

For agents

$ claude mcp add aquality-selenium-java \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page