Skip to content
This repository was archived by the owner on Nov 24, 2018. It is now read-only.

Commit

Permalink
First working remote version
Browse files Browse the repository at this point in the history
  • Loading branch information
timsuchanek committed Jun 7, 2017
1 parent e8bb51c commit b2e8b13
Show file tree
Hide file tree
Showing 19 changed files with 1,459 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules
.idea
lib
.DS_Store
57 changes: 57 additions & 0 deletions cookies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[
{
"name": "intercom-session-rqszgt2h",
"value": "S3BZL2Q0UE1NcDc2emsxUCt2cTBBcHl0Q3RTNEFzeEt4eVZCZTkwN0YyOVFNYmlMc0NZNmZOKzFqdkRQdjY5Qi0tU3lzTHljYVRVMWRwTG1qS0d0VlBaZz09--20630c992c745b19b7540a19563ce6464b39de92",
"domain": "localhost",
"path": "/",
"expires": 1497431120000,
"size": 187,
"httpOnly": false,
"secure": false,
"session": false
},
{
"name": "graphcool_last_used_project_id",
"value": "cj3kcpmaf00gs0101thxas06m",
"domain": "localhost",
"path": "/",
"expires": 1504602319000,
"size": 55,
"httpOnly": false,
"secure": false,
"session": false
},
{
"name": "graphcool_customer_id",
"value": "cj3kcpmai00gt0101zf5np9hj",
"domain": "localhost",
"path": "/",
"expires": 1504602318000,
"size": 46,
"httpOnly": false,
"secure": false,
"session": false
},
{
"name": "graphcool_auth_token",
"value": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE0OTY4MjYzMTcsImNsaWVudElkIjoiY2oza2NwbWFpMDBndDAxMDF6ZjVucDloaiJ9.jAl-nb8NtZGUiI4dPZWLWjfeu-90RbLq1bPtS4X7RdI",
"domain": "localhost",
"path": "/",
"expires": 1504602318000,
"size": 177,
"httpOnly": false,
"secure": false,
"session": false
},
{
"name": "graphcool_last_referral",
"value": "",
"domain": "localhost",
"path": "/",
"expires": 1504602260000,
"size": 23,
"httpOnly": false,
"secure": false,
"session": false
}
]
6 changes: 3 additions & 3 deletions jobs.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
[
{
"fn": "function (client, url) { return tslib_1.__awaiter(_this, void 0, void 0, function () {\n var Network, Page, e_1;\n return tslib_1.__generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n Network = client.Network, Page = client.Page;\n _a.label = 1;\n case 1:\n _a.trys.push([1, 6, , 7]);\n return [4 /*yield*/, Promise.all([Network.enable(), Page.enable()])];\n case 2:\n _a.sent();\n return [4 /*yield*/, Page.navigate({ url: url })];\n case 3:\n _a.sent();\n return [4 /*yield*/, Page.loadEventFired()];\n case 4:\n _a.sent();\n return [4 /*yield*/, util_1.wait(500)];\n case 5:\n _a.sent();\n console.log('Navigated to', url);\n return [3 /*break*/, 7];\n case 6:\n e_1 = _a.sent();\n console.error(e_1);\n return [3 /*break*/, 7];\n case 7: return [2 /*return*/];\n }\n });\n }); }",
"fn": "function (client, url) { return __awaiter(_this, void 0, void 0, function () {\n var Network, Page, e_1;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n Network = client.Network, Page = client.Page;\n _a.label = 1;\n case 1:\n _a.trys.push([1, 6, , 7]);\n return [4 /*yield*/, Promise.all([Network.enable(), Page.enable()])];\n case 2:\n _a.sent();\n return [4 /*yield*/, Page.navigate({ url: url })];\n case 3:\n _a.sent();\n return [4 /*yield*/, Page.loadEventFired()];\n case 4:\n _a.sent();\n return [4 /*yield*/, util_1.wait(500)];\n case 5:\n _a.sent();\n console.log('Navigated to', url);\n return [3 /*break*/, 7];\n case 6:\n e_1 = _a.sent();\n console.error(e_1);\n return [3 /*break*/, 7];\n case 7: return [2 /*return*/];\n }\n });\n }); }",
"args": {
"url": "http://localhost:8064"
}
},
{
"fn": "function (client, selector, artificialClick) { return tslib_1.__awaiter(_this, void 0, void 0, function () {\n var exists, fakeClick;\n return tslib_1.__generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, util_1.nodeExists(client, selector)];\n case 1:\n exists = _a.sent();\n if (!exists) {\n throw new Error(\"click(): node for selector \" + selector + \" doesn't exist\");\n }\n fakeClick = typeof artificialClick === 'boolean' ? artificialClick : this.options.useArtificialClick;\n return [4 /*yield*/, util_1.click(client, fakeClick, selector)];\n case 2:\n _a.sent();\n console.log('Clicked on ', selector);\n return [2 /*return*/];\n }\n });\n }); }",
"fn": "function (client, selector, artificialClick) { return __awaiter(_this, void 0, void 0, function () {\n var exists, fakeClick;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, util_1.nodeExists(client, selector)];\n case 1:\n exists = _a.sent();\n if (!exists) {\n throw new Error(\"click(): node for selector \" + selector + \" doesn't exist\");\n }\n fakeClick = typeof artificialClick === 'boolean' ? artificialClick : this.options.useArtificialClick;\n return [4 /*yield*/, util_1.click(client, fakeClick, selector)];\n case 2:\n _a.sent();\n console.log('Clicked on ', selector);\n return [2 /*return*/];\n }\n });\n }); }",
"args": {
"selector": "#submit"
}
},
{
"fn": "function (client, selector) { return tslib_1.__awaiter(_this, void 0, void 0, function () {\n return tslib_1.__generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n console.log(\"Waiting for \" + selector);\n return [4 /*yield*/, util_1.waitForNode(client, selector, this.options.waitTimeout)];\n case 1:\n _a.sent();\n console.log(\"Waited for \" + selector);\n return [2 /*return*/];\n }\n });\n }); }",
"fn": "function (client, selector) { return __awaiter(_this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n console.log(\"Waiting for \" + selector);\n return [4 /*yield*/, util_1.waitForNode(client, selector, this.options.waitTimeout)];\n case 1:\n _a.sent();\n console.log(\"Waited for \" + selector);\n return [2 /*return*/];\n }\n });\n }); }",
"args": {
"selector": "div"
}
Expand Down
40 changes: 40 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
export interface Options {
useArtificialClick?: boolean;
closeTab?: boolean;
waitTimeout?: number;
runRemote?: boolean;
}
declare class Chromeless {
private options;
private cdp;
private queue;
private client;
private processCallback;
private lastValue;
private target;
static functionUrl: string;
constructor(options?: Options);
goto(url: string): Chromeless;
click(selector: string, artificialClick?: boolean): Chromeless;
type(text: string, selector?: string): Chromeless;
backspace(n: number, selector?: string): Chromeless;
getCookies(url: string): Chromeless;
setCookies(cookies: any[], url: string): Chromeless;
clearCookies(): Chromeless;
sendKeyCode(keyCode: number, selector?: string, modifiers?: number): Chromeless;
wait(selector: string | number): Chromeless;
evaluate(fn: string | (() => void)): Chromeless;
value(selector: string): Chromeless;
screenshot(outputPath: string): Chromeless;
processJobs(jobs: any[]): Promise<any>;
end(): Promise<any>;
private processRemote();
private processLocal();
saveJobs(path: any): Promise<void>;
private serializeJobs();
private getSerializableJobs();
private deserializeJobs(jobs);
private prepareFunction(job);
private extractFunctionBody(fn);
}
export default Chromeless;
Loading

0 comments on commit b2e8b13

Please sign in to comment.