@airtop/plugin-selenium 1.0.0-alpha2.1 → 1.0.0-alpha2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Airtop Selenium Plugin
|
|
2
|
+
|
|
3
|
+
This plugin adds Selenium support to the Airtop SDK.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @airtop/sdk @airtop/plugin-selenium selenium-webdriver
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { registerAirtopPlugin } from "@airtop/sdk";
|
|
15
|
+
import { seleniumPlugin } from "@airtop/plugin-selenium";
|
|
16
|
+
|
|
17
|
+
registerAirtopPlugin(seleniumPlugin);
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Docs
|
|
21
|
+
|
|
22
|
+
Visit the docs [here](https://docs-v2.airtop.ai/sdk/typescript/@airtop/plugin-selenium/interfaces/SeleniumPluginMethods/).
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/airtop-sdk/airtop-sdk/typescript/packages/plugins/selenium/dist/index.cjs","../src/index.ts"],"names":[],"mappings":"AAAA;ACAA,kCAA6C;
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/airtop-sdk/airtop-sdk/typescript/packages/plugins/selenium/dist/index.cjs","../src/index.ts"],"names":[],"mappings":"AAAA;ACAA,kCAA6C;AA2D7C,MAAA,SAAe,yBAAA,CACb,MAAA,EACA,OAAA,EACA,MAAA,EACA;AAEA,EAAA,MAAM,mBAAA,EAAA,CAAsB,MAAM,MAAA,CAAO,UAAA,CAAW,CAAA,CAAA,CAAG,KAAA,CAAM,CAAA;AAC7D,EAAA,GAAA,CAAI,CAAC,kBAAA,EAAoB;AACvB,IAAA,MAAM,IAAI,KAAA,CAAM,gCAAgC,CAAA;AAAA,EAClD;AACA,EAAA,MAAM,uBAAA,EAAyB,CAAA,EAAA;AACF,EAAA;AACnB,IAAA;AACC,IAAA;AACS,MAAA;AACS,MAAA;AAC3B,IAAA;AACqB,IAAA;AACd,MAAA;AACI,MAAA;AACV,IAAA;AACF,EAAA;AAEoB,EAAA;AACvB;AAEoC;AAChB,EAAA;AACsC,EAAA;AAC5C,IAAA;AAKY,MAAA;AACC,MAAA;AAEI,MAAA;AAEV,MAAA;AACG,QAAA;AAClB,MAAA;AAEkB,MAAA;AACpB,IAAA;AACF,EAAA;AACF;AAK2D;AAClD,EAAA;AACgB,IAAA;AACvB,EAAA;AACF;AD1EkC;AACA;AACA","file":"/home/runner/work/airtop-sdk/airtop-sdk/typescript/packages/plugins/selenium/dist/index.cjs","sourcesContent":[null,"import { AirtopPluginAugmentationType } from \"@airtop/sdk\";\nimport type {\n AirtopPluginRegistration,\n AirtopRequestOptions,\n AirtopSession,\n AirtopSessionPlugin,\n AirtopWindow,\n ExternalSessionWithConnectionInfo,\n WindowGetConfig,\n} from \"@airtop/sdk\";\nimport type { AirtopWindowGetInfoResponse } from \"@airtop/sdk\";\n\ndeclare namespace seleniumWebdriver {\n interface WebDriver {\n getSession(): Promise<any>;\n createCDPConnection(domain: string): Promise<any>;\n }\n}\n\n// This is exported so the docs can expose it as we can't generate docs against the\n// module declaration\n/**\n * The methods provided by the Selenium plugin.\n */\nexport interface SeleniumPluginMethods {\n /**\n * Get the window information for a Selenium Page instance.\n *\n * @param driver The Selenium WebDriver instance.\n * @param options Configuration options for the window info request.\n * @param requestOptions Additional options to customize the request behavior.\n *\n * @example\n * // AirtopSession instance\n * session.getWindowForSeleniumDriver(driver, options, requestOptions);\n */\n getWindowForSeleniumDriver(\n driver: seleniumWebdriver.WebDriver,\n options?: WindowGetConfig,\n requestOptions?: AirtopRequestOptions,\n ): Promise<AirtopWindow<AirtopWindowGetInfoResponse>>;\n}\n\ndeclare module \"@airtop/sdk\" {\n interface AirtopSession {\n /**\n * Get the window information for a Selenium Page instance.\n * @param driver The Selenium WebDriver instance.\n * @param options Configuration options for the window info request.\n * @param requestOptions Additional options to customize the request behavior.\n */\n getWindowForSeleniumDriver(\n driver: seleniumWebdriver.WebDriver,\n options?: WindowGetConfig,\n requestOptions?: AirtopRequestOptions,\n ): Promise<AirtopWindow<AirtopWindowGetInfoResponse>>;\n }\n}\n\nasync function executeSeleniumCDPCommand(\n driver: seleniumWebdriver.WebDriver,\n session: ExternalSessionWithConnectionInfo,\n apiKey: string,\n) {\n // Get the current WebDriver session ID\n const webDriverSessionId = (await driver.getSession()).getId();\n if (!webDriverSessionId) {\n throw new Error(\"No WebDriver session available\");\n }\n const chromedriverSessionUrl = `${session.chromedriverUrl}/session/${webDriverSessionId}/chromium/send_command_and_get_result`;\n const response = await fetch(chromedriverSessionUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${apiKey}`,\n },\n body: JSON.stringify({\n cmd: \"Target.getTargetInfo\",\n params: {},\n }),\n });\n\n return response.json();\n}\n\nconst plugin: AirtopSessionPlugin = {\n augmentationType: AirtopPluginAugmentationType.AirtopSession,\n augment: (prototype: typeof AirtopSession.prototype) => {\n prototype.getWindowForSeleniumDriver = async function (\n driver: seleniumWebdriver.WebDriver,\n options: WindowGetConfig,\n requestOptions: AirtopRequestOptions,\n ) {\n const apiKey = this.getApiKey();\n const result = await executeSeleniumCDPCommand(driver, this.data, apiKey || \"\");\n // @ts-ignore\n const targetId = result?.value?.targetInfo?.targetId;\n\n if (!targetId) {\n throw new Error(\"TargetId not found\");\n }\n\n return await this.withWindowId(targetId).getWindowInfo(options, requestOptions);\n };\n },\n};\n\n/**\n * Use with registerAirtopPlugin() from the Airtop SDK to add the Selenium plugin.\n */\nexport function seleniumPlugin(): AirtopPluginRegistration {\n return {\n pluginsToAdd: [plugin],\n };\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -12,9 +12,14 @@ declare namespace seleniumWebdriver {
|
|
|
12
12
|
interface SeleniumPluginMethods {
|
|
13
13
|
/**
|
|
14
14
|
* Get the window information for a Selenium Page instance.
|
|
15
|
-
*
|
|
15
|
+
*
|
|
16
|
+
* @param driver The Selenium WebDriver instance.
|
|
16
17
|
* @param options Configuration options for the window info request.
|
|
17
18
|
* @param requestOptions Additional options to customize the request behavior.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // AirtopSession instance
|
|
22
|
+
* session.getWindowForSeleniumDriver(driver, options, requestOptions);
|
|
18
23
|
*/
|
|
19
24
|
getWindowForSeleniumDriver(driver: seleniumWebdriver.WebDriver, options?: WindowGetConfig, requestOptions?: AirtopRequestOptions): Promise<AirtopWindow<AirtopWindowGetInfoResponse>>;
|
|
20
25
|
}
|
|
@@ -22,7 +27,7 @@ declare module "@airtop/sdk" {
|
|
|
22
27
|
interface AirtopSession {
|
|
23
28
|
/**
|
|
24
29
|
* Get the window information for a Selenium Page instance.
|
|
25
|
-
* @param driver The Selenium
|
|
30
|
+
* @param driver The Selenium WebDriver instance.
|
|
26
31
|
* @param options Configuration options for the window info request.
|
|
27
32
|
* @param requestOptions Additional options to customize the request behavior.
|
|
28
33
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -12,9 +12,14 @@ declare namespace seleniumWebdriver {
|
|
|
12
12
|
interface SeleniumPluginMethods {
|
|
13
13
|
/**
|
|
14
14
|
* Get the window information for a Selenium Page instance.
|
|
15
|
-
*
|
|
15
|
+
*
|
|
16
|
+
* @param driver The Selenium WebDriver instance.
|
|
16
17
|
* @param options Configuration options for the window info request.
|
|
17
18
|
* @param requestOptions Additional options to customize the request behavior.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // AirtopSession instance
|
|
22
|
+
* session.getWindowForSeleniumDriver(driver, options, requestOptions);
|
|
18
23
|
*/
|
|
19
24
|
getWindowForSeleniumDriver(driver: seleniumWebdriver.WebDriver, options?: WindowGetConfig, requestOptions?: AirtopRequestOptions): Promise<AirtopWindow<AirtopWindowGetInfoResponse>>;
|
|
20
25
|
}
|
|
@@ -22,7 +27,7 @@ declare module "@airtop/sdk" {
|
|
|
22
27
|
interface AirtopSession {
|
|
23
28
|
/**
|
|
24
29
|
* Get the window information for a Selenium Page instance.
|
|
25
|
-
* @param driver The Selenium
|
|
30
|
+
* @param driver The Selenium WebDriver instance.
|
|
26
31
|
* @param options Configuration options for the window info request.
|
|
27
32
|
* @param requestOptions Additional options to customize the request behavior.
|
|
28
33
|
*/
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { AirtopPluginAugmentationType } from \"@airtop/sdk\";\nimport type {\n AirtopPluginRegistration,\n AirtopRequestOptions,\n AirtopSession,\n AirtopSessionPlugin,\n AirtopWindow,\n ExternalSessionWithConnectionInfo,\n WindowGetConfig,\n} from \"@airtop/sdk\";\nimport type { AirtopWindowGetInfoResponse } from \"@airtop/sdk\";\n\ndeclare namespace seleniumWebdriver {\n interface WebDriver {\n getSession(): Promise<any>;\n createCDPConnection(domain: string): Promise<any>;\n }\n}\n\n// This is exported so the docs can expose it as we can't generate docs against the\n// module declaration\n/**\n * The methods provided by the Selenium plugin.\n */\nexport interface SeleniumPluginMethods {\n /**\n * Get the window information for a Selenium Page instance.\n * @param driver The Selenium
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { AirtopPluginAugmentationType } from \"@airtop/sdk\";\nimport type {\n AirtopPluginRegistration,\n AirtopRequestOptions,\n AirtopSession,\n AirtopSessionPlugin,\n AirtopWindow,\n ExternalSessionWithConnectionInfo,\n WindowGetConfig,\n} from \"@airtop/sdk\";\nimport type { AirtopWindowGetInfoResponse } from \"@airtop/sdk\";\n\ndeclare namespace seleniumWebdriver {\n interface WebDriver {\n getSession(): Promise<any>;\n createCDPConnection(domain: string): Promise<any>;\n }\n}\n\n// This is exported so the docs can expose it as we can't generate docs against the\n// module declaration\n/**\n * The methods provided by the Selenium plugin.\n */\nexport interface SeleniumPluginMethods {\n /**\n * Get the window information for a Selenium Page instance.\n *\n * @param driver The Selenium WebDriver instance.\n * @param options Configuration options for the window info request.\n * @param requestOptions Additional options to customize the request behavior.\n *\n * @example\n * // AirtopSession instance\n * session.getWindowForSeleniumDriver(driver, options, requestOptions);\n */\n getWindowForSeleniumDriver(\n driver: seleniumWebdriver.WebDriver,\n options?: WindowGetConfig,\n requestOptions?: AirtopRequestOptions,\n ): Promise<AirtopWindow<AirtopWindowGetInfoResponse>>;\n}\n\ndeclare module \"@airtop/sdk\" {\n interface AirtopSession {\n /**\n * Get the window information for a Selenium Page instance.\n * @param driver The Selenium WebDriver instance.\n * @param options Configuration options for the window info request.\n * @param requestOptions Additional options to customize the request behavior.\n */\n getWindowForSeleniumDriver(\n driver: seleniumWebdriver.WebDriver,\n options?: WindowGetConfig,\n requestOptions?: AirtopRequestOptions,\n ): Promise<AirtopWindow<AirtopWindowGetInfoResponse>>;\n }\n}\n\nasync function executeSeleniumCDPCommand(\n driver: seleniumWebdriver.WebDriver,\n session: ExternalSessionWithConnectionInfo,\n apiKey: string,\n) {\n // Get the current WebDriver session ID\n const webDriverSessionId = (await driver.getSession()).getId();\n if (!webDriverSessionId) {\n throw new Error(\"No WebDriver session available\");\n }\n const chromedriverSessionUrl = `${session.chromedriverUrl}/session/${webDriverSessionId}/chromium/send_command_and_get_result`;\n const response = await fetch(chromedriverSessionUrl, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${apiKey}`,\n },\n body: JSON.stringify({\n cmd: \"Target.getTargetInfo\",\n params: {},\n }),\n });\n\n return response.json();\n}\n\nconst plugin: AirtopSessionPlugin = {\n augmentationType: AirtopPluginAugmentationType.AirtopSession,\n augment: (prototype: typeof AirtopSession.prototype) => {\n prototype.getWindowForSeleniumDriver = async function (\n driver: seleniumWebdriver.WebDriver,\n options: WindowGetConfig,\n requestOptions: AirtopRequestOptions,\n ) {\n const apiKey = this.getApiKey();\n const result = await executeSeleniumCDPCommand(driver, this.data, apiKey || \"\");\n // @ts-ignore\n const targetId = result?.value?.targetInfo?.targetId;\n\n if (!targetId) {\n throw new Error(\"TargetId not found\");\n }\n\n return await this.withWindowId(targetId).getWindowInfo(options, requestOptions);\n };\n },\n};\n\n/**\n * Use with registerAirtopPlugin() from the Airtop SDK to add the Selenium plugin.\n */\nexport function seleniumPlugin(): AirtopPluginRegistration {\n return {\n pluginsToAdd: [plugin],\n };\n}\n"],"mappings":";AAAA,SAAS,oCAAoC;AA2D7C,eAAe,0BACb,QACA,SACA,QACA;AAEA,QAAM,sBAAsB,MAAM,OAAO,WAAW,GAAG,MAAM;AAC7D,MAAI,CAAC,oBAAoB;AACvB,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AACA,QAAM,yBAAyB,GAAG,QAAQ,eAAe,YAAY,kBAAkB;AACvF,QAAM,WAAW,MAAM,MAAM,wBAAwB;AAAA,IACnD,QAAQ;AAAA,IACR,SAAS;AAAA,MACP,gBAAgB;AAAA,MAChB,eAAe,UAAU,MAAM;AAAA,IACjC;AAAA,IACA,MAAM,KAAK,UAAU;AAAA,MACnB,KAAK;AAAA,MACL,QAAQ,CAAC;AAAA,IACX,CAAC;AAAA,EACH,CAAC;AAED,SAAO,SAAS,KAAK;AACvB;AAEA,IAAM,SAA8B;AAAA,EAClC,kBAAkB,6BAA6B;AAAA,EAC/C,SAAS,CAAC,cAA8C;AACtD,cAAU,6BAA6B,eACrC,QACA,SACA,gBACA;AACA,YAAM,SAAS,KAAK,UAAU;AAC9B,YAAM,SAAS,MAAM,0BAA0B,QAAQ,KAAK,MAAM,UAAU,EAAE;AAE9E,YAAM,WAAW,QAAQ,OAAO,YAAY;AAE5C,UAAI,CAAC,UAAU;AACb,cAAM,IAAI,MAAM,oBAAoB;AAAA,MACtC;AAEA,aAAO,MAAM,KAAK,aAAa,QAAQ,EAAE,cAAc,SAAS,cAAc;AAAA,IAChF;AAAA,EACF;AACF;AAKO,SAAS,iBAA2C;AACzD,SAAO;AAAA,IACL,cAAc,CAAC,MAAM;AAAA,EACvB;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@airtop/plugin-selenium",
|
|
3
3
|
"description": "Adds Selenium support to the Airtop SDK",
|
|
4
|
-
"version": "1.0.0-alpha2.
|
|
4
|
+
"version": "1.0.0-alpha2.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"selenium-webdriver": ">=4.25.0",
|
|
37
|
-
"@airtop/sdk": "1.0.0-alpha2.
|
|
37
|
+
"@airtop/sdk": "1.0.0-alpha2.1"
|
|
38
38
|
},
|
|
39
39
|
"bugs": "https://github.com/airtop-ai/airtop-sdk/issues",
|
|
40
40
|
"engines": {
|