# Oracle JET Component WebElements

oraclejet-webdriver is a UI automation library built on top of
[selenium-webdriver](https://www.selenium.dev/selenium/docs/api/javascript/), and
designed to work with [Oracle JET](https://www.npmjs.com/package/@oracle/oraclejet)-based applications.

## Installation

```bash
npm install -D @oracle/oraclejet-webdriver
```

## Usage

The library is available with type definitions so that tests can be authored in
[TypeScript](https://www.npmjs.com/package/typescript).

The root module <code>@oracle/oraclejet-webdriver</code> has a
[default export](modules/index.html#default) where common utilities can be found.
WebElements that correspond to JET components can be found underneath
<code>@oracle/oraclejet-webdriver/elements</code>

A sample test script using [Mocha](https://mochajs.org):

```javascript
import ojwd, { DriverManager } from '@oracle/oraclejet-webdriver';
import { ojInputText } from '@oracle/oraclejet-webdriver/elements';
import { By, WebDriver } from 'selenium-webdriver';

describe('My suite of tests', function () {
  let driver: WebDriver;

  before(async function () {
    driver = await DriverManager.getDriver();
    await ojwd.get(driver, 'http://myapp.com/');
  });

  it('changes an &lt;oj-input-text> value', async function () {
    const input = await ojInputText(driver, By.id('text-input-1'));
    await input.changeValue('...');
  });

  after(function () {
    DriverManager.releaseDriver(driver);
  });
});
```

## Compatibility

It's important to use the same version of oraclejet-webdriver which matches your
oraclejet. If the versions differ, the library will throw an exception upon opening
the page and a console error will be logged.

### Dependencies

This library depends on the following:

- [@oracle/oraclejet](https://www.npmjs.com/package/@oracle/oraclejet)
- [selenium-webdriver >= 4.0.0](https://www.npmjs.com/package/selenium-webdriver)
- NodeJS v12+
