diff --git a/index.e2e.spec.ts b/index.e2e.spec.ts index f44b4ac..6b3cb04 100644 --- a/index.e2e.spec.ts +++ b/index.e2e.spec.ts @@ -1,4 +1,5 @@ import { + activeWindow, assert, Button, centerOf, @@ -10,7 +11,7 @@ import { right, screen, sleep, - straightTo + straightTo, } from "./index"; const openXfceMenu = async () => { @@ -97,3 +98,20 @@ describe("E2E mouse button demo", () => { } }); }); + +describe("E2E window demo", () => { + it("should list gnome-calculator", async () => { + jest.setTimeout(30000); + screen.config.resourceDirectory = "./e2e/assets"; + await assert.isVisible("mouse.png"); + await assert.isVisible("desktop.png"); + await openXfceMenu(); + await run("uxterm"); + await sleep(1500); + const foregroundWindow = await activeWindow(); + const windowTitle = await foregroundWindow.title; + await close(); + + expect(windowTitle).toBe("uxterm") + }); +}); diff --git a/index.ts b/index.ts index 22589c4..9eeb7e2 100644 --- a/index.ts +++ b/index.ts @@ -7,6 +7,7 @@ import { Mouse } from "./lib/mouse.class"; import { createMovementApi } from "./lib/movement.function"; import { Screen } from "./lib/screen.class"; import { LineHelper } from "./lib/util/linehelper.class"; +import { createWindowApi } from "./lib/window.function"; export { jestMatchers } from "./lib/expect/jest.matcher.function"; export { sleep } from "./lib/sleep.function"; @@ -19,6 +20,7 @@ export { OptionalSearchParameters } from "./lib/optionalsearchparameters.class"; export { linear } from "./lib/movementtype.function"; export { Point } from "./lib/point.class"; export { Region } from "./lib/region.class"; +export { Window } from "./lib/window.class"; const screenActions = new VisionAdapter(); const nativeActions = new NativeAdapter(); @@ -31,6 +33,7 @@ const screen = new Screen(screenActions); const assert = new Assert(screen); const {straightTo, up, down, left, right} = createMovementApi(nativeActions, lineHelper); +const {windows, activeWindow } = createWindowApi(nativeActions); export { clipboard, @@ -43,4 +46,6 @@ export { down, left, right, + windows, + activeWindow, };