sdf
This commit is contained in:
@@ -19,6 +19,7 @@ class SeleniumBrowser {
|
||||
return this.getDriver();
|
||||
},
|
||||
destroy: function (driver) {
|
||||
driver.close()
|
||||
driver.quit()
|
||||
}
|
||||
}, {
|
||||
@@ -35,6 +36,11 @@ class SeleniumBrowser {
|
||||
this.pool.on('factoryDestroyError', function (err) {
|
||||
logger.error(err.message, 'pool error')
|
||||
})
|
||||
|
||||
this.pool.use(async driver => {
|
||||
let session = await driver.getSession()
|
||||
return session && session.getId() ? driver : this.getDriver()
|
||||
}).then(/* a promise that will run after myTask resolves */)
|
||||
}
|
||||
|
||||
getDriver() {
|
||||
@@ -60,8 +66,9 @@ class SeleniumBrowser {
|
||||
.then(body => body.getAttribute('innerHTML'))
|
||||
let htmlPromise = this.isCaptchaPage(html) ? this.resolveCaptcha(driver) : this.getHtml(driver, html, params)
|
||||
html = await htmlPromise
|
||||
driver.close()
|
||||
driver.quit()
|
||||
this.pool.destroy(driver)
|
||||
this.pool.release(driver)
|
||||
return html
|
||||
})
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user