import BotphusCore, {TaskMessage, TaskType, TaskTypeDomSubType} from 'botphus-core';
const botphusCore = new BotphusCore();
(async () => {
const taskNo = await botphusCore.createTask('Test task', new Date().getTime(), [
{
argments: ['div'],
assertion: ['data === "wrong assertion rule"'],
subType: TaskTypeDomSubType.SUB_TYPE_GET_TEXT,
type: TaskType.TYPE_DOM
}
]);
const subProcess = await botphusCore.startTask(taskNo, 'https://bing.com/');
subProcess.on('message', ([error, messageData]: TaskMessage) => {
if (error) {
global.console.log(error.stack);
}
global.console.log(messageData);
});
subProcess.on('close', (code) => {
global.console.log('done:', code);
});
})();