Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING: New but browser orientated API #91

Merged
merged 24 commits into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ jobs:
cd tests/integration/docker_test
docker-compose up -d
docker exec drivers deno test -A --config tsconfig.json tests/integration
docker exec drivers deno test -A --config tsconfig.json tests/unit/chrome_client_test.ts
docker exec drivers deno test -A --config tsconfig.json tests/unit/firefox_client_test.ts
docker exec drivers deno test -A --config tsconfig.json tests/unit/mod_test.ts
docker exec drivers deno test -A --config tsconfig.json tests/unit


tests:
Expand All @@ -44,9 +42,7 @@ jobs:

- name: Run Unit Tests
run: |
deno test -A --config tsconfig.json tests/unit/chrome_client_test.ts
deno test -A --config tsconfig.json tests/unit/firefox_client_test.ts
deno test -A --config tsconfig.json tests/unit/mod_test.ts
deno test -A --config tsconfig.json tests/unit

linter:
# Only one OS is required since fmt is cross platform
Expand Down
16 changes: 0 additions & 16 deletions examples/a.ts

This file was deleted.

50 changes: 39 additions & 11 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,46 @@
import { ChromeClient } from "./src/chrome_client.ts";
import { FirefoxClient } from "./src/firefox_client.ts";
import { BuildOptions } from "./src/client.ts";
import { Client } from "./src/client.ts";
import { BuildOptions, Cookie, ScreenshotOptions } from "./src/interfaces.ts";
import type { Browsers } from "./src/types.ts";
import { getChromeArgs, getFirefoxArgs } from "./src/utility.ts";

export { ChromeClient, FirefoxClient };

type Browsers = "firefox" | "chrome";
export type { BuildOptions, Cookie, ScreenshotOptions };

export async function buildFor(
browser: Browsers,
options?: BuildOptions,
): Promise<ChromeClient | FirefoxClient> {
if (browser === "firefox") {
return await FirefoxClient.build(options);
options: BuildOptions = {
hostname: "localhost",
debuggerPort: 9292,
binaryPath: undefined,
},
): Promise<Client> {
if (!options.debuggerPort) options.debuggerPort = 9292;
if (!options.hostname) options.hostname = "localhost";
if (browser === "chrome") {
const args = getChromeArgs(options.debuggerPort, options.binaryPath);
return await Client.create(
args,
{
hostname: options.hostname,
port: options.debuggerPort,
},
browser,
undefined,
);
} else {
return await ChromeClient.build(options);
const tmpDirName = Deno.makeTempDirSync();
const args = getFirefoxArgs(
tmpDirName,
options.debuggerPort,
options.binaryPath,
);
return await Client.create(
args,
{
hostname: options.hostname,
port: options.debuggerPort,
},
browser,
tmpDirName,
);
}
}
84 changes: 0 additions & 84 deletions src/chrome_client.ts

This file was deleted.

Loading