ewrewr
This commit is contained in:
59
test.js
Normal file
59
test.js
Normal file
@@ -0,0 +1,59 @@
|
||||
const logger = require("logops")
|
||||
, { Builder, Capabilities, By, Key, until } = require('selenium-webdriver')
|
||||
, url = require('url')
|
||||
, fetch = require('node-fetch')
|
||||
, pool = require('generic-pool')
|
||||
, { Options } = require('selenium-webdriver/chrome');
|
||||
|
||||
|
||||
|
||||
|
||||
class Test {
|
||||
|
||||
constructor() {
|
||||
this.config = {
|
||||
useHub: true, browser: 'chrome',
|
||||
browserArgs: ['--no-sandbox', '--headless', '--disable-dev-shm-usage', '--proxy-server=spiduler-tor:8118']
|
||||
}
|
||||
this.capabilities = Capabilities.chrome()
|
||||
|
||||
this.getDriver().then(driver => {
|
||||
driver.get('https://www.naver.com/')
|
||||
.then(() => driver.findElement(By.css('body')))
|
||||
.then(body => body.getAttribute('innerHTML'))
|
||||
driver.getSession().then(s => {
|
||||
let id = s.getId()
|
||||
console.log(id)
|
||||
// driver.close()
|
||||
// driver.quit()
|
||||
driver.get('https://www.naver.com/')
|
||||
.then(() => driver.findElement(By.css('body')))
|
||||
.then(body => body.getAttribute('innerHTML'))
|
||||
.finally(() => {
|
||||
// driver.close().then(a => console.log(a))
|
||||
driver.quit().then(q => console.log(q))
|
||||
})
|
||||
// driver.quit()
|
||||
return ''
|
||||
}).catch(err => {
|
||||
console.log(err.message)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
async getDriver() {
|
||||
let opts = new Options;
|
||||
opts.addArguments(this.config.browserArgs)
|
||||
return new Builder()
|
||||
.usingServer('http://spiduler-chrome:4444/wd/hub')
|
||||
.withCapabilities(this.capabilities)
|
||||
.forBrowser(this.config.browser)
|
||||
.setChromeOptions(opts)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
const test = new Test
|
||||
|
||||
Reference in New Issue
Block a user