update
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
const { Builder, By, Key, until } = require('selenium-webdriver')
|
||||
const chrome = require('selenium-webdriver/chrome')
|
||||
const firefox = require('selenium-webdriver/firefox')
|
||||
const config = require('../config')
|
||||
|
||||
const setsUrl = 'https://www.echomtg.com/sets/'
|
||||
|
||||
const setsClass = '.main.marketAnalysis.sets'
|
||||
|
||||
|
||||
module.exports.getDriver = async () => {
|
||||
if (!/^(firefox|chrome)$/i.test(config.browser)) {
|
||||
throw new Error('browser type not support')
|
||||
}
|
||||
let opts = null
|
||||
let driver = null
|
||||
if (/firefox/i.test(config.browser)) {
|
||||
opts = new firefox.Options()
|
||||
opts.headless()
|
||||
if (config.firefox_path.length > 0) {
|
||||
opts.setBinary(config.firefox_path)
|
||||
}
|
||||
driver = await new Builder().forBrowser('firefox').setFirefoxOptions(opts).build()
|
||||
} else if (/chrome/i.test(config.browser)) {
|
||||
opts = new chrome.Options()
|
||||
opts.headless()
|
||||
if (config.chrome_path.length > 0) {
|
||||
opts.setChromeBinaryPath(config.chrome_path)
|
||||
}
|
||||
driver = await new Builder().forBrowser('chrome').setChromeOptions(opts).build()
|
||||
} else {
|
||||
throw new Error('browser type not support')
|
||||
}
|
||||
return driver
|
||||
}
|
||||
Reference in New Issue
Block a user