为什么我的Chrome个人资料无法连接? 我打开浏览器并登录到我的Google帐户(用我自己的双手,没有网络驱动程序),然后将我的Chrome配置文件连接到脚本中,并且理论上Selenium应该已经登录到我的Google帐户,但这不是发生。
代码:
const {Builder, By} = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
const until = require('selenium-webdriver/lib/until');
const screen = {
width: 1240,
height: 720
};
let option = new chrome.Options().addArguments("user-data-dir=C:\\Users\\Kulic\\AppData\\Local\\Google\\Chrome\\User Data\\Default").headless().windowSize(screen);
let driver = new Builder()
.forBrowser('chrome')
.setChromeOptions(option)
.build();
let adidas_url = "http://www.google.com";
driver.get(adidas_url)
.then(() => {
setTimeout(() => {
driver.takeScreenshot()
.then(
function(image, err) {
require('fs').writeFile('out.png', image, 'base64', function(err) {
console.log(err);
});
driver.quit();
}
);
}, 4000);
});
});