argist-selenium/index.js

49 lines
977 B
JavaScript
Raw Normal View History

2023-03-19 13:55:55 +03:00
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
} = 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
});
let scope = await runInContext(fileContext + '\n\nmain();', context);
}
process.nextTick(runFile,"./projects/index.js");