This commit is contained in:
spiduler
2020-10-20 08:22:26 +09:00
parent e036759b15
commit d339563a4c

View File

@@ -6,11 +6,11 @@ const logger = require("logops")
, { Options } = require('selenium-webdriver/chrome');
class SeleniumBrowser {
constructor() {
constructor() {
this.config = { useHub: true, browser: 'chrome' }
this.capabilities = Capabilities.chrome()
this.sleep = m => new Promise(r => setTimeout(r, m))
this.isRecaptchaReseponseEmpty = false
this.isRecaptchaReseponseEmpty = false
}
getDriver() {
@@ -34,20 +34,9 @@ class SeleniumBrowser {
if (uri.indexOf('://') > 3) {
return this.getDriver().then(driver => {
return driver.get(uri)
.then(() => {
if (waitElement) {
return driver.wait(until.elementIsVisible(driver.findElement(By.css(waitElement))), 5 * 1000)
}
return true
})
.then(() => driver.findElement(By.css('body')))
.then(body => body.getAttribute('innerHTML'))
.then(html => this.getHtml(html))
.catch(error => {
return driver.findElement(By.css('body'))
.then(body => body.getAttribute('innerHTML'))
.then(html => this.getHtml(html))
})
.finally(() => {
driver.quit()
})