Compare commits
10 Commits
dd6d5b1100
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3d8116db2 | ||
|
|
4db81f2251 | ||
|
|
78c0d08fa8 | ||
|
|
8a2473d62d | ||
|
|
55f3ea9f33 | ||
|
|
eb376638cd | ||
|
|
7ee8c2c9a0 | ||
|
|
ba64a18e18 | ||
|
|
eacfb5ebf0 | ||
|
|
116e3e5878 |
@@ -5,7 +5,7 @@ class Config {
|
||||
|
||||
constructor() {
|
||||
this.options = {}
|
||||
this.requires = ['env', 'gateway', 'quix24']
|
||||
this.requires = []
|
||||
this.init()
|
||||
this.validate()
|
||||
this.finalize()
|
||||
|
||||
4
index.js
4
index.js
@@ -26,7 +26,7 @@ var app = express();
|
||||
app.use(express.json());
|
||||
app.use(expressLogging(logger));
|
||||
app.listen(port, () => {
|
||||
logger.info({ app: 'Headless browser' }, 'Startup');
|
||||
logger.info('Browser service started');
|
||||
});
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ process.on('SIGTERM', exitHandler.bind(null, { cleanup: true }));
|
||||
*/
|
||||
app.post('/', async (req, res, next) => {
|
||||
browser.get(req.body).then(result => {
|
||||
typeof html == 'string' ? res.send(result) : res.json(result)
|
||||
typeof result == 'string' ? res.send(result) : res.json(result)
|
||||
}).catch(e => {
|
||||
logger.error({ message: e.message, info: e.info }, 'Browser error')
|
||||
res.status(500).send({ code: 500, message: e.message })
|
||||
|
||||
@@ -8,7 +8,7 @@ class NavigateService {
|
||||
constructor() {
|
||||
this.config = {
|
||||
browser: 'chrome',
|
||||
hub: 'http://spiduler-chrome:4444/wd/hub',
|
||||
hub: 'http://bro-chrome:4444/wd/hub',
|
||||
capabilities: Capabilities.chrome(),
|
||||
browserArgs: ['--no-sandbox', '--headless', '--disable-dev-shm-usage']
|
||||
}
|
||||
@@ -19,7 +19,14 @@ class NavigateService {
|
||||
}
|
||||
|
||||
page(params) {
|
||||
return this._getDriver(params).then(driver => driver.findElement(By.css('body')).then(body => body.getAttribute('innerHTML')))
|
||||
return this._getDriver(params)
|
||||
.then(driver => {
|
||||
return driver.get(params.uri).then(() => driver.findElement(By.css('body'))
|
||||
.then(body => {
|
||||
console.log(body.getTagName())
|
||||
return body.getAttribute('innerHTML')
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
login(params) {
|
||||
@@ -31,12 +38,10 @@ class NavigateService {
|
||||
driver.actions().move({ origin: username }).perform()
|
||||
await username.sendKeys(params.key.username)
|
||||
await password.sendKeys(params.key.password)
|
||||
// logger.info({ currentUrl: await driver.getCurrentUrl(), sessionId: await driver.getSession() }, 'aaaaa')
|
||||
// return submit.click()
|
||||
// WebElement
|
||||
return submit.click().then(() => driver.findElement(By.css('body')))
|
||||
// return submit.click().then(() => driver.findElement(By.css('body')))
|
||||
return submit.click()
|
||||
}).then(async body => {
|
||||
return body.getAttribute('innerHTML')
|
||||
// return body.getAttribute('innerHTML')
|
||||
return { currentUrl: await driver.getCurrentUrl(), sessionId: await driver.getSession() }
|
||||
})
|
||||
})
|
||||
@@ -47,7 +52,7 @@ class NavigateService {
|
||||
}
|
||||
|
||||
async _getDriverExists(params) {
|
||||
return new WebDriver(new Session(params.sessionId, this.config.capabilities), new _http.Executor(Promise.resolve(this.config.hub)
|
||||
return new WebDriver(params.sessionId, new _http.Executor(Promise.resolve(this.config.hub)
|
||||
.then(url => new _http.HttpClient(url, null, null))))
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class PoolingService {
|
||||
this.config = {
|
||||
pool: { max: 10, min: 1, testOnBorrow: true },
|
||||
browser: 'chrome',
|
||||
browserArgs: ['--no-sandbox', '--headless', '--disable-dev-shm-usage', '--proxy-server=spiduler-tor:8118']
|
||||
browserArgs: ['--no-sandbox', '--headless', '--disable-dev-shm-usage', '--proxy-server=bro-tor:8118']
|
||||
}
|
||||
this.pool = this.createPool()
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class PoolingService {
|
||||
let capabilities = Capabilities.chrome()
|
||||
opts.addArguments(this.config.browserArgs)
|
||||
return new Builder()
|
||||
.usingServer('http://spiduler-chrome:4444/wd/hub')
|
||||
.usingServer('http://bro-chrome:4444/wd/hub')
|
||||
.withCapabilities(capabilities)
|
||||
.forBrowser(this.config.browser)
|
||||
.setChromeOptions(opts)
|
||||
|
||||
Reference in New Issue
Block a user