This commit is contained in:
spiduler
2020-10-20 08:18:46 +09:00
parent 7de1f460f0
commit e036759b15

View File

@@ -6,11 +6,11 @@ const logger = require("logops")
, { Options } = require('selenium-webdriver/chrome'); , { Options } = require('selenium-webdriver/chrome');
class SeleniumBrowser { class SeleniumBrowser {
constructor() { constructor() {
this.config = { useHub: true, browser: 'chrome' } this.config = { useHub: true, browser: 'chrome' }
this.capabilities = Capabilities.chrome() this.capabilities = Capabilities.chrome()
this.sleep = m => new Promise(r => setTimeout(r, m)) this.sleep = m => new Promise(r => setTimeout(r, m))
this.isRecaptchaReseponseEmpty = false this.isRecaptchaReseponseEmpty = false
} }
getDriver() { getDriver() {
@@ -43,6 +43,11 @@ class SeleniumBrowser {
.then(() => driver.findElement(By.css('body'))) .then(() => driver.findElement(By.css('body')))
.then(body => body.getAttribute('innerHTML')) .then(body => body.getAttribute('innerHTML'))
.then(html => this.getHtml(html)) .then(html => this.getHtml(html))
.catch(error => {
return driver.findElement(By.css('body'))
.then(body => body.getAttribute('innerHTML'))
.then(html => this.getHtml(html))
})
.finally(() => { .finally(() => {
driver.quit() driver.quit()
}) })