# Variable default`Const`

default: {
assertViewModelValue(driver, vmLocator, expectation) => Promise<any>;
fetch(driver, requestInfo, responseInfo, init?) => Promise<MarshaledResponse>;
get(driver, url) => Promise<void>;
pageReady() => Condition<Promise<boolean>>;
waitAndFindElement(driver, by) => Promise<WebElement>;
} = ...

The test utility object for JET component WebElements. This object contains all of the factory functions needed to create the component WebElements, plus, additional utilities useful for testing JET-based UIs. This object should be imported into tests with

    import ojwd from "@oracle/oraclejet-webdriver";

#### Type declaration

- ##### assertViewModelValue:function

  - assertViewModelValue(driver, vmLocator, expectation): Promise<any>

  - Assert a given expectation against a JET application's viewmodel. Assertions are Chai-like expressions, represented by the Expectation class, and compared remotely on the test browser against the identified viewmodel and its path to the target value.

    The viewmodel is typically identiied by the DOM node on which Knockout's `ko.applyBindings` was called, but can also be descendants of that originial "root" node.

        new Expectation(...)

    The target value within the viewmodel is identified by a dot-notated path and/or expression which yields the value. For instance, a value may be an observable, therefore, the expression must include parenthesis to unwrap the observable.

        new Expecation(By.id('view-container'), 'firstName()')

    The expression to which the viewmodel value will be compared is expressed as BDD-style chains, such as

        const fnExpectation = new Expectation('firstName()')
          .to.equal('Joe');

    If a viewmodel value returns a Promise, the assertion will wait for it to resolve before doing the comparison.

    #### Parameters

    - ##### driver: WebDriver

      The instance of WebDriver to use in performing the expectation

    - ##### vmLocator: Locator

      The Locator which identifies the DOM node associated with the viewmodel on the client.

    - ##### expectation: Expectation<any>

      The Expectation object to evaluate on the client browser.

    #### Returns Promise<any>

- ##### fetch:function

  - fetch(driver, requestInfo, responseInfo, init?): Promise<MarshaledResponse>

  - Invoke fetch in the browser to permit interaction with REST services. Browsers must support fetch api.

    The fetch parameters mirror the MDN fetch api https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters

    Note the return value is not the typical Response object, to accommodate webdriver marshalling.

    #### Parameters

    - ##### driver: WebDriver

      A WebDriver-like object

    - ##### requestInfo: string

    - ##### responseInfo: MarshalableResponseInfo

      Indicates the desired structure of the response body, text or json

    - ##### `Optional` init: MarshalableRequestInit

      Optional An options object containing any custom settings that you want to apply to the request.

    #### Returns Promise<MarshaledResponse>

    A Promise resolving to a MarshaledResponse object

    ###### Example of READ and UPDATE operations

            let dept:any;
            try {
              let res:MarshaledResponse = await ojwd.fetch(driver,restServer + 'Departments/?DepartmentId=20',
                 { "responseBodyAs": "json" } );
              assert(res.status == 200,"Status code should be 200, was " + res.status);
              assert(res.body.kind == "json","Body kind should be 'json', was " + res.body.kind);
              assert(res.body.body[0].DepartmentName == "Marketing","Dept 20 should be named 'Marketing' not " + res.body.body[0].DepartmentName);
              dept = res.body.body[0];

              dept.DepartmentName = "Product Marketing";
              res = await ojwd.fetch(driver,restServer + 'Departments/30', { "responseBodyAs": "json" }, {
                method: 'put',
                headers: { "Content-Type": "application/json" },
                body: {"kind":"json", "body": JSON.stringify(dept)}
              });
              assert(res.status == 200,"Status code should be 200, was " + res.status + " body = " + JSON.stringify(res.body,null,2));
            } catch(err) {
              assert(false, "fetch failed : " + err);
            }

    ###### Example of CREATE and DELETE operations

            try {
              let res:MarshaledResponse = await ojwd.fetch(driver,restServer + 'Departments/',
                 { "responseBodyAs": "json" },
                 { method: 'post',
                 headers: { "Content-Type": "application/json"},
                 body: { "kind": "json", "body": JSON.stringify(newdept)} });
               assert(res.status == 201,"Status code should be 201, was " + res.status);

               res = await ojwd.fetch(driver,restServer + 'Departments/190',
                 { "responseBodyAs": "text" },
                 { method: 'delete' });
               assert(res.status == 200,"Status code should be 200, was " + res.status);
              } catch(err) {
               assert(false, "fetch failed : " + err);
              }

    ###### Example of Checking for row deleted operation

              try {
                let res:MarshaledResponse = await ojwd.fetch(driver,restServer + 'Departments/400',
                  { "responseBodyAs": "json" });
                assert(res.status == 404,"Status code should be 404, was " + res.status);
              } catch(err) {
                assert(false, "fetch failed : " + err);
              }

    ###### Example of MarshaledResponse object for READ fetch

        {
         "body": {
           "body": [
            {
               "DepartmentId": 20,
               "DepartmentName": "Marketing",
               "LocationId": null,
                "ManagerId": null
             }
           ],
            "kind": "json"
          },
          "headers": {
           "cache-control": "no-cache",
            "content-type": "application/json; charset=utf-8",
            "expires": "-1",
            "pragma": "no-cache"
          },
          "ok": true,
          "redirected": false,
          "status": 200,
          "statusText": "OK",
          "type": "cors",
          "url": "http://localhost:3000/Departments/?DepartmentId=20"
          }

- ##### get:function

  - get(driver, url): Promise<void>

  - Opens a JET page and wait for the UI to be ready for testing. This method should be used in place of WebDriver.get() to open a page for test. It will wait on the page's BusyContext to clear before continuing on. Note that this method should only be used to open a JET page, one which uses RequireJS. Attempting to open a non-JET page will result in the script timing out waiting for RequireJS to become available.

    #### Parameters

    - ##### driver: WebDriver

      The WebDriver instance

    - ##### url: string

      The URL to open

    #### Returns Promise<void>

- ##### pageReady:function

  - pageReady(): Condition<Promise<boolean>>

  - ### Deprecated

    Wait until the JET page indicates that it's loaded and ready. This function returns a Condition that can be used with WebDriver.wait().

        await driver.wait(ojwd.pageReady())

    This function is deprecated. All WebElements interacting with JET pages should automatically block until the BusyContext is cleared before performing their actions. Therefore, explicitly waiting for the page to be ready should not be needed.

    #### Returns Condition<Promise<boolean>>

- ##### waitAndFindElement:function

  - waitAndFindElement(driver, by): Promise<WebElement>

  - This is a convenience function to allow either WebDriver or WebElement to be passed as the driver and the search to be performed using that object.

    ### Deprecated

    Since 11.0.0 This method is equivalient to calling driver.findElement(by)

    #### Parameters

    - ##### driver: DriverLike

      A WebDriver-like object, either WebDriver itself or a WebElement. The target element will be searched using this driver.

    - ##### by: By

      The locator by which to find the element

    #### Returns Promise<WebElement>

Generated using TypeDoc