argist-selenium/index.js

65 lines
1.2 KiB
JavaScript

const fs = require("fs");
const {resolve} = require("path");
const {
createContext,
runInContext
} = require("vm");
const {
StartSelenium,
ClearElement,
ClickElement,
CreateTab,
GetAttribute,
SubmitElement,
WaitElement,
WriteElement,
Navigate,
goTab,
GoLastTab,
GoFirstTab,
NextTab,
PrevTab,
GetCurrentTabIndex,
GoBack,
GoForward,
Refresh
} = require("./Core/index");
const {
knex
} = require("knex");
const DB = knex({
client: "sqlite3",
connection:{
filename: resolve("./data/database.db")
}
});
async function runFile(file)
{
let fileContext = fs.readFileSync(resolve(file),"utf-8");
let context = createContext({
StartSelenium,
ClearElement,
ClickElement,
CreateTab,
GetAttribute,
SubmitElement,
WaitElement,
WriteElement,
Navigate,
goTab,
GoLastTab,
GoFirstTab,
NextTab,
PrevTab,
GetCurrentTabIndex,
GoBack,
GoForward,
Refresh,
DB
});
await runInContext(fileContext + '\n\nmain();', context);
}
process.nextTick(runFile,"./projects/index.js");