evs-chris / automatonic Goto Github PK
View Code? Open in Web Editor NEWBrowser automation as an electron library
Browser automation as an electron library
I was just poking around looking for solutions to automate an electron app. Are you still maintaining/using this?
In the readme you mention:
You can't use Nightmare.js from within an Electron app.
But it looks like this is no longer the case
Hi. im using electron v1.6.11
when i using Auto
function outside app.on('ready',...) it work OK, but i using auto inside it, it not working
Here is my code:
const {app, BrowserWindow} = require('electron')
const path = require('path')
const url = require('url')
const { Browser, run, sleep } = require('automatonic');
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win;
function Auto(){
console.log("begin");
run(function*() {
const I = new Browser();
console.log("start");
I.goto('https://google.com');
// let's give 'em a second to settle
yield sleep(1000);
// do a search
I.type('#lst-ib', 'automatonic\n');
I.click('button[name=btnG]');
// wait for a result and grab its title
I.waitFor('h3.r a');
const first = yield I.execute(function() {
return document.querySelector('h3.r a').innerText;
});
if (~first.toLowerCase().indexOf('wikipedia')) {
console.log("hey look, it's a Wikipedia link");
} else {
console.log("it's not a Wikipedia link, let's click it");
I.click('h3.r a');
}
yield sleep(20000);
I.close();
}).then(null, err => {
console.error('OH NOES!', err);
});
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', ()=>{
Auto(); // it not work!
})
// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit()
}
})
//Auto(); //it work
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.