Skip to content

Commit

Permalink
Control browser from Node server
Browse files Browse the repository at this point in the history
  • Loading branch information
dnhn committed Apr 19, 2020
1 parent eacd00f commit 76da258
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 8 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const app = require('express')();
const proxy = require('express-http-proxy');
const webdriver = require('selenium-webdriver');
const browser = require('./browse');

const HOST = 'http://127.0.0.1';
const PORT = 4444;
Expand All @@ -16,6 +18,11 @@ app.use(proxy(FAH, {
}));
app.listen(PORT, () => console.log(`Proxy is running at ${HOST}:${PORT}\n`));

require('./browse');
browser.get(`${HOST}:${PORT}`);
browser.manage().window().minimize();

const keepAlive = browser.findElement(webdriver.By.id('slots'));

setInterval(() => keepAlive.click(), 120000);

module.exports = app;
7 changes: 1 addition & 6 deletions browse.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,4 @@ const driver = new webdriver.Builder()
.setChromeOptions({ args: ['--headless'] })
.build();

driver.get('http://127.0.0.1:4444');
driver.manage().window().minimize();

const keepAlive = driver.findElement(webdriver.By.id('slots'));

setInterval(() => keepAlive.click(), 120000);
module.exports = driver;

0 comments on commit 76da258

Please sign in to comment.