argist-selenium/index.js

55 lines
1.0 KiB
JavaScript

const fs = require("fs");
const path = 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");
async function runFile(file)
{
let fileContext = fs.readFileSync(path.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
});
let scope = await runInContext(fileContext + '\n\nmain();', context);
}
process.nextTick(runFile,"./projects/index.js");